{"id":20558101,"url":"https://github.com/dineshba/docker-swarm-canary","last_synced_at":"2025-04-14T13:35:07.240Z","repository":{"id":42133726,"uuid":"264234369","full_name":"dineshba/docker-swarm-canary","owner":"dineshba","description":"Steps to achieve canary deployment in Docker swarm","archived":false,"fork":false,"pushed_at":"2020-05-22T14:45:05.000Z","size":15,"stargazers_count":6,"open_issues_count":0,"forks_count":6,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-28T02:45:49.290Z","etag":null,"topics":["canary","canary-deployment","docker","docker-swarm","envoy","envoyproxy"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/dineshba.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}},"created_at":"2020-05-15T15:47:29.000Z","updated_at":"2023-12-19T17:57:51.000Z","dependencies_parsed_at":"2022-09-17T17:24:48.359Z","dependency_job_id":null,"html_url":"https://github.com/dineshba/docker-swarm-canary","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/dineshba%2Fdocker-swarm-canary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dineshba%2Fdocker-swarm-canary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dineshba%2Fdocker-swarm-canary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dineshba%2Fdocker-swarm-canary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dineshba","download_url":"https://codeload.github.com/dineshba/docker-swarm-canary/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248889067,"owners_count":21178158,"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":["canary","canary-deployment","docker","docker-swarm","envoy","envoyproxy"],"created_at":"2024-11-16T03:42:17.154Z","updated_at":"2025-04-14T13:35:07.180Z","avatar_url":"https://github.com/dineshba.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Canary Deployment in Docker Swarm\n\n### Steps:\n\n#### Deploy the application that needs the canary deployment\n\n```sh\ndocker stack deploy -c docker-compose-app-only.yml myapplication\n```\n\nRun with proper replicas and update_config\n```yaml\ndeploy:\n      replicas: 2\n      update_config:\n        delay: 60s\n        parallelism: 1\n```\n\n#### Deploy a utils container which can be used for debugging\n\n```sh\ndocker stack deploy -c docker-compose-utils.yml utils\n```\n\n```sh\n# Exec into the container\n$(docker ps | grep utils | awk '{print \"docker exec -it \" $1  \" bash\" }')\n\n# continously ping the application\nwhile true; do curl myapplication:8123; sleep 1; date; echo \"\"; done;\n```\n\n#### Deploy the infra components that helps the canary.\n\nIn our case, we are going to use `envoy proxy` for the dynamic traffic shifting. We are going to use `Envoy-Pilot` which listens to the `consul` and updates the envoy proxies on the fly. So without restart, we can achieve the canary deployment. So this will install a consul (for production we need to run consul in cluster mode) and envoy-pilot\n\n```sh\ndocker stack deploy -c docker-compose-infra.yml infra\n```\n\n#### Inject envoy-proxy before our application so that we can start controlling the traffic\n\n- All the traffic that uses `myapplication` for **dns** will flow through the envoy\n- If you want to send the traffic from **interlock** to envoy, remove the labels related to interlock from `myapplication` and add it to `envoy`. Labels such as\n\n```yaml\ncom.docker.lb.hosts: dns-name-to-register-in-interlock\ncom.docker.lb.port: port\n```\n\n\u003e 10/20 sec downtime during this step\n```sh\ndocker stack deploy -c docker-compose-app-with-envoy.yml myapplication\n```\n\n#### Start the version 2 of the application in the new docker stack and change the config in consul, so that envoy-proxy can start splitting the traffic between two versions.\n\n```sh\ndocker stack deploy -c docker-compose-app-version-two.yml myapplication_v2\n```\n\n#### If everything goes well, install version of the application\n\n\u003e 5/10 sec downtime during this step\n```sh\ndocker stack deploy -c docker-compose-app-version-two-only.yml myapplication --prune\n```\n\n\n\u003e Note: `--prune` will clean the no longer referenced service in yaml file. In our case it will remove `consul-import` and `myapplication_behind_envoy`\n\n#### Clean the extra components which are used for canary\n\n```sh\ndocker stack rm infra\ndocker stack rm myapplication_v2\ndocker stack rm utils\n```\n\n#### Latency test after introducing envoy proxy:\nCommand used for testing:\n```sh\nwhile true; do curl -w \"%{time_total}\\n\" myapplication:8123/return/200?delay=1000 -o /dev/null -s; sleep 1; done;\n```\n\n```yaml\nwithout_proxy:\n  1.006084s\n  1.006302s\n  1.006514s\n  1.006616s\n  1.006759s\n  1.006860s\n  1.006884s\n\nwith_proxy:\n  1.006429s\n  1.006636s\n  1.006747s\n  1.006885s\n  1.007227s\n  1.008819s\n  1.009144s\n  1.010470s\n```\n\n##### so max delay(approx): 0.004 seconds **(4ms)**\n\nRefer [here](https://www.getambassador.io/resources/envoyproxy-performance-on-k8s/) for better Benchmarking Envoy Proxy, HAProxy, and NGINX Performance results.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdineshba%2Fdocker-swarm-canary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdineshba%2Fdocker-swarm-canary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdineshba%2Fdocker-swarm-canary/lists"}