summaryrefslogtreecommitdiffstats
path: root/health/guides/cgroups/k8s_cgroup_ram_in_use.md
blob: aec443b78bbd1b7d3b593ef7525c3be94862fb7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
### Understand the alert

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.

### Troubleshoot the alert

1. 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
   ```

2. 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
   ```

3. 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>
   ```

4. 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.

5. 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.

### Useful resources

1. [Kubernetes best practices: Organizing with Namespaces](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/)
2. [Managing Resources for Containers](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/)
3. [Configure Default Memory Requests and Limits](https://kubernetes.io/docs/tasks/administer-cluster/memory-default-namespace/)