{"id":13622337,"url":"https://github.com/FelixAnna/web-service-dlw","last_synced_at":"2025-04-15T05:34:45.441Z","repository":{"id":37479932,"uuid":"440916907","full_name":"FelixAnna/web-service-dlw","owner":"FelixAnna","description":"Restful Golang Microservice","archived":false,"fork":false,"pushed_at":"2024-04-22T14:28:09.000Z","size":5348,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-31T08:22:57.945Z","etag":null,"topics":["application-gateway","azure-kubernetes-service","consul","docker","gin-gonic","go-micro","golang","gorm","helm","horizontal-pod-autoscaler","kms","kong","kubernetes","mockery","mongodb","nginx","oauth2","parameter-store","testify","wire"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FelixAnna.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-22T16:18:55.000Z","updated_at":"2024-04-22T14:26:28.000Z","dependencies_parsed_at":"2024-04-22T15:52:35.113Z","dependency_job_id":null,"html_url":"https://github.com/FelixAnna/web-service-dlw","commit_stats":{"total_commits":422,"total_committers":4,"mean_commits":105.5,"dds":"0.17535545023696686","last_synced_commit":"63aff95b263d23861d0ff92c7533cb6c074d5484"},"previous_names":[],"tags_count":54,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FelixAnna%2Fweb-service-dlw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FelixAnna%2Fweb-service-dlw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FelixAnna%2Fweb-service-dlw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FelixAnna%2Fweb-service-dlw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FelixAnna","download_url":"https://codeload.github.com/FelixAnna/web-service-dlw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223486089,"owners_count":17153226,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["application-gateway","azure-kubernetes-service","consul","docker","gin-gonic","go-micro","golang","gorm","helm","horizontal-pod-autoscaler","kms","kong","kubernetes","mockery","mongodb","nginx","oauth2","parameter-store","testify","wire"],"created_at":"2024-08-01T21:01:17.848Z","updated_at":"2024-11-08T09:31:32.662Z","avatar_url":"https://github.com/FelixAnna.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# dlw - daily life web microservices (RESTful)\n\n[![Build Status](https://github.com/FelixAnna/web-service-dlw/workflows/Run%20Tests/badge.svg?branch=master)](https://github.com/FelixAnna/web-service-dlw/actions?query=branch%3Amaster)\n[![codecov](https://codecov.io/gh/FelixAnna/web-service-dlw/branch/master/graph/badge.svg)](https://codecov.io/gh/FelixAnna/web-service-dlw)\n[![Go Report Card](https://goreportcard.com/badge/github.com/FelixAnna/web-service-dlw/common)](https://goreportcard.com/report/github.com/FelixAnna/web-service-dlw/src/common)\n\n# Table of Contents\n\n- 1. [Prepare](#prepare)\n- 2. [Tools](#tools)\n- 3. [Switch Context](#switch-kubectl-context)\n\n- 4. [Components](#components)\n    - 4.1 [Microservices](#microservices)\n    - 4.2 [Ingress controller](#ingress)\n    - 4.3 [Metric Server](#metric-server)\n    - 4.4 [Dashboard](#dashboard)\n\n- 5. [DevOps](#devops)\n\t- 5.1 [Docker build and push](#docker-build--push-to-azure-container-registry)\n\t- 5.2 [Deploy to AKS with nginx](#aksnginx)\n\t- 5.3 [Deploy to AKS with application gateway](#aksappgw)\n\t- 5.4 [Deploy to local Kind cluster](#local-deployment)\n    \n- 6. [Front-end](#front-end)\n\n## Prepare \n1. Register OAuth Apps in https://github.com/settings/developers (2+ for different environment)\n   \n   the Authorization callback URL should be： {baseApiUrl}/user/oauth2/github/redirect\n   \n   keep the ClientID and ClientSecret\n\n2. Add parameters in aws parameter store: \n   \n   https://ap-southeast-1.console.aws.amazon.com/systems-manager/parameters/?region=ap-southeast-1\u0026tab=Table , \n   \n   use KMS customer managed keys if necessary.\n\n~~3. [deprecated]Create Tables in aws DynamoDB: dlf.Memos, dlf.Users~~\n   \n4. Prepare an SQL Server instance to store data for finance api, table will be automatic migrated\n\n5. Prepare database in MongoDB atlas (free forever for first 500MB)\n\t\n\t* database: dlw_mathematicals\n\t* collections： answers， questions\n\n\t* database: dlw_memo\n\t* collections： users， memos (replace dynamodb)\n\n## Tools\n\n1. install git: https://git-scm.com/downloads;\n2. install \\[dotnet 6 sdk\\] (https://dotnet.microsoft.com/en-us/download/dotnet/6.0);\n3. install [nodejs](https://nodejs.org/en/download/) and [npm](https://www.npmjs.com/package/npm);\n4. install and configure [azure cli](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli);\n5. install [kubectl](https://kubernetes.io/docs/tasks/tools/);\n6. install [helm](https://helm.sh/docs/intro/install/);\n7. install [terraform](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli);\n8. install [consul](https://developer.hashicorp.com/consul/downloads?host=www.consul.io).\n\n---\n\n1. \\[optional\\] install [postman](https://www.postman.com/downloads/);\n2. \\[optional\\] install [draw.io](https://github.com/jgraph/drawio-desktop/releases);\n3. \\[optional\\] install [docker](https://www.docker.com/);\n4. \\[optional\\] install [kind](https://kubernetes.io/docs/tasks/tools/#kind);\n5. \\[optional\\] install and configure [aws cli](https://aws.amazon.com/cli/).\n\n\n## Switch kubectl context\n\nafter you connected to aks, you context is attached to aks by default, if you want to check your local Kubernetes status, you need switch context:\n\n```bash\nkubectl config view\nkubectl config use-context kind-dlw-cluster\n```\n\n## Components\n### Microservices \n(Here is the Application Gateway version, Nginx version is very similar)\n![architecture overview](docs/architecture_dlw.png)\n\nService | Path | Tags\n--- | --- | ---\nUser api service | [user api service](/src/user-api/readme.md) | [![Go Report Card](https://goreportcard.com/badge/github.com/FelixAnna/web-service-dlw/src/user-api)](https://goreportcard.com/report/github.com/FelixAnna/web-service-dlw/src/user-api)\nMemo api service | [memo api service](/src/memo-api/readme.md) | [![Go Report Card](https://goreportcard.com/badge/github.com/FelixAnna/web-service-dlw/src/memo-api)](https://goreportcard.com/report/github.com/FelixAnna/web-service-dlw/src/memo-api)\nDate api service | [date api service](/src/date-api/readme.md) | [![Go Report Card](https://goreportcard.com/badge/github.com/FelixAnna/web-service-dlw/src/date-api)](https://goreportcard.com/report/github.com/FelixAnna/web-service-dlw/src/date-api)\nFinance api service | [finance api service](/src/finance-api/readme.md) | [![Go Report Card](https://goreportcard.com/badge/github.com/FelixAnna/web-service-dlw/src/finance-api)](https://goreportcard.com/report/github.com/FelixAnna/web-service-dlw/src/finance-api)\n\n### Ingress\nreference [ingress](./devops/ingress/readme.md)\n\n### Metric Server\n`devops/metrics/*.yaml`: enable metrics server which is necessary for horizontalautoscaler or veticalautoscaler if metric server not deployed by default, --kubelet-insecure-tls args is used for local, --metric-resolution can be set to longer if use docker-desktop\n\ncloud based kubernetes already include metric server by default.\n\n### Dashboard\n`devops/dashboard`: follow the instructions to enable dashboard.\n\n## DevOps\n\nin \"devops\" folder, you can find how to deploy the microservices to azure Kubernetes service.\n\nmicroservice helm chart is located in \"./dlw-chart\" and \"./dlw-chart-nossl\".\n\n### Docker build \u0026 push to azure container registry\n\n```\n  ## if you have docker, and want to push to docker hub\n\n  tag=latest\n\n  cd src/date-api\n  docker build -t dlw-date-api:$tag -f date-api/Dockerfile . \n  docker image tag dlw-date-api:$tag yufelix/dlw-date-api:$tag\n  docker image push yufelix/dlw-date-api:$tag\n  \n  cd ../finance-api\n  docker build -t dlw-finance-api:$tag -f finance-api/Dockerfile . \n  docker image tag dlw-finance-api:$tag yufelix/dlw-finance-api:$tag\n  docker image push yufelix/dlw-finance-api:$tag\n\n  cd ../memo-api\n  docker build -t dlw-memo-api:$tag -f memo-api/Dockerfile . \n  docker image tag dlw-memo-api:$tag yufelix/dlw-memo-api:$tag\n  docker image push yufelix/dlw-memo-api:$tag\n\n  cd ../user-api\n  docker build -t dlw-user-api:$tag -f user-api/Dockerfile . \n  docker image tag dlw-user-api:$tag yufelix/dlw-user-api:$tag\n  docker image push yufelix/dlw-user-api:$tag\n```\n\n```\n# from devops/docker-compose dir\ndocker compose build --push\n```\n\n```\n  ## if you do not have docker, and want to push to acr\n    \n  tag=latest\n  cd src/date-api\n  az acr build -t dlw-date-api:$tag -f Dockerfile -r hssdevacr -g felix-configuration-rg .\n  cd ../finance-api\n  az acr build -t dlw-finance-api:$tag -f Dockerfile -r hssdevacr -g felix-configuration-rg .\n  cd ../memo-api\n  az acr build -t dlw-memo-api:$tag -f Dockerfile -r hssdevacr -g felix-configuration-rg .\n  cd ../user-api\n  az acr build -t dlw-user-api:$tag -f Dockerfile -r hssdevacr -g felix-configuration-rg .\n\n ```\n\n### AKS(nginx)\n\ndeploy to aks with \"prod\" argument will create valid cert by cert-manager, and use consul as service register,\n\n```\n## deploy (need AWS CLI configured)\ncd aks\nsh install.sh prod  ## prod/dev\n```\n\n```\n## destroy (need AWS CLI configured)\ncd aks\nsh uninstall.sh prod  ## prod/dev\n```\n\n```\n## install/upgrade our microservices only (don't need to configure AWS CLI)\ncd aks/services\nsh main_services.sh prod ## prod/dev\n```\n\nfollowing： [./devops/aks_nginx/readme.md](./devops/aks_nginx/readme.md)\n\nrefer: [Securing NGINX-ingress](https://cert-manager.io/v0.14-docs/tutorials/acme/ingress/), [Let's Encrypt](https://letsencrypt.org/)\n\n### AKS(appgw)\n\nThis version contains SSL/TLS termination and https redirection, and use consul service discovery.\n\nfollowing： [./devops/aks_appgw/readme.md](./devops/aks_appgw/readme.md)\n\n refer: [aks](https://docs.microsoft.com/en-us/cli/azure/aks?view=azure-cli-latest#az-aks-create), [application gateway for aks](https://docs.microsoft.com/en-us/azure/application-gateway/tutorial-ingress-controller-add-on-existing#code-try-2),\n [application-gateway-kubernetes-ingress](https://azure.github.io/application-gateway-kubernetes-ingress)\n\n### local deployment\n\nThere is another folder \"./dlw-chart-nossl\" which is for deploying to a local kind cluster, it doesn't depend on cert-manager, and consul.\n\nfollow: [./devops/kind/readme.md](./devops/kind/readme.md)\n\n## Front-end\nimplemented by [ReactJs + Redux](https://github.com/FelixAnna/keep-hands-on/tree/master/important/dlw-app)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFelixAnna%2Fweb-service-dlw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFelixAnna%2Fweb-service-dlw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFelixAnna%2Fweb-service-dlw/lists"}