Blue/Green Deployment
We can create our "blue" deployment by saving the following yaml to a file blue.yaml.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-1.10
spec:
replicas: 3
template:
metadata:
labels:
name: nginx
version: "1.10"
spec:
containers:
- name: nginx
image: nginx:1.10
ports:
- name: http
containerPort: 80You can then create the deployment using the kubectl command.
Save this to service.yaml.
Creating the service will create a load balancer that is accessible outside the cluster.
For the "green" deployment we will deploy a new deployment in parallel wit the "blue" deployment. If the following is in green.yaml...
... I can create the new deployment like so.
To cut over to the "green" deployment we will update the selector for the service. Edit the service.yaml and change the selector version to "1.11". That will make it so that it matches the pods on the "green" deployment.
This apply will update the existing nginx service in place.
Automating
References
https://www.ianlewis.org/en/bluegreen-deployments-kubernetes
Last updated