{"id":21982527,"url":"https://github.com/ideal/kubernetes-demo","last_synced_at":"2025-04-30T05:22:40.250Z","repository":{"id":137752180,"uuid":"224449115","full_name":"ideal/kubernetes-demo","owner":"ideal","description":"Demo for running services in Kubernetes.","archived":false,"fork":false,"pushed_at":"2019-12-09T09:05:58.000Z","size":1418,"stargazers_count":34,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T13:04:13.874Z","etag":null,"topics":["archlinux","consul","docker","hyperf","java","kubernetes","microservice","mysql","php","swoole"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/ideal.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-11-27T14:28:47.000Z","updated_at":"2024-07-07T19:47:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"ec053074-ce35-4b2a-85c6-4bfe880b65ef","html_url":"https://github.com/ideal/kubernetes-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ideal%2Fkubernetes-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ideal%2Fkubernetes-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ideal%2Fkubernetes-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ideal%2Fkubernetes-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ideal","download_url":"https://codeload.github.com/ideal/kubernetes-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251645989,"owners_count":21620848,"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":["archlinux","consul","docker","hyperf","java","kubernetes","microservice","mysql","php","swoole"],"created_at":"2024-11-29T17:28:36.536Z","updated_at":"2025-04-30T05:22:40.244Z","avatar_url":"https://github.com/ideal.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kubernetes-demo\n\ndemo for running services in Kubernetes.\n\n# Steps\n\n0. install `kubectl` and `helm`, run `helm init` to init both server (install tiller) and client.\n\n1. Optional: build and push Docker images (if you need) under `mysql/master`, `mysql/slave`, `archlinux-php`, `backend-service`, `backend-www`. If you build and push images yourself, you need to change container image in the corresponding yaml files.\n\n2. Deploy MySQL master:\n\n```shell\nkubectl apply -f mysql/master/mysql-master-local.yaml\n```\n\n3. Deploy MySQL slave:\n\n```shell\nkubectl apply -f mysql/slave/mysql-slave-local.yaml\n```\n\n4. Deploy consul:\n\nChange server.storage and server.storageClass to fit your requirement.\n\n```shell\ngit submodule update --init\ncd consul/consul-helm \u0026\u0026 helm install --name consul --set server.storage=20Gi,server.storageClass=alicloud-disk-ssd ./\n```\n\n5. Deploy backend-service, which provides jsonrpc service for backend-www:\n\n```shell\nkubectl apply -f backend-service/backend-service.yaml\n```\n\n6. Deploy backend-www, which calls backend-service and provides HTTP web access:\n\n```shell\nkubectl apply -f backend-www/backend-www.yaml\n```\n\n7. Test if all are ok:\n\n```shell\n# get backend-www's EXTERNAL-IP\nkubectl get svc\n\n# If you have EXTERNAL-IP\ncurl -i -XPOST \"EXTERNAL-IP/user?name=fatcat\"\n\n# If you have no EXTERNAL-IP\n# Change xxxx to your Pod name\nkubectl exec backend-www-xxxx -- curl -i -XPOST \"backend-www/user?name=fatcat\"\n\n# Check fatcat_db.user table in mysql master or slave if data inserted\n...\n```\n\n8. Maybe the most exciting features of Kubernetes:\n\n```shell\n# scaling\nkubectl scale --replicas 6 deployment/backend-service\nkubectl scale --replicas 6 deployment/backend-www\nkubectl scale --replicas 4 deployment/mysql-slave\n\n# autoscaler\nkubectl autoscale deployment/backend-service --min=2 --max=20 --cpu-percent=50\n\n# graceful upgrading\nkubectl set image deployment/backend-service backend-service=ideal/backend-service:0.0.1\n\n# graceful restarting\nkubectl rollout restart deployment/backend-www\n```\n\n![Pods](.image/pods.png?raw=true \"Pods\")\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fideal%2Fkubernetes-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fideal%2Fkubernetes-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fideal%2Fkubernetes-demo/lists"}