{"id":15178851,"url":"https://github.com/containersolutions/k8s-deployment-strategies","last_synced_at":"2025-05-14T16:14:57.122Z","repository":{"id":38363293,"uuid":"104323769","full_name":"ContainerSolutions/k8s-deployment-strategies","owner":"ContainerSolutions","description":"Kubernetes deployment strategies explained","archived":false,"fork":false,"pushed_at":"2024-04-24T08:10:01.000Z","size":3779,"stargazers_count":3580,"open_issues_count":2,"forks_count":1062,"subscribers_count":136,"default_branch":"master","last_synced_at":"2025-04-12T02:59:13.797Z","etag":null,"topics":["ab-testing","blue-green-deployment","canary","canary-deployment","deployment-automation","deployment-strategy","grafana","helm","kubernetes","kubernetes-deployment-strategies","prometheus"],"latest_commit_sha":null,"homepage":"https://container-solutions.com/kubernetes-deployment-strategies/","language":"Go","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/ContainerSolutions.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":"2017-09-21T08:46:42.000Z","updated_at":"2025-04-10T13:04:40.000Z","dependencies_parsed_at":"2022-08-09T03:15:32.936Z","dependency_job_id":"ffecb479-7d06-4358-a046-42a608bf6f3a","html_url":"https://github.com/ContainerSolutions/k8s-deployment-strategies","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/ContainerSolutions%2Fk8s-deployment-strategies","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ContainerSolutions%2Fk8s-deployment-strategies/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ContainerSolutions%2Fk8s-deployment-strategies/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ContainerSolutions%2Fk8s-deployment-strategies/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ContainerSolutions","download_url":"https://codeload.github.com/ContainerSolutions/k8s-deployment-strategies/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254179905,"owners_count":22027884,"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":["ab-testing","blue-green-deployment","canary","canary-deployment","deployment-automation","deployment-strategy","grafana","helm","kubernetes","kubernetes-deployment-strategies","prometheus"],"created_at":"2024-09-27T15:40:19.066Z","updated_at":"2025-05-14T16:14:57.067Z","avatar_url":"https://github.com/ContainerSolutions.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Kubernetes deployment strategies\n================================\n\n\u003e In Kubernetes there are a few different ways to release an application, you have\nto carefully choose the right strategy to make your infrastructure resilient.\n\n- [recreate](recreate/): terminate the old version and release the new one\n- [ramped](ramped/): release a new version on a rolling update fashion, one\n  after the other\n- [blue/green](blue-green/): release a new version alongside the old version\n  then switch traffic\n- [canary](canary/): release a new version to a subset of users, then proceed\n  to a full rollout\n- [a/b testing](ab-testing/): release a new version to a subset of users in a\n  precise way (HTTP headers, cookie, weight, etc.). This doesn’t come out of the\n  box with Kubernetes, it imply extra work to setup a smarter\n  loadbalancing system (Istio, Linkerd, Traeffik, custom nginx/haproxy, etc).\n- [shadow](shadow/): release a new version alongside the old version. Incoming\n  traffic is mirrored to the new version and doesn't impact the\n  response.\n\n![deployment strategy decision diagram](decision-diagram.png)\n\nBefore experimenting, checkout the following resources:\n- [CNCF presentation](https://www.youtube.com/watch?v=1oPhfKye5Pg)\n- [CNCF presentation slides](https://www.slideshare.net/EtienneTremel/kubernetes-deployment-strategies-cncf-webinar)\n- [Kubernetes deployment strategies](https://container-solutions.com/kubernetes-deployment-strategies/)\n- [Six Strategies for Application Deployment](https://thenewstack.io/deployment-strategies/).\n- [Canary deployment using Istio and Helm](https://github.com/etiennetremel/istio-cross-namespace-canary-release-demo)\n- [Automated rollback of Helm releases based on logs or metrics](https://container-solutions.com/automated-rollback-helm-releases-based-logs-metrics/)\n\n## Getting started\n\nThese examples were created and tested on [Minikube](http://github.com/kubernetes/minikube)\nrunning with Kubernetes v1.25.2 and [Rancher Desktop](https://rancherdesktop.io/) running\nwith Kubernetes 1.23.6.\n\nOn MacOS the hypervisor VM does not have external connectivity so docker image pulls\nwill fail. To resolve this, install another driver such as\n[VirtualBox](https://www.virtualbox.org/) and add `--vm-driver virtualbox`\nto the command to be able to pull images.\n\n```\n$ minikube start --kubernetes-version v1.25.2 --memory 8192 --cpus 2\n```\n\n## Visualizing using Prometheus and Grafana\n\nThe following steps describe how to setup Prometheus and Grafana to visualize\nthe progress and performance of a deployment.\n\n### Install Helm3\n\nTo install Helm3, follow the instructions provided on their\n[website](https://github.com/kubernetes/helm/releases).\n\n### Install Prometheus\n\n```\n$ helm install prometheus prometheus-community/prometheus \\\n    --create-namespace --namespace=monitoring \\\n    -f prometheus-override.yaml\n```\n\n### Install Grafana\n\n```\n$ helm install grafana \\\n    --namespace=monitoring \\\n    --set=adminUser=admin \\\n    --set=adminPassword=admin \\\n    --set=service.type=NodePort \\\n    grafana/grafana\n```\n\n### Setup Grafana\n\nNow that Prometheus and Grafana are up and running, you can access Grafana:\n\n```\n$ minikube service grafana -n monitoring\n```\n\nTo login, username: `admin`, password: `admin`.\n\nThen you need to connect Grafana to Prometheus, to do so, add a DataSource:\n\n```\nName: prometheus\nType: Prometheus\nUrl: http://prometheus-server\nAccess: Server\n```\n\nCreate a dashboard with a Time series or import\nthe [JSON export](grafana-dashboard.json) - update the UID first of the Prometheus source. Use the following query:\n\n```\nsum(rate(http_requests_total{app=\"my-app\"}[2m])) by (version)\n```\n\nSince we installed Prometheus with default settings, it is using the default scrape\ninterval of `1m` so the range cannot be lower than that.\n\nTo have a better overview of the version, add `{{version}}` in the legend field.\n\n#### Example graph\n\nRecreate:\n\n![Kubernetes deployment recreate](recreate/grafana-recreate.png)\n\nRamped:\n\n![Kubernetes deployment ramped](ramped/grafana-ramped.png)\n\nBlue/Green:\n\n![Kubernetes deployment blue-green](blue-green/grafana-blue-green.png)\n\nCanary:\n\n![Kubernetes deployment canary](canary/grafana-canary.png)\n\nA/B testing:\n\n![kubernetes ab-testing deployment](ab-testing/grafana-ab-testing.png)\n\nShadow:\n\n![kubernetes shadow deployment](shadow/grafana-shadow.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontainersolutions%2Fk8s-deployment-strategies","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcontainersolutions%2Fk8s-deployment-strategies","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontainersolutions%2Fk8s-deployment-strategies/lists"}