1. What is Kubernetes
Kubernetes (commonly stylized as k8s) is an open-source system for automating deployment, scaling, and management of containerized applications.
K8s : technology developed in Google lab in 2005 to manage containerized applications in different kind of environments such as physical, virtual, and cloud infrastructure.
This article is prepared for anyone who want to understand the containerized infrastructure and deployment of application on containers using k8s. and will help you to understand the concepts of container management using this technology.
To understand Kubernetes you need to get an idea of how the Docker works and how to create Docker images, you must also understand the basic notions on networks and configuration management.
4. Why Kubernetes is popular
Let’s take a look at why Kubernetes is so useful by going back in time
Traditional deployment : companies were deploy applications on physical servers very early. There was no way to set resource limits for applications on a physical server, which caused resource allocation issues. if multiple applications are running on a physical server, an application might use most of the resources, resulting in underperformance of other applications
Virtualized Deployment : virtualization allows us to run multiple virtual machines (VMs) on a single physical server. Virtualization isolates applications between virtual machines and provides a level of security because information from one application is not freely accessible by another application.
Container deployment : Containers are similar to VMs, but they have relaxed isolation properties to share the Operating System (OS) among the applications. Therefore, containers are considered lightweight. Similar to a VM, a container has its own filesystem, CPU, memory, process space, and more.
So why you need Kubernetes and what can it do?
Containers are a good way to bundle and run our applications. In a production environment, we need to manage the containers that run the applications and ensure that there is no downtime (for example, if a container goes down, another container needs to start
5. Features of Kubernetes
Below among the benefits and the important features of Kubernetes.
- Containerized infrastructure
- Multi-container application management on a scale : Auto-scalable infrastructure
- Higher density of resource utilization
- Deployment automation
- Service discovery and load balancing
- Storage orchestration
- Automated rollouts and rollbacks
- Secret and configuration management
6. Kubernetes – Architecture
Kubernetes follows a client-server architecture, it’s possible to have a multi-master setup, by default there is a single master server which acts as a controlling all nodes.
- The master server : consists of various components including a kube-apiserver, an etcd, kube-controller-manager, kube-scheduler, and DNS server for Kubernetes services.
- Node components : include kubelet and kube-proxy on top of Docker.
7. Kubernetes Concept
To use of Kubernetes requires understanding the different abstractions it uses to represent the state of the system, such as services, pods, volumes, namespaces, and deployments.
- Pod : generally refers to one or more containers that should be controlled as a single application.
- Service : A service represents a logical set of pods and acts as a gateway, service allows the client to access applications hosted in pods
- Volume : similar to a container volume in Docker, but a Kubernetes volume applies to a whole pod and is mounted on all containers in the pod.
- Namespace : Kubernetes supports multiple virtual clusters backed by the same physical cluster. These virtual clusters are called namespaces.
- Deployment : A Deployment provides declarative updates for Pods and ReplicaSets in a yaml file.
8. Kubernetes – Master Components
Below are the main components master node in kubernetes cluster :
- etcd cluster : a simple, distributed key value storage which is used to store the Kubernetes cluster data (such as number of pods, their state, namespace, etc)
- kube-apiserver : Kubernetes API server is the central management entity that receives all REST requests for modifications (to pods, services, replication sets/controllers and others) The API server is a component of the Kubernetes control plane that exposes the Kubernetes API. Also, kube-apiserver is the only component that communicates with the etcd cluster.
- kube-controller-manager : runs all controllers that handle all tasks in the cluster, bellow a list of containers in Kubernetes process :
These controllers include:
Node Controller : Responsible for noticing and responding when nodes go down.
Replication Controller : Responsible for maintaining the correct number of pods for every replication controller object in the system.
Endpoints Controller : Populates the Endpoints object (that is, joins Services & Pods).
Service Account & Token Controllers : Create default accounts and API access tokens for new namespaces
- cloud-controller-manager : is responsible to runs controllers that interact with the underlying cloud providers, (fo example, check if a node was terminated or set up routes, load balancers or volumes in the cloud infrastructure.
- kube-scheduler : In Kubernetes, scheduling refers to making sure that Pods are matched to Nodes so that Kubelet can run them.
9. Kubernetes – Node Components
Below are the main components found on a worker node in kubernetes cluster:
- kubelet : The kubelet is the primary “node agent” that runs on each node, regularly taking in new or modified pod specifications (primarily through the kube-apiserver)
- kube-proxy : a proxy service that runs on each worker node to deal with individual host subnetting and expose services to the external world. kube-proxy is a network proxy that runs on each node in kubernetes cluster, it maintains network rules on nodes. These network rules allow network communication to different Pods from network sessions inside or outside of k8s cluster.