Over the past few days I’ve been reading up on, and experimenting with Kubernetes. If you’re also interested to see what the hype is all about (and so far I have to say — the hype is warranted, if you care about DevOps at all), here are the resources I used to get started.
Install minikube to start experimenting locally. This boots up a local VM (e.g. Virtualbox VM) with Kubernetes installed, and sets up the kubectl command to connect to it. Alternatively, just set up a small cluster on Google Container Engine (these can be as small as 1 VM), but… it’s not free.
Read Kubernetes in Action
Read Kubernetes in Action (still MEAP). At home I have little time to sit behind a computer and experiment, but I do find time here and there to read a few pages in a book to get familiar with the concepts. Kubernetes in Action (still in early access) was a great help here.
Get a private docker repository
Kubernetes always has to pull its images from some docker repository. If you work on random open source stuff, you can use the public Docker registry for this. However, if you want to experiment with more private stuff, you need a private docker repository. I use GCR (Google Container Registry) for this purpose. Setting this up basically involves:
- Creating a Google account (in the rare case you don’t have one)
- Create a Google Cloud Platform project and attach billing to it
Setup the gcloud tool on your machine to start pushing your images to GCR. After you install this tool and set it up (gcloud init), you can now start pushing your images there (e.g. gcloud docker push gcr.io/yourproject/yourimage)
The next challenge is to pull these images in minikube. Here’s how I got this to work:
$ gcloud auth application-default print-access-token
# Then copy and paste the output
# Next, we ssh into the minikube VM:
$ minikube ssh
# Once in, we can login to the registry
$ docker login -u oauth2accesstoken -p "<<paste your access token here>>" https://gcr.io
# And log back out
That should be it.
Go higher level
Once mastering the basics, it may become worth looking into higher-level abstractions built on to of Kubernetes. Like Helm, a package manager. This makes it easier to deploy some commonly used software to your cluster, e.g. a highly available MySQL, or some other database.