Note: If you have missed my previous articles on Docker, you can find them here.
Application deployment models evolution.
Getting started with Docker.
Docker file and images.
Publishing images to Docker Hub and re-using them
Docker- Find out what's going on
Docker Networking- Part 1
Docker Networking- Part 2
Docker Swarm-Multi-Host container Cluster
Docker Networking- Part 3 (Overlay Driver)
Before we get into Kubernetes, let me do a quick recap:
Docker enables developers to deploy an application or service inside containers. Services like httpd (apache) could be deployed with a single command "docker run -detach --name web -p 80:80 httpd"
Docker allows the creation of custom images. Images with custom applications can be built and pushed to the docker hub. See Docker file and images and Publishing images to Docker Hub and re-using them.
Docker Swarm is Docker's built-in orchestration system that allows containers to be run across multiple hosts. See Docker Swarm-Multi-Host container Cluster
So, What is Kubernetes?
Kubernetes (or K8) is an orchestration system and an alternative to Docker Swarm. Kubernetes uses Docker hosts to host containers. Kubernetes was originally developed by Google and open-sourced in 2015, it's maintained by the open-source community now.
There are different distributions of Kubernetes depending on deployment- Cloud or on-premise. Amazon AWS, Google's GCP have their own distribution of Kubernetes that can be deployed on respective cloud platforms. For on-premise deployments, there are choices like Docker-Enterprise, OpenShift, Canonical, VMWare PKS. Due to vendor support, Kubernetes has become very popular and is often the first choice of orchestration system for containers.
Let's look at the requirements of a container orchestration system and how it can be accomplished with Kubernetes:
Ability to run multiple replicas of service across multiple hosts:
Once the Kubernetes cluster is setup this can be accomplished with a single command:
kubectl run --replicas=1000 mycustomapp
2. Ability to scale replicas dynamically (horizontal scaling)
kubectl scale --replicas=2000 mycustomapp
3. Ability to do "rolling upgrades" for all instances with a single command
kubectl rolling-update mycustomapp --image=mycustomapp:2
4. Ability to "rollback" to a previous version if there are problems with the upgrade
kubectl rolling-update mycustomapp --rollback
A Kubernetes cluster consists of a set of nodes (Docker hosts with Kubernetes). Containers are launched on these nodes. Each cluster has a master (similar to Manager/Leader in Docker swarm) that manages services across nodes with a control plane protocol. Replicas of service can be run across nodes in a cluster. If a node fails, replicas running in the failed node are automatically launched on other nodes by the master.
When Kubernetes is installed, it installs various software components:
API Server: This is front end for Kubernetes. Command-line, devices, users talk to the Kubernetes cluster via the API server.
etcd: This is a distributed key-value store used to store data required to manage the cluster (control plane). The consistency of data across nodes is ensured.
Scheduler: This is responsible for distributing the workload across nodes in the cluster when new services are created.
Controller: The controller is responsible for bringing up new containers on active nodes in case of failures among other things.
Container Runtime: This is Docker in most cases.
Kubelet: This ensures containers are running on nodes as expected. This is like a "heartbeat" for cluster health.
Finally, kubectl is the command line for deploying and managing services/nodes/containers in a cluster.
I Hope, this introduction to Kubernetes was useful. In the next article, I will show you how to install Kubernetes on Ubuntu and set a Kubernetes cluster.
Comments