<p>I'm trying to dynamically increase the maxPods of a k8s node.  Currently its set to 30 and I want to increase it to 50. I'm following these instructions: <a href="https://kubernetes.io/docs/tasks/administer-cluster/reconfigure-kubelet/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/administer-cluster/reconfigure-kubelet/</a></p>
<p>On the node I added the <code>--dynamic-config-dir</code> flag and restarted <code>kubelet</code></p>
<p>I then added a configmap with maxPods set to 50 and added a configSource section to the node:</p>
<pre class="lang-sh prettyprint-override"><code>configSource:
    configMap:
        name: my-node-name
        namespace: kube-system
        kubeletConfigKey: kubelet
</code></pre>
<p>And I can verify the configmap has been applied via:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl get no ${NODE_NAME} -o json | jq '.status.config'
{
  &quot;active&quot;: {
    &quot;configMap&quot;: {
      &quot;kubeletConfigKey&quot;: &quot;kubelet&quot;,
      &quot;name&quot;: &quot;my-node-config-c87h9fm782&quot;,
      &quot;namespace&quot;: &quot;kube-system&quot;,
      &quot;resourceVersion&quot;: &quot;54483288&quot;,
      &quot;uid&quot;: &quot;144bd26f-d290-11ea-bb9d-5e7d8d22eed0&quot;
    }
  },
  &quot;assigned&quot;: {
    &quot;configMap&quot;: {
      &quot;kubeletConfigKey&quot;: &quot;kubelet&quot;,
      &quot;name&quot;: &quot;my-node-config-c87h9fm782&quot;,
      &quot;namespace&quot;: &quot;kube-system&quot;,
      &quot;resourceVersion&quot;: &quot;54483288&quot;,
      &quot;uid&quot;: &quot;144bd26f-d290-11ea-bb9d-5e7d8d22eed0&quot;
    }
  },
  &quot;lastKnownGood&quot;: {
    &quot;configMap&quot;: {
      &quot;kubeletConfigKey&quot;: &quot;kubelet&quot;,
      &quot;name&quot;: &quot;my-node-config-c87h9fm782&quot;,
      &quot;namespace&quot;: &quot;kube-system&quot;,
      &quot;resourceVersion&quot;: &quot;54483288&quot;,
      &quot;uid&quot;: &quot;144bd26f-d290-11ea-bb9d-5e7d8d22eed0&quot;
    }
  }
}
</code></pre>
<p>But the node is still only running 30 pods and any attempt to deploy another pod fails with the pod in the Pending state.</p>
<p>I pulled down the configmap and I verified maxPods is set to 50.</p>
<p>What am I missing? Any help would be greatly appreciate</p>
<p>Thanks,</p>
<p>Jerry</p>

<p><strong>Default Max POD Value per node is 110</strong></p>
<pre><code>ubuntu@k8s-master-1:~$ kubectl describe nodes k8s-worker-1  | grep -i &quot;Capacity\|Allocatable&quot; -A 6
Capacity:
  cpu:                2
  ephemeral-storage:  12131484Ki
  hugepages-1Gi:      0
  hugepages-2Mi:      0
  memory:             4046184Ki
  pods:               110
Allocatable:
  cpu:                2
  ephemeral-storage:  11180375636
  hugepages-1Gi:      0
  hugepages-2Mi:      0
  memory:             3943784Ki
  pods:               110
</code></pre>
<p><strong>Find config file path for kubelet on worker node</strong></p>
<pre><code>ubuntu@k8s-worker-1:~$ ps -ef | grep -i kubelet
ubuntu    5077  5005  0 20:07 pts/0    00:00:00 grep --color=auto -i kubelet
root     23930     1  1 06:42 ?        00:15:18 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --cgroup-driver=systemd --network-plugin=cni --pod-infra-container-image=k8s.gcr.io/pause:3.2
</code></pre>
<p><strong>Update/Add maxPods field on <code>/var/lib/kubelet/config.yaml</code> as needed and restart kubelet on worker node</strong></p>
<pre><code>ubuntu@k8s-worker-1:~$ sudo cat /var/lib/kubelet/config.yaml
apiVersion: kubelet.config.k8s.io/v1beta1
authentication:
  anonymous:
    enabled: false
  webhook:
    cacheTTL: 0s
    enabled: true
  x509:
    clientCAFile: /etc/kubernetes/pki/ca.crt
authorization:
  mode: Webhook
  webhook:
    cacheAuthorizedTTL: 0s
    cacheUnauthorizedTTL: 0s
clusterDNS:
- 10.96.0.10
clusterDomain: cluster.local
cpuManagerReconcilePeriod: 0s
evictionPressureTransitionPeriod: 0s
fileCheckFrequency: 0s
healthzBindAddress: 127.0.0.1
healthzPort: 10248
httpCheckFrequency: 0s
imageMinimumGCAge: 0s
kind: KubeletConfiguration
nodeStatusReportFrequency: 0s
nodeStatusUpdateFrequency: 0s
rotateCertificates: true
runtimeRequestTimeout: 0s
staticPodPath: /etc/kubernetes/manifests
streamingConnectionIdleTimeout: 0s
syncFrequency: 0s
volumeStatsAggPeriod: 0s
maxPods: 500
</code></pre>
<p><strong>Verify pods value should be now changed after kubelet is restarted</strong>.</p>
<pre><code>ubuntu@k8s-master-1:~$ kubectl describe nodes k8s-worker-1  | grep -i &quot;Capacity\|Allocatable&quot; -A 6
Capacity:
  cpu:                2
  ephemeral-storage:  12131484Ki
  hugepages-1Gi:      0
  hugepages-2Mi:      0
  memory:             4046184Ki
  pods:               500
Allocatable:
  cpu:                2
  ephemeral-storage:  12131484Ki
  hugepages-1Gi:      0
  hugepages-2Mi:      0
  memory:             3943784Ki
  pods:               500
</code></pre>
