diff --git a/pkg/apis/cluster/common/consts.go b/pkg/apis/cluster/common/consts.go index ca58aafca..09b63e252 100644 --- a/pkg/apis/cluster/common/consts.go +++ b/pkg/apis/cluster/common/consts.go @@ -135,12 +135,14 @@ const ( ) const ( - SystemReservedKubeletConfig = "SystemReserved" - KubeReservedKubeletConfig = "KubeReserved" - EvictionHardKubeletConfig = "EvictionHard" - ContainerLogMaxSizeKubeletConfig = "ContainerLogMaxSize" - ContainerLogMaxFilesKubeletConfig = "ContainerLogMaxFiles" - MaxPodsKubeletConfig = "MaxPods" + SystemReservedKubeletConfig = "SystemReserved" + KubeReservedKubeletConfig = "KubeReserved" + EvictionHardKubeletConfig = "EvictionHard" + ContainerLogMaxSizeKubeletConfig = "ContainerLogMaxSize" + ContainerLogMaxFilesKubeletConfig = "ContainerLogMaxFiles" + MaxPodsKubeletConfig = "MaxPods" + ImageGCLowThresholdPercentKubeletConfig = "ImageGCLowThresholdPercent" + ImageGCHighThresholdPercentKubeletConfig = "ImageGCHighThresholdPercent" ) const ( diff --git a/pkg/userdata/helper/kubelet.go b/pkg/userdata/helper/kubelet.go index 926b28600..7b6beac30 100644 --- a/pkg/userdata/helper/kubelet.go +++ b/pkg/userdata/helper/kubelet.go @@ -295,6 +295,28 @@ func kubeletConfiguration(log *zap.SugaredLogger, clusterDomain string, clusterD } } + if imgGcLowThreshold, ok := kubeletConfigs[common.ImageGCLowThresholdPercentKubeletConfig]; ok { + val, err := strconv.ParseInt(imgGcLowThreshold, 10, 32) + if err != nil || val < 0 || val > 100 { + // Instead of breaking the workflow, just print a warning and skip the configuration + log.Info("Skipping invalid ImageGCLowThresholdPercent value for Kubelet configuration", "value", imgGcLowThreshold) + } else { + i32val := int32(val) + cfg.ImageGCLowThresholdPercent = &i32val + } + } + + if imgGcHighThreshold, ok := kubeletConfigs[common.ImageGCHighThresholdPercentKubeletConfig]; ok { + val, err := strconv.ParseInt(imgGcHighThreshold, 10, 32) + if err != nil || val < 0 || val > 100 { + // Instead of breaking the workflow, just print a warning and skip the configuration + log.Info("Skipping invalid ImageGCHighThresholdPercent value for Kubelet configuration", "value", imgGcHighThreshold) + } else { + i32val := int32(val) + cfg.ImageGCHighThresholdPercent = &i32val + } + } + if enabled, ok := featureGates["SeccompDefault"]; ok && enabled { cfg.SeccompDefault = ptr.To(true) }