{"id":18257127,"url":"https://github.com/yzhong52/microservices-demo","last_synced_at":"2025-10-13T17:08:41.000Z","repository":{"id":40442052,"uuid":"182783666","full_name":"yzhong52/microservices-demo","owner":"yzhong52","description":"https://yuchen52.medium.com/developing-microservices-with-minikube-81b31e5366ac","archived":false,"fork":false,"pushed_at":"2024-12-08T23:58:54.000Z","size":170,"stargazers_count":6,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-04T18:38:44.282Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yzhong52.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-04-22T12:37:12.000Z","updated_at":"2024-12-08T23:58:50.000Z","dependencies_parsed_at":"2024-11-14T04:18:35.429Z","dependency_job_id":"1315d050-21d6-481a-a721-5f65c66f0de7","html_url":"https://github.com/yzhong52/microservices-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yzhong52/microservices-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yzhong52%2Fmicroservices-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yzhong52%2Fmicroservices-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yzhong52%2Fmicroservices-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yzhong52%2Fmicroservices-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yzhong52","download_url":"https://codeload.github.com/yzhong52/microservices-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yzhong52%2Fmicroservices-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274095422,"owners_count":25221433,"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","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-05T10:24:56.286Z","updated_at":"2025-10-13T17:08:35.981Z","avatar_url":"https://github.com/yzhong52.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kubernetes Microservices Demo\n\nThree simple services:\n\n**books_svc**\n\nTo keep things simple, we don't really have a database of books.\nFor whatever request that is made to the `/api/v1/book/:id` endpoint, we always return a same book.\n\n**auth_svc**\n\nIt will check the authorization token.\nIf it matches `SUPERSECUREAUTTHTOKEN`, then returns `{ok: true}`;\notherwise, return `{ok: false}`.\n\n**gateway_svc**\n\nIt has two endpoints `api/v1/hey` and `/api/v1/book/:id`.\n`api/v1/hey` will simply response \"Hello World\".\n`/api/v1/book/:id` will first authenticate the request by sending a request to **auth-svc**.\nIf it is authenticated, it will then make a request to **books-svc** asking for details for the book given id.\n\n## Running Services\n\nWe are using `books_svc` as an example here. But the principle is the same for `auth_svc` and `gateway_svc`.\n\n### Running service locally\n\nMake sure you have typescript installed.\n\n```\n$ npm install -g typescript\n$ tsc --version\n\nVersion 3.4.5\n```\n\nBuild and run `books_svc`.\n\n```\ncd books_svc\nnpm install\nnpm run build\nnpm run serve\n\ncurl http://localhost:8080/api/v1/book/1\n```\n\n### Running service inside minikube cluster\n\nBuild docker image (for the docker daemon inside minikube). \nCreate kubenete deployment and service.\n\n```\neval $(minikube docker-env)\ndocker build ./books_svc -t books\n\nkubectl apply -f books_svc/books-deployment.yaml\nkubectl apply -f books_svc/books-service.yaml\n\ncurl $(minikube service books-service --url)/api/v1/book/1\n```\n\n### Hybrid\n\nWhen we have multiple services running inside a minikube cluster and we want to develop or investigate one of them,\nit would be easier to launch that service locally while leaving the rest of the services running inside the cluster.\nIt is a faster change/build/validate development cycle and we can also utilize any IDE or debugger if needed. \nThat's what `books-service-local.yaml` is for.\nIt does two things:\n\n* Create a headless service without selectors. See kubernetes doc about [services-networking](https://kubernetes.io/docs/concepts/services-networking/service/#services-without-selectors). \n* Create an Endpoint object that point to localhost `10.0.2.2`, which is the host machine instead of the VM. \n\nThe IP to reach the host machine maybe driver dependend. We can use `ifconfig` to find out the host IP, which should be under `vboxnet0`.\n\nThese are some known alternatives:\n\n* `10.0.2.2` according to [link](https://stackoverflow.com/q/1261975/1035008)\n* `192.168.64.1` according to [link](https://github.com/machine-drivers/docker-machine-driver-xhyve/issues/196#issuecomment-328363611)\n* `192.168.99.1` according to [link](https://github.com/kubernetes/minikube/issues/2735)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyzhong52%2Fmicroservices-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyzhong52%2Fmicroservices-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyzhong52%2Fmicroservices-demo/lists"}