Monitoring cluster components of Kubernetes (K8s)
There are various type of monitoring we can perform at the cluster, node level and pod level. At cluster level we can monitor like number nodes running, how many are healthy, performance status, network usage etc.
At the POD level we can monitor disk and cpu, memory utilisation, Performance metrics of each POD about its resources.
To utilise the experience of monitoring on kubernetes cluster we can use “Metrics server”
We can have 1 metrics server per cluster. It's retrieves the information about Nodes , PODS aggregate them and store them into memory.
Matrics server is IN-MEMORY solution where the data or information which it fatch from nodes and pod will be in memory and does not store it in disk.
As Metrics server is "IN-MEMORY" where it's not possible to retrieve the historical data about the kubernetes resources. To get the historical data its require to use advance tool or proprietors monitoring tool supporting kubernetes
So how does the Metrics Server get data??
As you know each nodes having an agent called KUBLET which is responsible to get information from API server for running and assigning pods.
KUBELET is also running sub component which called cAdvisor or container advisor.
KUBELET is also running sub component which called cAdvisor or container advisor.
cAdvisor is responsible for exposing performance metrics from POD and exposing it to API server then it get the data available to Metrics server.
For enabling feature use below:
For minikube : Use below code to enable metrics-server.
>minikube addons enable metrics-server
>minikube addons enable metrics-server
For all other environment Clone the metrics server from GitHub repository.
>git clone https://github.comkubernetes-incubator/metrics-server.git
>git clone https://github.comkubernetes-incubator/metrics-server.git
- Kubectl create -f deploy/1.8+/ ( run this command after cloning. It may take time to install and configure MATRICS server so be patience.
- Kubectl top nodes ( to view the metrics about nodes)
- Kubectl top pod ( to view the metrics about PODS)
Application logging
For watching logs of containers into the POD we can use command “kubectl log -f (pod name) . This will give you the list of events which fetch all the containers events.
What if we want to fetch event of specific containers in a pod. For gaining this objective we need to add one parameter into the pod definition file under spec section.
- Name : image-processorimage: some-image-processor
Kubectl log -f (pod name) (container name)
Happy learning..... :)
Comments
Post a Comment