Skip to content

Commit

Permalink
K8s-9602 Kubelet image GC settings configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
multi-io committed Mar 1, 2024
1 parent b332154 commit 7eb9759
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/apis/cluster/common/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
22 changes: 22 additions & 0 deletions pkg/userdata/helper/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 7eb9759

Please sign in to comment.