Deploying an Application Using the Blue/Green Strategy

You are running a high-available application on Kubernetes that needs a deployment strategy to handle updates. This application, for example, a mortgage calculation engine API, has different versions, which result in different calculation results. Therefore, the client requires extensive testing before release and instant switches between the versions. We'll run an application with blue/green strategy so that both versions are running, and Kubernetes service handles instant switch of version. We'll run an application with blue/green strategy so that both versions are running, and Kubernetes service handles instant switch of version. Let's begin by performing the following steps:

  1. Create both versions of the deployment and the common service with the following command:
kubectl apply -f blue-green.yaml

  1. Check that both versions are deployed on the cluster with the following command:
kubectl get pods

You should see the following output:

  1. In a separate terminal, start a cURL instance in the Kubernetes cluster:
kubectl run curl --image=tutum/curl --rm -it
  1. When the command prompt is ready, watch for the version of the deployment by using an HTTP request:
while sleep 0.5; do curl -s http://blue-green/version | grep nginx; done
  1. Update the service to route traffic to the new version with the following command:
kubectl patch service blue-green -p '{"spec":{"selector":{"version":"1.11"}}}'

  1. In the terminal that we opened in Step 3, we should see the Kubernetes service handling an instant change of versions without any interruption:

  1. For cleanup, stop the cURL command with Ctrl + C and exit from the pod by writing exit. The pod will be deleted by Kubernetes upon exit. Run the following command:
kubectl delete -f blue-green.yaml
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.247.81