Skip to content

Configuring imageMaximumGCAge for kubelet in Rancher managed RKE2 clusters

Article Number: 000022045

Environment

Rancher managed RKE2 clusters

Procedure

To configure the imageMaximumGCAge setting for kubelet in Rancher managed RKE2 clusters, follow these steps:

Create a config file for each node. For example: /etc/rancher/rke2/kubelet-config.yaml.  The content of the file should be similar to:

cat /etc/rancher/rke2/kubelet-config.yaml
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
imageMaximumGCAge: 12h

Ensure this file is created on each node.

Pass the config file to the kubelet:

  • Go to Cluster Management → Clusters.
  • Select the target RKE2 cluster.
  • Edit Cluster Configuration: Click ⋮ (Ellipsis Menu) → Edit Config.
  • Scroll to Advanced Options → Additional Arguments →  Additional Kubelet args
  • Point to the file created in step 1.

  • config=/etc/rancher/rke2/kubelet-config.yaml.

Note: As of Kubernetes v1.30, the imageMaximumGCAge feature is enabled by default, and the value should be a time duration (e.g., 12h45m) rather than a boolean. The feature-gates argument is deprecated and should be set via a config file. 

Additional information

https://kubernetes.io/docs/concepts/architecture/garbage-collection/#image-maximum-age-gc