Kubernetes Overview
We hear a lot about Kubernetes, what is it really?
Earlier we had servers which consisted of hardware, operating system and application. Each component was tightly bound to each other, could not run windows application on linux server, vice-versa.
Then came VMware which made workloads portable, but moving vm images from server-A to server-B was still an issue due to image size.
Then came Docker which trimmed image size called it containers. Containers are mobile and they boot-up fast.
Then came Kubernetes to look after those containers, where to place which container and see that containers are healthy.
Kubernetes is platform to run distributed systems. It is a container orchestrator. It basically serves following objectives
- Create an efficient deployment workflow.
- Provides immutable deployments.
- Ability to pack more workloads into available resources.
- Improve application availability by self healing.
- Abstract the underlying infrastructure so that workloads are portable.
Kubernetes is API driven, container centric system. It is one of the most active open source project with close to 2000 contributors. It is written in Go. It abstracts the cluster implementation from workloads. So applications can be written once, run on any cloud provider or on-premise.
we can deploy on AWS, GCP, Azure or on-premise, the application remains consistent across the deployments.
Kubernetes components
It consists of master node and sets of worker nodes. Control plane runs on master node, applications runs on worker nodes.
In simple terms Kubernetes is nothing but a database fronted by API server. API server is the policy engine that sits in front of etcd, a highly consistent distributed database that holds the cluster state. Controller manager is set control loops that reconcile the actual state in cluster to desired state stored in database.
Kubernetes follows declarative schema, where the user express their intent declaratively and it is upto Kubernetes to maintain intent expressed.
Scheduler assigns workloads to appropriate worker nodes.
Kubelet is agent that runs on every node and makes sure that container are running and healthy.
Container runtime is responsible to run containers, Kubernetes supports docker, rkt, containerd or any OCI compliant implementation.
Kubernetes Primitives
POD
Kubernetes manages Pods rather than containers directly. Pod is a wrapper over container, it represents an instance of application. It encapsulates container, storage resource, network IP and other options that govern how container is suppose to run.
Pod can consist of single container or set of tightly coupled containers that share resources. All the containers in the Pod land on same node.
Example of co-located containers can be, one container serving html web pages to outside world and a side-car container populating those html web pages. Both the container share a storage volume. One container writes to volume other container reads from it.
Pods are ephemeral, if the node goes down, Pods are scheduled for deletion. It is more common to manage Pods using a Controller.
Relicaset Controller
Relicaset controller takes a count, and template to create Pods.
It makes sure specified number of Pods are always running on the cluster. If any node goes down, Pods are rescheduled on different node.
Replicaset is managed by higher level abstraction called Deployment.
Deployment
Deployment manages the rolling out of application. When a new version of application is to be rolled out, it creates a new Replicaset. It rolls down the Pods created by old Replicaset and rolls up the Pods on new Replicaset.
StatefulSets
StatefulSets attaches persistent storage with the instance of application. It provides guarantee of ordering and provides unique ID to Pod.
It is used by applications that requires stable network ID, persistent storage, graceful deployment and termination.
Storage is either dynamically provisioned or pre-provisioned by Admin. Network ID for the Pods is provided by Headless service.
DaemonSet
DaemonSet ensures that a Pod runs on every node in cluster. Examples of these kinds of Pods are log collectors and node monitoring agents.
Job
Till now all controllers were about creating applications that need to run for ever, if an instance goes down, it needs to be recreated. Jobs are about tasks that need to run to completion. Job need to run till it is successful.
Cronjob
Cronjob creates Jobs based on schedule.
Service
Pods are ephemeral, when the Pods are rescheduled, they get new IP address. Services groups the Pods providing the same functionality and provides them a virtual IP address. Workloads can access these Pods using virtual IP address, without having to worry about ephemeral nature of Pods.
Services can also provision LoadBalancers provided by cloud provider, so that functionality provided by group of Pods can be exposed to outside world. LoadBalancer will redirect the traffic to virtual IP address, which redirects to one of the Pods backing the service.
This was a brief overview on Kubernetes.
Originally published at gist.github.com.