Logging, Monitor and Debugging in Kubernetes - Sandeep-K-Khandelwal/CKAD GitHub Wiki
Logging
Use the following command to get the live logs from a Pod - kubectl logs -f <podname>
The above command works only if the pod contains only one container
If the pod has more than one container then we must specify the container name while getting the log - kubectl logs -f <pod_name> <container_name>
Monitor and Debugging
I’d like to know Node level metrics such as the number of nodes in the cluster, how many of them are healthy as well as performance metrics such as CPU. Memory, network and disk utilization.
As well as POD level metrics such as the number of PODs, and performance metrics of each POD such the CPU and Memory consumption. So we need a solution that will monitor these metrics, store them and provide analytics around this data.
The metrics server retrieves metrics from each of the kubernetes nodes and pods, aggregates them and stores them in memory. Note that the metrics server is only an in-memory monitoring solution and does not store the metrics on the disk, and as a result you cannot see historical performance data.
Once the metrics server is setup use the following command to capture the resource information: