OpenStack, Kubernetes and OpenShift crash course for impatient - Kubernetes
January 20, 2018 2 min read
Kubernetes is a system for orchestration of containerized applications that can be used to deploy your microservice-based websites to the cloud. Kubernetes is created by Google, based on their internal orchestration system Borg (although, codebase is re-written completely from scratch). Kubernetes is written mostly in Go programming languages and is open-source.
Kubernetes
Kubernetes assumes that each microservice of your application is represented by a set of containers, currently specifically Docker containers (but integration with other containerization systems are underway, e.g. see CoreOS rkt and its differences from Docker).
Here are the key concepts and entities of Kubernetes (see the official docs).
- Nodes - Nodes are servers that you're deploying your Kubernetes application to; for instance, these can be represented by dedicated servers at Hetzner.de or OpenStack instances.
- Cluster - all the Nodes that Kubernetes is operating on constitute Kubernetes Cluster.
- Master - single point of failure of the Cluster that manages all the nodes and offers API which interacts with user and accepts commands from kubectl utility.
- Images and Containers - images and containers are Docker images and containers (although, Kubernetes engineers work on porting it to other containerization systems). Kubernetes dowloads your images from Docker Hub or its private analogues and build containers from them.
- Pods - pods in the same sense as in rkt. These are "logical servers" of your app. Each pod contains a group of containers that are meant to reside on the same physical server (node) and a number of volumes. For instance, your Nginx reverse proxy container (used to serve static assets like javascript, css, images and fonts) and your Node.js Express web server container (used for backend rendering of your React web application) might reside in the same pod and share a volume with your static assets.
- Volumes, Persistent Volumes and Persistent Volume Claims - Volumes are NOT just docker volumes, but a piece of block storage that is allocated from underlying IaaS for a pod and lives as long as the pod lives (similarly to OpenStack ephemeral disks). Unlike regular Volumes, Persistent Volumes are volumes in terms of underlying IaaS solution, they are meant to outlive corresponding pods (e.g. if your IaaS is OpenStack, these are Cinder Volumes). Persistent Volume is an available volume resource, while Persistent Volume Claim is a specific allocated Persistent Volume for a certain current pod. Persistent Volume Claim consumes Persistent Volume resources same way as Pod consumes Node resources.
- Controllers - orchestrators that determine, how multi-pod configurations are deployed on you Kubernetes cluster. Possible controller types are called Deployment, ReplicationController, ReplicaSet, StatefulSet, DaemonSet, GarbageCollection and Jobs.
To be a part of Kubernetes Cluster a Node has to run at least the following processes:
- kubelet - agent program similar to what Jenkins or OpenStack run, that communicates with master
- container engine - usually, Docker, to run containers
- kube-proxy - routing utility that programs iptables to provide virtual IPs and load-balancing for pods
To create Kubernetes deployment, you need to create a .YAML file, that declaratively describes your desired cluster state. Kubernetes will try its best to make your cluster fit the config you specified. See full reference of .YAML file options in the reference section of documentation and see examples of .YAML configurations in tasks section.
To interact with Kubernetes you'll probably use kubectl
utility. Its full reference is also available
in reference section of
the Kubernetes documentation.
To try Kubernetes out on your local machine, try installing Minikube. It will create a VM on your local computer that will work as a Node of Kubernetes cluster and you will be able to try your deployment configuration on it. It will also run a web server with a nice dashboard, describing the state of your Kubernetes cluster.
Written by Boris Burkov who lives in Moscow, Russia, loves to take part in development of cutting-edge technologies, reflects on how the world works and admires the giants of the past. You can follow me in Telegram