Configuring KubeletConfig for podsPerCore and maxPods

I found a useful KubeletConfig.

In Kubernetes, the podsPerCore parameter, when used in node configuration, specifies the maximum number of pods that can run on a node based on the number of its CPU cores. The default value for podsPerCore is 0, which essentially disables this limit, meaning there’s no constraint imposed based on the number of cores.

You can check your current settings using:

$ oc debug node/worker-1
sh-4.4# chroot /host
sh-4.4# cat /etc/kubernetes/kubelet.conf | grep maxPods
  "maxPods": 250,
sh-4.4# cat /etc/kubernetes/kubelet.conf | grep podsPerCore
  "podsPerCore": 10,

In you environment substitute worker-1 for a node name of a ndoe that belongs to your MachineConfigPool.

You can change your configuration using:

apiVersion: machineconfiguration.openshift.io/v1
kind: KubeletConfig
metadata:
  name: set-max-pods-core 
spec:
  machineConfigPoolSelector:
    matchLabels:
      pools.operator.machineconfiguration.openshift.io/worker: "" 
  kubeletConfig:
    podsPerCore: 10 
    maxPods: 250 

Reference

  1. podsPerCore – https://docs.redhat.com/en/documentation/openshift_container_platform/4.14/html/postinstallation_configuration/post-install-node-tasks
  2. defaults – https://access.redhat.com/solutions/6998814