Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Rolling deployments with Kubernetes

In a previous post I worked through getting a Kubernetes cluster up and running on a local machine using minikube. Within this cluster I have one Deployment of a simple Hello World Go application.

kubectl get deployments
NAME       DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
hello-go   1         1         1            1           1d

How then do you deploy a new image? It is a simple case of updating an image within a deployment.

kubectl set image deployment/hello-go hello-go=shapeshed/hello-go:latest

The status of a rollout can be checked as follows

kubectl set image rollout status deployment/hello-go
Waiting for rollout to finish: 0 of 1 updated replicas are available...
deployment "hello-go" successfully rolled out

If for whatever reason you need to rollback just update the image to an older version.

kubectl setkubectl set image deployment/hello-go hello-go=shapeshed/hello-go:22ee0304

Recording history

Deployment history can be recorded by either adding --record when a deployment is created or by adding it to commands that modify a deployment. This provides details on any amends made to a deployment and the command issued.

kubectl set image deployment/hello-go hello-go=shapeshed/hello-go:latest --record

Now the history of a deployment may be seen

kubctl rollout history deployment hello-go
REVISION        CHANGE-CAUSE
1               kubectl set image deployment/hello-go hello-go=shapeshed/hello-go:22ee0304 --record
2               kubectl set image deployment/hello-go hello-go=shapeshed/hello-go:latest --record

A deployment may be rolled back as follows

kubectl rollout undo deployment hello-go

Summary

I have worked with most deployment tools - from FTP to Capistranoto Git post-receive hooks. Kubernetes offers a super simple way to update a deployment that can easily be integrated into Continuous Deployment workflows. Given that it is just containers that are being deployed there is a guaranteed idempotent version of an application. That makes Continuous Deployment far less risky and increases the possibility of shipping code to customers faster. A win all round.

Further reading

  • Kubernetes Deployments documentation
  • Kubernetes - Rolling updates with deployment
  • How to rollout or rollback a deployment on a Kubernetes cluster?
  • Rolling Updates and Rollbacks using Kubernetes Deployments


This post first appeared on Home | Shape Shed, please read the originial post: here

Share the post

Rolling deployments with Kubernetes

×

Subscribe to Home | Shape Shed

Get updates delivered right to your inbox!

Thank you for your subscription

×