Up to this point we were working with some of the core Kubernetes building blocks, such as Kubernetes Pods, Kubernetes Deployments and Kubernetes ConfigMaps and Secrets.
These resources, once created, take up some of your Kubernetes platform resources, be it CPU, RAM or Disk Space. Your Kubernetes environment can very quickly spin out of control if you don’t keep an eye on these core resources that you provisioned in this environment.
Therefore, in this final chapter of the Kubernetes Building Blocks series, we’ll learn how to maintain a healthy Kubernetes environment.
Node Status & Health Check
This is probably best place to start when looking into Kubernetes cluster status, including Node’s resources, events and constraints.
More details: Kubernetes Nodes
kubectl describe nodes
CPU & RAM Usage
Knowing which Pods consume most of the CPU and RAM on your Kubernetes cluster will help you contain these resources within its limits. This is very important from a number of reasons, mainly reducing cost by freeing space for the apps that need the resources more. Also performance of you Pods is a key metric here to.
Why is my Pod running high of CPU all the time? Does it need so much RAM etc…
View Node Level CPU & RAM Allocations
kubectl get nodes --no-headers | awk '{print $1}' | xargs -I {} sh -c 'echo {}; kubectl describe node {} | grep Allocated -A 5 | grep -ve Event -ve Allocated -ve percent -ve -- ; echo'
View Pod Level CPU & RAM Allocations
kubectl top pod --all-namespaces
View Horizontal Pod Autoscaler Targets
kubectl get hpa --all-namespaces
Delete Pods
For detailed examples on Pod delete operations please refer back to the Delete section in this article: Kubernetes Pods
Delete Deployments
For detailed examples on Deployment delete or rollback operations please refer back to the Delete section in this article: Kubernetes Deployments
<< Kubernetes ConfigMaps and Secrets | Kubernetes Housekeeping