Kubernetes

Kubernetes

What is Kubernetes?

Kubernetes is a Google-developed open-source container orchestration system for automating software deployment, scaling, and management. That is, Kubernetes enables us to manage applications composed of hundreds or thousands of containers in a variety of environments such as physical machines, virtual machines, or cloud environments.

It is well-known for its self-healing mechanism, scaling applications, and general management of the application to ensure that it reaches the required state. The most extensively used services for container orchestration or rather cloud offering, in general, are Amazon's Elastic Kubernetes Service, Google's Kubernetes Engine, and Azure's Kubernetes Service.

Kubernetes Architecture

A Kubernetes cluster consists of at least one master node and a handful of worker nodes, each of which has a kubelet process running on it.

Kubelet is a Kubernetes process that allows the cluster to interact with one another and perform actions on the worker nodes such as launching application processes. Each worker node has docker containers for various apps deployed on it, hence the number of docker containers operating on the worker nodes varies depending on how the workload is spread. Your application runs on the worker nodes, while the master node runs numerous Kubernetes processes required to function and effectively govern the cluster.

Master Node

The control plane is split into various sections. The API-Server, etcd, controller manager, and scheduler are all components.

  1. Control Manager: The controller manager as a whole oversees the many types of controllers ( replica set, namespace, endpoint, and service controller ). Controller managers serve as control loops that monitor the condition of your k8s cluster. As it continually listens to the API server, it compares the current state, then modifies the current state as needed to advance toward the intended state.

  2. Scheduler: The scheduler's function is to listen for API server requests, such as scheduling new pods. It would then arrange pods on worker nodes based on their health and availability.

  3. API Server: It is one of the most critical processes that run on the master node. It serves as the gateway to the Kubernetes cluster. That is, it is the method via which the various Kubernetes clients will communicate, such as the UI if you are using the Kubernetes dashboard, an API if you are using scripts, and a command-line tool.

  4. etcd: etcd is a distributed database storage system that essentially stores the Kubernetes cluster's state. etcd makes advantage of key-value storage. Its data storage is extremely accessible, consistent, and persistent.

Worker Node

Worker nodes run containers and programs that are allocated to them. Worker nodes are separated into four components: Kubelet, Container runtime, Pod, and Kube proxy.

  1. Container Runtime: Container Runtime is a low-level component of a container engine that is in charge of mounting containers and collaborating with the operating system kernel to allow containerization.

  2. Kubelet: Kubelet is a Kubernetes controller that is present in all worker nodes. It serves as a bridge between the control plane and the container runtime. The kubelet builds containers in compliance with the scheduled pods by first reading the container's Podspec and then instructing the container runtime via the CRI (container runtime interface) to launch the container.

  3. Kubeproxy: Kubeproxy is in charge of allocating an IP address to a certain worker node. Updates the IP database and keeps network rules up to date.

Kubernetes Concepts

  1. Node: A Kubernetes node is a single computer that serves as an abstraction in a cluster. Instead of maintaining individual physical or virtual machines, you may use each node as a pool of CPU and RAM resources on which containerized workloads can be executed. Kubernetes distributes tasks across nodes when an application is deployed to the cluster. Workloads may be shifted across cluster nodes with ease.

  2. Pod: A Pod is Kubernetes' smallest unit that a user may customize or interact with. It functions as a container wrapper, and on each worker node, we may have several pods with numerous containers within.

  3. Service: A Kubernetes service is a logical abstraction for a cluster's deployed collection of pods (which all perform the same function). Because pods are transient, a service allows a set of pods that perform specified operations (web services, image processing, etc.) to be given a name and a unique IP address (clusterIP). It will not change as long as the service is functioning on that IP address. Policies for service access are also defined.

  4. Ingress: Kubernetes Ingress is an API object that offers routing rules to govern external users' access to Kubernetes cluster services, often through HTTPS/HTTP. With Ingress, you can quickly configure traffic routing rules without having to create a slew of Load Balancers or expose every service on the node. As a result, it is the greatest alternative for usage in production situations.

  5. Config Map: A ConfigMap is an API object used to store non-confidential data in key-value pairs. Pods can consume ConfigMaps as environment variables, command-line arguments, or as configuration files in a volume. It allows you to decouple environment-specific configuration from your container images so that your applications are easily portable.

  6. Secret: ConfigMap does not provide confidentiality or encryption. Assume that, in addition to the Database URL, the login and password are also changed. Keeping this sensitive data in a ConfigMap, however, would be unsafe, even though it is an external setting. We utilize a Kubernetes component named Secret to store this type of sensitive data. The data in Secret is kept in base64 encoded format. So it's similar to ConfigMap, except it includes info that other people won't have access to.

  7. Volumes: Container on-disk files are temporary, which causes issues for non-trivial programs operating in containers. When a container crashes, one issue is the loss of files. The container is restarted by the kubelet but in a clean condition. A second issue arises when exchanging files amongst containers operating in a Pod. Both of these issues are addressed by the Kubernetes volume abstraction. It is recommended that you be familiar with Pods.

Installation on your Computer

There are two command line tools.

  1. Minikube

  2. Kubectl

ย