Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I manage deployments with kubernetes

I am hoping to find a good way to automate the process of going from code to a deployed application on my kubernetes cluster.

In order to build and deploy my app I need to first build the docker image, tag it, and then push it to ECR. I then need to update my deployment.yaml with the new tag for the docker image and run the deployment with kubectl apply -f deployment.yaml.

This will go and perform a rolling deployment on the kubernetes cluster updating the pods to the new version of the container image, once this deployment has completed I may need to do other application specific things such as running database migrations, or cache clear/warming which may or may not need to run for a given deployment.

I suppose I could just write a shell script that runs all of these commands, and run it whenever I want to start up a new deployment, but I am hoping there is a better/industry standard way to solve these problems that I have missed.

As I was writing this question I noticed stackoverflow recommend this question: Kubernetes Deployments. One of the answers to it seems to imply at least some of what I am looking for is coming soon to kubernetes, but I want to make sure that if there is a better solution I could be using now that I at least know about it.

like image 430
Carl Minden Avatar asked May 25 '16 00:05

Carl Minden


1 Answers

My colleague has a good blog post about this topic:

http://blog.jonparrott.com/building-a-paas-on-kubernetes/

Basically, Kubernetes is not a Platform-as-a-Service, it's a toolkit on which you can build your own Platform-a-as-Service. It's not very opinionated by design, instead it focuses on solving some tricky problems with scheduling, networking, and coordinating containers, and lets you layer in your opinions on top of it.

One of the simplest ways to automate the workflows you're describing is using a Makefile.

A step up from that, you can design your own miniature PaaS, which the author of the first blog post did here:

https://github.com/jonparrott/noel

Or, you could get involved in more sophisticated efforts to build an open source PaaS on Kubernetes, like OpenShift:

https://www.openshift.com/

or Deis, which is building a Heroku-like platform on Kubernetes:

https://deis.com/

or Redspread, which is building "Git for Kubernetes cluster":

https://redspread.com/

and there are many other examples of people building PaaS on top of Kubernetes. But I think it will be a long time, if ever, that there is an "industry standard" way to deploy to Kubernetes, since half the purpose is to enable multiple deployment workflows for different use cases.

I do want to note that as far as building container images, Google Cloud Container Builder can be a useful tool, since you can do things like use it to automatically build an image any time you push to a repository which could then get deployed. Alternatively, Jenkins is a popular way to automate CI/CD flows with Kubernetes.

like image 172
Bill Prin Avatar answered Oct 15 '22 00:10

Bill Prin