<p>My goal to override the default Kubelet configuration in the running cluster</p>

<pre><code>"imageGCHighThresholdPercent": 85,
"imageGCLowThresholdPercent": 80,
</code></pre>

<p>to</p>

<pre><code> "imageGCHighThresholdPercent": 60,
 "imageGCLowThresholdPercent": 40,
</code></pre>

<p>The possible option is to apply the node patch for each node. </p>

<p>I'm using the following command to get the kubelet config via kubeclt proxy </p>

<pre><code>curl -sSL "http://localhost:8001/api/v1/nodes/ip-172-31-20-135.eu-west-1.compute.internal/proxy/configz" | python3 -m json.tool
</code></pre>

<p>The output is </p>

<pre><code>{
  "kubeletconfig": {

     ....

    "imageGCHighThresholdPercent": 85,
    "imageGCLowThresholdPercent": 80,

     .....
    }
}
</code></pre>

<p>here is the command I'm using to update these two values</p>

<pre><code>kubectl patch node ip-172-31-20-135.eu-west-1.compute.internal -p '{"kubeletconfig":{"imageGCHighThresholdPercent":60,"imageGCLowThresholdPercent":40}}'
</code></pre>

<p>Unfortunately the kubeclt returns me </p>

<p><strong>node/ip-172-31-20-135.eu-west-1.compute.internal patched (no change)</strong> </p>

<p>As a result the change has no effect.</p>

<p>Any thought what I'm doing wrong. </p>

<p>Thanks</p>

Denis Voloshin
<p>Patching node object is not woking because those configurations are not part of node object.</p>

<p>The way to achieve this would be by updating the kubelet config file in the kubernetes nodes and restarting kubelet process. <code>systemctl status kubelet</code> should tell if kubelet was started with a config file and the location of the file.</p>

<pre><code>root@kind-control-plane:/var/lib/kubelet# systemctl status kubelet
  kubelet.service - kubelet: The Kubernetes Node Agent
   Loaded: loaded (/kind/systemd/kubelet.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/kubelet.service.d
           └─10-kubeadm.conf
   Active: active (running) since Tue 2020-04-14 08:43:14 UTC; 2 days ago
     Docs: http://kubernetes.io/docs/
 Main PID: 639 (kubelet)
    Tasks: 20 (limit: 2346)
   Memory: 59.6M
   CGroup: /docker/f01f57e1ef7aa7a1a8197e0e79be15415c580da33a7d048512e22418a88e0317/system.slice/kubelet.service
           └─639 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --container-runtime=remote --c
ontainer-runtime-endpoint=/run/containerd/containerd.sock --fail-swap-on=false --node-ip=172.17.0.2 --fail-swap-on=false
</code></pre>

<p>As it can seen above in a cluster setup by kubeadm kubelet was started with a config file located at <code>/var/lib/kubelet/config.yaml</code></p>

<p>Edit the configfile to add </p>

<pre><code>ImageGCHighThresholdPercent: 60
ImageGCHighThresholdPercent: 40
</code></pre>

<p>Restart kubelet using <code>systemctl restart kubelet.service</code></p>

<p>In case the cluster was not started with a kubelet config file then create a new <a href="https://pkg.go.dev/k8s.io/kubelet/config/v1beta1?tab=doc#KubeletConfiguration" rel="nofollow noreferrer">config file</a> and pass the config file while starting kubelet.</p>
