From b5fb0e919abe9720b9040a77ffa062f6febad12e Mon Sep 17 00:00:00 2001 From: Josef Mende Date: Wed, 29 May 2024 13:49:26 +0200 Subject: [PATCH] Add machine annotation to specify MaxParallelImagePulls --- pkg/apis/cluster/common/consts.go | 4 +++- pkg/userdata/helper/kubelet.go | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/apis/cluster/common/consts.go b/pkg/apis/cluster/common/consts.go index 09b63e252..cdaf39687 100644 --- a/pkg/apis/cluster/common/consts.go +++ b/pkg/apis/cluster/common/consts.go @@ -134,6 +134,7 @@ const ( ExternalCloudProviderKubeletFlag KubeletFlags = "ExternalCloudProvider" ) +// Annotation suffixes, used with the KubeletConfig prefix, used on Machine objects to set fields of the KubeletConfig const ( SystemReservedKubeletConfig = "SystemReserved" KubeReservedKubeletConfig = "KubeReserved" @@ -143,10 +144,11 @@ const ( MaxPodsKubeletConfig = "MaxPods" ImageGCLowThresholdPercentKubeletConfig = "ImageGCLowThresholdPercent" ImageGCHighThresholdPercentKubeletConfig = "ImageGCHighThresholdPercent" + MaxParallelImagePullsKubeletConfig = "MaxParallelImagePulls" ) +// Annotation prefixes, used on Machine objects to indicate the parameters that been used to create those Machines. const ( - // Annotation prefixes, used on Machine objects to indicate the parameters that been used to create those Machines. KubeletFeatureGatesAnnotationPrefixV1 = "v1.kubelet-featuregates.machine-controller.kubermatic.io" KubeletFlagsGroupAnnotationPrefixV1 = "v1.kubelet-flags.machine-controller.kubermatic.io" KubeletConfigAnnotationPrefixV1 = "v1.kubelet-config.machine-controller.kubermatic.io" diff --git a/pkg/userdata/helper/kubelet.go b/pkg/userdata/helper/kubelet.go index 7b6beac30..86449e159 100644 --- a/pkg/userdata/helper/kubelet.go +++ b/pkg/userdata/helper/kubelet.go @@ -317,6 +317,18 @@ func kubeletConfiguration(log *zap.SugaredLogger, clusterDomain string, clusterD } } + if maxParallelImagePulls, ok := kubeletConfigs[common.MaxParallelImagePullsKubeletConfig]; ok { + val, err := strconv.ParseInt(maxParallelImagePulls, 10, 32) + if err != nil || val < 1 { + // Instead of breaking the workflow, just print a warning and skip the configuration + log.Info("Skipping invalid MaxParallelImagePulls value for Kubelet configuration", "value", maxParallelImagePulls) + } else { + i32val := int32(val) + cfg.SerializeImagePulls = ptr.To(false) + cfg.MaxParallelImagePulls = &i32val + } + } + if enabled, ok := featureGates["SeccompDefault"]; ok && enabled { cfg.SeccompDefault = ptr.To(true) }