How to change the max-pods limit in an RKE2 or K3s cluster
Article Number: 000021093
Environment
- Rancher v2.6+
- A standalone or Rancher-provisioned RKE2/K3s cluster
Situation
The existing RKE2/K3s cluster's pod limit has been exhausted and needs to be increased.
Resolution
When looking to change the max-pods for a node, make sure to take into account the number of IP addresses available from each nodes node CIDR, as this will limit the number of pods that can be scheduled on a node. Changing the node CIDR config in an existing cluster is not supported. If you need to increase the
node-cidr-mask-size(and/orcluster_cidr) you will need to provision a fresh cluster, per the article How to setup your network CIDR for a large cluster.
Standalone RKE2/K3s clusters
In a standalone cluster, the configuration needs to be applied per node:
- Configure the kubelet's
max-podsargument in the RKE2 or K3s configuration file (/etc/rancher/rke2/config.yamlor/etc/rancher/k3s/config.yaml) per the following example:
kubelet-arg:
- "max-pods=200"
- On RKE2 server nodes:
systemctl restart rke2-server - On RKE2 worker nodes:
systemctl restart rke2-agent - On K3s server nodes:
systemctl restart k3s - On K3s worker nodes:
systemctl restart k3s-agent
Rancher-provisioned RKE2/K3s clusters
In a Rancher-provisioned cluster, the configuration can be managed at the cluster-level within Rancher:
- Navigate to Cluster Management within the Rancher UI and click Edit Config for the relevant RKE2/K3s cluster
- Under Cluster Configuration click Advanced
- Under For all machines, use the Kubelet args: in the section Additional Kubelet Args click Add Argument
- Enter the desired
max-podsvalue, for examplemax-pods=200 - Click Save to apply the change