Monitoring applications on a Kubernetes cluster
A standard end-to-end monitoring solution covers infrastructure monitoring and application monitoring. In Kubernetes, Metrics Server is not only used to monitor the Kubernetes worker nodes but also Kubernetes Pods and containers.
We can test out application monitoring by deploying a new pod in the default namespace as follows:
kubectl run nginx --image=nginx
After executing the preceding command, make sure that your nginx
pod is up and running before going to the next section. To check out the status of the pod, you can use the kubectl get pod nginx
command.
Monitoring the resource usage of an application
You can use the kubectl top pod <podname>
command to check out the metrics collected for that pod, including the resource consumption of the pod:
kubectl top pod nginx
The output should look as follows, where you can see the CPU and memory usage of the pod:
NAME CPU(cores) ...