Kubernetes Tutorial for Beginners
Kubernetes or K8s is a container orchestration technology.
With Docker we can run a single instance of application with “docker run” command like “docker run script1” When load increases, we introduce multiple instances of docker container by running “docker run” command multiple times. If any of the instance fails, you have to run another instance as replacement. If the host where docker instances are running crashes we can neither access to host nor the containers hosted on it. So, infrastructure performance monitoring is required be it an engineer or via automated scripts. In case of a large set up with 100s of containers, even personal monitoring is not an ideal solution.
Container Orchestration is a solution to such upscaling issues. It consists of a set of tools and scripts that can help host containers in a production environment. It contains multiple docker hosts.
A useful command for this: docker service create –replicas=100 nodejs
Container Orchestration solution available in markets:
- Docker Swarm
It consists of multiple nodes and easy to scale up to as many nodes as required with a simple command: kubectl run – -replicas=1000 servers
If one node fails, it is still accessible via another
It is another node monitors the performance of all other nodes. It is responsible for the orchestration of the containers on these worker nodes
API Server – It is the front end for Kubernetes services. Command Line interfaces, Management devices, users, all communicate with the API Server to interact with the Kubernetes cluster.
Scheduler– It distributes workload between the containers across multiple nodes
Controller– Controllers monitor and notify when nodes, endpoint or containers goes down. It makes decision to bring up new containers in such cases
Container Runtime– It is the software that is used to run container. For example, docker
Kubelet– It is the agent that runs on each node in the cluster. It make sure that containers are running on nodes
etcd- It is a distributed key value store to store data for Kubernetes to manage the cluster. It puts locks between the clusters to avoid conflict for master. It stores all info of all nodes of the clusters.
Kubectl utility– It is used on CLI to deploy and manage applications on Kubernetes cluster. Number of commands available for kubectl.
- kubectl run applicaiton1 – to run app on Kubernetes
- kubectl get nodes – to list all nodes
- kubectl cluster-info – shows cluster info.