Switching Traffic to Deployment Version 2
We can update our service.yaml as below.
apiVersion: v1
kind: Service
metadata:
name: blue-green-dep-service
spec:
ports:
- port: 8080
targetPort: 8080
selector:
app: dep-v2
After that we can use the same command to update our service,
kubectl apply -f service.yaml
At this point there shouldn’t be any difference but when we visit http://localhost:8080 again, version 2 of our app is live now. Make sure port forwarding is still on.
In any case if you want to switch to deployment version 1, we only need to update our service file. Then, we should remove the other version of the deployment that will not be used anymore.
kubectl delete -f dep-v1.yaml
What is Kubernetes Blue Green Deployment?
Blue-green deployment is a software deployment strategy that involves running two identical production environments, known as “blue” and “green.” At any given time, only one of these environments serves live traffic, while the other remains idle or serves only non-production traffic (e.g., testing or staging).