Kubernetes (k8s) is an open-source container orchestration system. The platform manages, deploys and scales containerized applications.Â
Benefits of Kubernetes
Kubernetes presents several benefits for organizations:
- Open-sourceâ€”Kubernetes can run containers on public, private or on-premises environments. It is compatible with several platforms, in summary, it can be deployed almost anywhere.
- Scalableâ€”k8s offers several features for scaling workloads. You can scale horizontally, adding or removing nodes. Kubernetes also offers autoscaling, which enables you to set the number of containers you want to run.Â
- Highly availableâ€”the platform ensures high availability through self-healing. k8s constantly monitors the health of nodes and pods. Another feature that helps with high availability is load balancing. The load balancer ensures that the resources get distributed the load across multiple workloads.
Kubernetes: Key Concepts
Kubernetes architecture starts with containers. A container is the smallest unit in the k8 platform. It is a packaged software, usually containing one process in a self-contained unit. This unit or container has everything the process needs to run.Â
A pod is a group of containers that share the same networking and storage resources. One of the characteristics of the pod is that when it is deleted, it cannot be restored.Â
A node is a server the pods run on. It represents a single machine in your cluster. It can be a physical or virtual machine.Â
A cluster consists of a collection of nodes. The cluster distributes the workload to the individual nodes for you. If you remove or add new nodes, the cluster redistributes the load.Â
Pods are usually managed in a deployment layer. A deployment is k8sâ€™ way to achieve high availability. While pods are mortal, you can set the number of pods you want running. Kubernetes uses deployments to maintain this number of pods.
Kubernetes Architecture Model
K8s is based on a master-slave architecture model. A Kubernetes master node is a unit that controls workloads across the system. The components of a master node include Etcd storage, a controller manager, an API server, and a scheduler.Â
Worker or slave nodes receive communications from the master node. The master node assigns resources to containers according to the schedule. The responsibilities of master nodes range from handling API requests, to scheduling and running pods in worker nodes. Master nodes also perform monitoring and networking.
What Is Etcd?
Etcd is a key-value data store accessible by all the nodes in a cluster. Etcd stores the configuration data of the cluster, representing the actual state of the cluster. You can deploy etcd instances as pods on the master nodes or you can deploy it as an external cluster. This adds a extra layer of security. There are a number of tutorials available about how to set up the etcd kubernetes cluster.Â
Kubernetes is distributed, running in several machines at the same time. Therefore, its database requires to be distributed too. Etcd functions as k8sâ€™ database. Before setting up an etcd Kubernetes cluster, you should ensure that no resource starvation occurs since this can lead to timeout and an unstable cluster.Â
You should run Etcd clusters on dedicated machines to ensure the stability of k8s clusters. To ensure high availability you should run Etcd as a multi-node cluster. Since maintaining consensus is important in the k8s cluster, running a five-member cluster can be helpful to avoid consensus failure.Â
Etcd requires advanced hardware configuration. You can consult the resource requirement documentation for more information.
How Kubernetes Uses Etcd
To understand how k8s uses Etcd it is important to understand the difference between the actual state and the desired state in k8s.Â
In k8s, you use API objects to describe your clusterâ€™s desired state. Then, the k8s control plane monitors the actual state of the system, making the necessary changes to reconcile the actual and the desired states.Â
Etcd stores the configuration of the k8s cluster, including the actual and the desired state. Any change is logged and updated in etcd. Therefore, Kubernetes uses Etcd like other applications use databases, for storing configuration data, state and metadata.
How Companies Leverage Kubernetes
Many global companies chose k8s to manage their container workloads. K8s helps companies manage surges in workloads, ensuring high availability of content, among other benefits. Some examples include:
- Pinterestâ€”the social networking platform uses thousands of microservices, with a distributed set of tools. When the company wanted to streamline production, it looked for a container orchestration platform like Kubernetes. Pinterest reported increased efficiency after deploying Kubernetes.Â
- Pokemon Goâ€”when the online game was released, the company expected reasonable traffic. However, the game went viral and the network received a surge in traffic of 50 times more than expected. Pokemon Go could adapt quickly to the sudden demand thanks to k8sâ€™ scalability.
It can take some time to learn how to truly leverage K8Sâ€™ capabilities and architecture. This beginnerâ€™s guide should give you a solid start. For an in-depth explanation, go to the official Kubernetes documentation.