Professional Documents
Culture Documents
@jakubkrzywda
How to perform
BLUE–GREEN DEPLOYMENTS
using only Kubernetes
Primitives?
Blue–green deployment refers to running
two application environments in parallel
in a production cluster.
replicas: 3
...
labels:
app: myapp
track: blue
image: myapp:v1
Create Blue Deployment
1.
replicas: 3
...
labels:
app: myapp
track: blue
image: myapp:v1
Expose it with a Service
2.
name: myservice
selector:
app: myapp
track: blue
replicas: 3
...
labels:
app: myapp
track: blue
image: myapp:v1
Expose it with a Service
2.
Service selector uses both labels –
app and track. Therefore, it precisely
matches the blue deployment!
name: myservice
selector:
app: myapp
track: blue
replicas: 3
...
labels:
app: myapp
track: blue
image: myapp:v1
Add an Ingress
3.
backend:
service: myservice
name: myservice
selector:
app: myapp
track: blue
replicas: 3
...
labels:
app: myapp
track: blue
image: myapp:v1
Add an Ingress
3.
backend:
service: myservice
Ingress is optional
but useful to
expose application
name: myservice
outside the cluster. selector:
app: myapp
track: blue
replicas: 3
...
labels:
app: myapp
track: blue
image: myapp:v1
Add Green Deployment
4.
backend:
service: myservice
name: myservice
selector:
app: myapp
track: blue
replicas: 3 replicas: 3
... ...
labels: labels:
app: myapp app: myapp
track: blue track: green
image: myapp:v1 image: myapp:v2
Add Green Deployment
4.
Notice different values backend:
of track label and service: myservice
image tag.
replicas: 3 replicas: 3
... ...
labels: labels:
app: myapp app: myapp
track: blue track: green
image: myapp:v1 image: myapp:v2
Switch to Green Deployment
5.
backend:
service: myservice
name: myservice
selector:
app: myapp
track: green
replicas: 3 replicas: 3
... ...
labels: labels:
app: myapp app: myapp
track: blue track: green
image: myapp:v1 image: myapp:v2
Switch to Green Deployment
5.
backend:
service: myservice
replicas: 3 replicas: 3
... ...
labels: labels:
app: myapp app: myapp
track: blue track: green
image: myapp:v1 image: myapp:v2
JAKUB KRZYWDA
@jakubkrzywda