This blog also summarizes the content presented on the “Is it Observable” episode: how to collect metrics in k8S, briefly explaining:
1
The core components of Kubernetes
2
The architecture of Prometheus
3
The default Prometheus exporter that will help you collect relevant metric on k8S
If you're working in the cloud-native space, there is a big chance that you're eating K8s for breakfast, lunch, and dinner.
A few years ago, the entire market was looking at the new kid on the block called Kubernetes…but at that time, nobody was betting on the current usage and popularity of the technology.
Kubernetes has become the standard technology for Cloud-native architecture.
In reality, it’s an orchestration tool that manages our workload by starting, updating, and deleting pods.
But how is Kubernetes able to do magic tricks on our environment?
Well, to answer this question, we need to look at the engine:
A master node is a central component managing the entire cluster. If you're using a Kubernetes cluster managed by one of the cloud providers, you probably won’t have access to the master node.
On the other hand, the worker nodes are the layer that will be used to deploy our pod for our workload.
Let’s have a look at the core that we find in those two types of nodes:
The scheduler is the component that is responsible for selecting the node that will be in charge of hosting our workload. The scheduler will select the node based on resource utilization, taints, quotas, …etc.
2
The Control Manager is responsible for detecting the state changes of our workload. If a pod crashes, it will try to reschedule the pod to make sure we always have the desired number of pods running in our cluster. The control manager doesn’t schedule pods by itself, it will reach out to the scheduler to delegate that task.
3
Etcd is a key-value pair storage that stores the status of our various Kubernetes components
4
The APi server is a very important layer because it allows us to deploy our workload utilizing the HTTP request or kubectl ( that is interacting with the API)
Container runtime: since Kubernetes orchestrates containers within your cluster, the node needs to have a container runtime. Most of us use the docker runtime.
2
Kubelet: Once the scheduler has identified the node to run our workload, kubelet is in charge of allocating resources and running our pods. It is also responsible for validating that our pods are ready and healthy. Kubelet will report any state changes of our pod to the control manager.
3
Kube-proxy is the component in charge of the communication between services.
All those components have specific tasks to make sure that we always have the desired number of pods in our environment. If we want to make sure that Kubernetes is running under good conditions, we will need to make sure to collect information related to:
1
The health of the nodes
2
The status of the workload
To collect metrics related to our Kubernetes cluster, we will naturally take advantage of Prometheus, which has become standard for this.
So, let’s have a look at the architecture of Prometheus.