A blue/green deployment differs from a ramped deployment because the “green” version of the application is deployed alongside the “blue” version. After testing that the new version meets the requirements, we update the Kubernetes Service object that plays the role of load balancer to send traffic to the new version by replacing the version label in the selector field.
cd ~/Workshop-K8S/k8s/blue-green/
kubectl create ns blue-green
kubectl -n blue-green apply -f hello-world-blue.yaml
kubectl -n blue-green get pods
With CURL:
curl [public ip adress load balancer]/api
And in browser you should see the blue version (1.0.0):
<http://[public ip adress load balancer]
kubectl -n blue-green apply -f hello-world-green.yaml
kubectl -n blue-green get pods -w
Stop with CONTROL-C
With CURL:
curl [public ip adress load balancer]/api
And in browser you should see the blue version (1.0.0):
http://[public ip adress load balancer]
Check that service is pointing to blue
version:
kubectl -n blue-green describe svc hello-world-service
Change to green
version:
kubectl -n blue-green patch service hello-world-service -p '{"spec":{"selector":{"app":"hello-world-green"}}}'
With CURL:
curl [public ip adress load balancer]/api
And in browser you should see the green version (2.0.0):
http://[public ip adress load balancer]
kubectl delete ns blue-green