Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K8s-9602 Kubelet image GC settings configurable #55

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
phiphi282 marked this conversation as resolved.
Show resolved Hide resolved
} 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
Loading