From the last post on containers, we know what are containers & its benefits. Just to recap, here are the points below :
- Uses OS Level virtualization
- Isolated from each of them and from the host
- Increased ease and efficiency of container image creation compared to VM image use.
- Provides reliable and frequent container image build and deployment with quick and easy rollbacks
- Create application container images at build/release time rather than deployment time, thereby decoupling applications from infrastructure.
- Raises the level of abstraction from running an OS on virtual hardware to run an application on an OS using logical resources.
Now we know what containers are and why do we need them, also note deploying lots of containers does require sophisticated management, though. Luckily, there is a solution that simplifies this, it is Kubernetes. let us see what it has to offer.
Kubernetes has been built based upon 15 years of experience of running production workloads at Google, combined with best-of-breed ideas and practices from the community. It groups containers that make up an application into logical units for easy management and discovery.
Kubernetes is a production-ready, open-source platform designed with Google’s accumulated experience in container orchestration, combined with best-of-breed ideas from the community. It is designed to automate deploying, scaling, and operating application containers.
Kubernetes coordinates a highly available cluster of computers that are connected to work as a single unit. The abstractions in Kubernetes allow you to deploy containerized applications to a cluster without tying them specifically to individual machines.
In short, Kubernetes is
- Portable: public, private, hybrid, multi-cloud
- Extensible: modular, pluggable, hookable, composable
- Self-healing: auto-placement, auto-restart, auto-replication, auto-scaling
Kubernetes Architecture – System and Abstractions
The following would help you to learn about the different parts of the Kubernetes system and the abstractions. Kubernetes automates the entire distribution and scheduling of application containers across a cluster in a more efficient way.
- To interact with Kubernetes, there is an API layer (Kubernetes API ) exposed same can be interacted with using a command-line interface via
- Any Kubernetes cluster (example below) would have two types of resources:
- Master which controls the cluster
- Node is the workers’ nodes that run applications
- The Master coordinates all activities in your cluster, such as scheduling applications, maintaining applications’ desired state, scaling applications, and rolling out new updates.
- Each Node can be a VM or a physical computer that serves as a worker machine in a cluster. Each node has a Kubelet, which is an agent for managing the node and communicating with the Kubernetes master. The node should also have tools for handling container operations, such as Docker or rkt.
- When any applications need to be deployed on Kubernetes, the master issues a command to start the application containers. The master schedules the containers to run on the cluster’s nodes.
- The nodes communicate with the master using the Kubernetes API, which the master exposes. End-users can also use the Kubernetes API directly to interact with the cluster.
Master components provide the cluster’s control plane. Kubernetes Control Plane consists of a collection of below processes on your cluster:
- Kubernetes Master is a collection of three processes kube-apiserver, kube-controller-manager, and kube-scheduler.
- kube-apiserver exposes the Kubernetes API. It is the front-end of the Kubernetes control plane.
- kube-controller-manager runs controllers, which are designed to handle routine tasks in the cluster.
- kube-scheduler is to keep watch for newly created pods that have no node assigned and selects a node for them to run on.
- Each individual non-master node on the cluster runs two processes:
- kubelet – this is to communicate with Kubernetes Master
- kube-proxy – this is nothing but network proxy (Kubernetes networking services) on each node.
- Container runtime such as Docker.
Master components make global decisions about the cluster (like for example, scheduling applications), and detecting and responding to cluster events.
Apart from the above, there are other objects to represent the state of the system, some of the basic Kubernetes objects include:
Kubernetes cluster can run on various platforms: from your laptop to VMs on a cloud provider, to a rack of bare metal servers. To try with local Kubernetes setup, you can use Minikube which is a lightweight Kubernetes implementation that creates a VM on your local machine and deploys a simple cluster containing only one node. Minikube is available for Linux, macOS, and Windows systems. The Minikube CLI provides basic bootstrapping operations for working with your cluster, including start, stop, status, and delete.
There is also a web-based Kubernetes Dashboard for your clusters. It allows users to manage and troubleshoot applications running in the cluster, as well as the cluster itself.
In the next post of the Kubernetes tutorial, we can learn how to use Minikube CLI to create/deploy apps to the Kubernetes cluster. Stay tuned.
Like this post? Don’t forget to share it!
Additional Resources :
- Take a free course on Building Scalable Java Microservices with Spring Boot and Spring Cloud
- Kubernetes tutorial – Create simple cluster & Deploy app
- Kubernetes tutorial – Scale & perform updates to your app
- Kubernetes tutorial – Create deployments using YAML file
- Official documentation as a reference to understand any command.
- Set Up MicroK8s to Run an Edge Application
- If you’re looking for Kubernetes examples, here it is GitHub