How to Modify the Metrics-Server Container Limits?
Problem
- A metrics-server container running inside the metrics-server pod is frequently restarting because it's being OOMKilled due to insufficient resources.
- Requests and Limits change applied to the
metrics-servercontainer reverts back. - How to modify the
metrics-servercontainer limits?
Environment
- Private Cloud Director Kubernetes – v2025.4 and Higher
- Self-Hosted Private Cloud Director Kubernetes - v2025.4 and Higher
- Component - Metric Server Add-on.
Procedure
The metrics-server container running inside the metric-server pod retrieves its value from the metrics-server-nanny-config config map. This config map needs to be updated to push the latest configuration.
Direct update to the requests and limits for the metrics-server container running inside the metric-server pod won't work.
Updating the requests and limits for the metrics-server-nanny container running inside the metric-server pod will work without updating the Config Map.
- Take a backup of the existing
metrics-server-nanny-configconfig map using the command given below:
$ kubectl get cm -n kube-system metrics-server-nanny-config -o yaml > metrics-server-nanny-config.yaml.bk- Edit the Config Map.
$ kubectl edit cm -n kube-system metrics-server-nanny-config- Update the below fields with the desired value and save the config map.
baseCPU: 80m # This is minimum CPU required for the container similar to pod request cpuPerNode: 1mbaseMemory: 80Mi # This is minimum Memory required for the container similar to pod requestmemoryPerNode: 2MiCPU and Memory calculations are done by the metrics-server-nanny container for the metrics-server container is based on the number of nodes running on the cluster.
CPU = baseCPU + extraCpu * max(nodes, minClusterSize)
Memory = baseMem + extraMemory * max(nodes, minClusterSize)
Here, CPU and Memory are the Limits that will be applied to the metric-server container. baseCPU, baseMem values can be retrieved from the existing metrics-server-nanny-config Config Map. However, values such as extraCpu(default is 1), extraMemory (default is 2) and minClusterSize (default is 10) can be retrieved from the metric-server cluster add-on, which are applicable only for Self-Hosted Private Cloud Director Kubernetes.
- Save the Config Map.
- Delete the
metrics-serverpod in thekube-systemnamespace and it should redeploy pod with new updated value as per updated config map.
Validation
- Validate the latest updated value in Config Map and Pod status.
$ kubectl get cm -n kube-system metrics-server-nanny-config -o yaml$ kubectl get pods -n kube-system | grep -i "metrics-server"- Latest Limits set to the
metrics-servercontainer running inside the metric-server pod. - If these steps prove insufficient, reach out to the Platform9 Support Team for additional assistance.