Deploying an Application Using the Rolling Update Strategy

You are running a high-available application on Kubernetes that needs a deployment strategy to handle updates. This application, let's say, the frontend of your client's company, should always be available so that downtime is out of the question. Multiple versions of the applications could be working together at any time; however, the client does not want to cover the cost of extra resources during the update. We'll run an application with the rolling update deployment strategy so that updates will be handled by Kubernetes by incrementally creating new instances and deleting old instances, one after another. Let's begin by following these steps:

  1. Create the deployment with the following command:
kubectl apply -f rolling.yaml
  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://rolling/version | grep nginx; done
  1. Update the version of the deployment with the following command:
kubectl patch deployment rolling -p '{"spec":{"template":{"spec":{"containers":[{"name":"nginx", "image":"nginx:1.11"}]}}}}'

  1. In the terminal that we opened in Step 2, it is expected that we should see Kubernetes handle an incremental change of versions. During the update, there is no interruption of the service. However, both versions are alive and serving requests as 1.10.3 and 1.11.13, and are used interchangeably:

  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 rolling.yaml

You can find the rolling.yaml file at: https://goo.gl/eo8cJw.

..................Content has been hidden....................

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