src/health/guides/cgroups/k8s_cgroup_ram_in_use.md
This alert monitors the RAM usage in a Kubernetes cluster by calculating the ratio of the memory used by a cgroup to its memory limit. If the memory usage exceeds certain thresholds, the alert triggers and indicates that the system's memory resources are under pressure.
Check overall RAM usage in the cluster
Use the kubectl top nodes command to check the overall memory usage on the cluster nodes:
kubectl top nodes
Identify Pods with high memory usage
Use the kubectl top pods --all-namespaces command to identify Pods consuming a high amount of memory:
kubectl top pods --all-namespaces
Inspect logs for errors or misconfigurations
Check the logs of Pods consuming high memory for any issues or misconfigurations:
kubectl logs -n <namespace> <pod_name>
Inspect container resource limits
Review the resource limits defined in the Pod's yaml file, particularly the limits and requests sections. If you're not setting limits on Pods, then consider setting appropriate limits to prevent running out of resources.
Scale or optimize applications
If high memory usage is expected and justified, consider scaling the application by adding replicas or increasing the allocated resources.
If the memory usage is not justified, optimizing the application code or configurations may help reduce memory usage.