In our previous articles in series basics on Kubernetes we have talked about etcd and Kube proxy and what are their exact functions in Kubernetes. If you have not read them you can find these articles below.
In this article we are going to talk about a very important component kubelet and what are its tasks and where does it fit in the Kubernetes environment.
What is kubelet?
Kubelet is an agent or program which runs on each node. This is responsible for all the communications between the Kubernetes control plane [group of programs which control kubernetes] and the nodes where the actual workload runs. Below are the exact tasks of the kubelet.
Joining the cluster.
With help of kubelet a node can join the cluster and tell the cluster that it is available to run the workload.
Running and health check of the containers
Kubelet talks to the control plane to get the pods list that needs to run on the node and runs the pod. It also does a health check on containers and tells the status back to API server.
Reporting status of Node
Kubelet is also responsible for reporting the status of the node back to the Kubernetes to make an informed decision.
Kubelet works on pod spec which is supplied to it from api server. In pod spec, it is defined that what pod needs to be launched and what all containers need to be launched. Apart from it there is other information like health check etc. Below is a small example for pod spec.
apiVersion: v1 kind: Pod metadata: name: nginx labels: env: test spec: containers: - name: nginx image: nginx imagePullPolicy: IfNotPresent nodeSelector: disktype: ssd
If you see here the details of what image to run, when to pull the image, etc is present in this pod spec. To know all the pod spec fields you can read this. https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#podspec-v1-core
Kubelet is like a captain of nodes and everything that needs to be executed on a node has to be done through kubelet.
This was a very basic introduction to kubelet. If you like the article please share and subscribe.