- Notifications
You must be signed in to change notification settings - Fork1.1k
Kubernetes deployment strategies explained
ContainerSolutions/k8s-deployment-strategies
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
In Kubernetes there are a few different ways to release an application, you haveto carefully choose the right strategy to make your infrastructure resilient.
- recreate: terminate the old version and release the new one
- ramped: release a new version on a rolling update fashion, oneafter the other
- blue/green: release a new version alongside the old versionthen switch traffic
- canary: release a new version to a subset of users, then proceedto a full rollout
- a/b testing: release a new version to a subset of users in aprecise way (HTTP headers, cookie, weight, etc.). This doesn’t come out of thebox with Kubernetes, it imply extra work to setup a smarterloadbalancing system (Istio, Linkerd, Traeffik, custom nginx/haproxy, etc).
- shadow: release a new version alongside the old version. Incomingtraffic is mirrored to the new version and doesn't impact theresponse.
Before experimenting, checkout the following resources:
- CNCF presentation
- CNCF presentation slides
- Kubernetes deployment strategies
- Six Strategies for Application Deployment.
- Canary deployment using Istio and Helm
- Automated rollback of Helm releases based on logs or metrics
These examples were created and tested onMinikuberunning with Kubernetes v1.25.2 andRancher Desktop runningwith Kubernetes 1.23.6.
On MacOS the hypervisor VM does not have external connectivity so docker image pullswill fail. To resolve this, install another driver such asVirtualBox and add--vm-driver virtualboxto the command to be able to pull images.
$ minikube start --kubernetes-version v1.25.2 --memory 8192 --cpus 2The following steps describe how to setup Prometheus and Grafana to visualizethe progress and performance of a deployment.
To install Helm3, follow the instructions provided on theirwebsite.
$ helm install prometheus prometheus-community/prometheus \ --create-namespace --namespace=monitoring \ -f prometheus-override.yaml$ helm install grafana \ --namespace=monitoring \ --set=adminUser=admin \ --set=adminPassword=admin \ --set=service.type=NodePort \ grafana/grafanaNow that Prometheus and Grafana are up and running, you can access Grafana:
$ minikube service grafana -n monitoringTo login, username:admin, password:admin.
Then you need to connect Grafana to Prometheus, to do so, add a DataSource:
Name: prometheusType: PrometheusUrl: http://prometheus-serverAccess: ServerCreate a dashboard with a Time series or importtheJSON export - update the UID first of the Prometheus source. Use the following query:
sum(rate(http_requests_total{app="my-app"}[2m])) by (version)Since we installed Prometheus with default settings, it is using the default scrapeinterval of1m so the range cannot be lower than that.
To have a better overview of the version, add{{version}} in the legend field.
Recreate:
Ramped:
Blue/Green:
Canary:
A/B testing:
Shadow:
About
Kubernetes deployment strategies explained
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors8
Uh oh!
There was an error while loading.Please reload this page.






