Skip to content

Commit 7d24417

Browse files
authored
Merge pull request #17510 from hakman/maxContainerRestartPeriod
kubelet: Wait less for control-plane pods to restart
2 parents 04f8c4d + 4b751e8 commit 7d24417

File tree

12 files changed

+61
-2
lines changed

12 files changed

+61
-2
lines changed

k8s/crds/kops.k8s.io_clusters.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4218,6 +4218,12 @@ spec:
42184218
description: CpuManagerPolicy allows for changing the default
42194219
policy of None to static
42204220
type: string
4221+
crashLoopBackOffMaxContainerRestartPeriod:
4222+
description: CrashLoopBackOffMaxContainerRestartPeriod is the
4223+
maximum duration the backoff delay can accrue to for container
4224+
restarts, minimum 1 second, maximum 300 seconds. If not set,
4225+
defaults to the internal crashloopbackoff maximum (300s).
4226+
type: string
42214227
dockerDisableSharedPID:
42224228
description: DockerDisableSharedPID was removed.
42234229
type: boolean
@@ -4681,6 +4687,12 @@ spec:
46814687
description: CpuManagerPolicy allows for changing the default
46824688
policy of None to static
46834689
type: string
4690+
crashLoopBackOffMaxContainerRestartPeriod:
4691+
description: CrashLoopBackOffMaxContainerRestartPeriod is the
4692+
maximum duration the backoff delay can accrue to for container
4693+
restarts, minimum 1 second, maximum 300 seconds. If not set,
4694+
defaults to the internal crashloopbackoff maximum (300s).
4695+
type: string
46844696
dockerDisableSharedPID:
46854697
description: DockerDisableSharedPID was removed.
46864698
type: boolean

k8s/crds/kops.k8s.io_instancegroups.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,12 @@ spec:
524524
description: CpuManagerPolicy allows for changing the default
525525
policy of None to static
526526
type: string
527+
crashLoopBackOffMaxContainerRestartPeriod:
528+
description: CrashLoopBackOffMaxContainerRestartPeriod is the
529+
maximum duration the backoff delay can accrue to for container
530+
restarts, minimum 1 second, maximum 300 seconds. If not set,
531+
defaults to the internal crashloopbackoff maximum (300s).
532+
type: string
527533
dockerDisableSharedPID:
528534
description: DockerDisableSharedPID was removed.
529535
type: boolean

nodeup/pkg/model/kubelet.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
awsconfig "github.com/aws/aws-sdk-go-v2/config"
3232
"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
3333
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
34-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
34+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3535
"k8s.io/apimachinery/pkg/runtime"
3636
"k8s.io/apimachinery/pkg/runtime/serializer"
3737

@@ -243,6 +243,9 @@ func buildKubeletComponentConfig(kubeletConfig *kops.KubeletConfigSpec, provider
243243
if providerID != "" {
244244
componentConfig.ProviderID = providerID
245245
}
246+
if kubeletConfig.CrashLoopBackOffMaxContainerRestartPeriod != nil {
247+
componentConfig.CrashLoopBackOff.MaxContainerRestartPeriod = kubeletConfig.CrashLoopBackOffMaxContainerRestartPeriod
248+
}
246249
if kubeletConfig.ShutdownGracePeriod != nil {
247250
componentConfig.ShutdownGracePeriod = *kubeletConfig.ShutdownGracePeriod
248251
}
@@ -495,7 +498,7 @@ func (b *KubeletBuilder) addECRCredentialProvider(c *fi.NodeupModelBuilderContex
495498
APIVersion: "credentialprovider.kubelet.k8s.io/v1",
496499
Name: "ecr-credential-provider",
497500
MatchImages: registryList,
498-
DefaultCacheDuration: &v1.Duration{Duration: cacheDuration},
501+
DefaultCacheDuration: &metav1.Duration{Duration: cacheDuration},
499502
Args: []string{"get-credentials"},
500503
Env: []kubeletv1.ExecEnvVar{
501504
{
@@ -688,6 +691,11 @@ func (b *KubeletBuilder) buildKubeletConfigSpec(ctx context.Context) (*kops.Kube
688691

689692
c.ClientCAFile = filepath.Join(b.PathSrvKubernetes(), "ca.crt")
690693

694+
// Wait less for pods to restart, especially during the bootstrap sequence
695+
if b.IsKubernetesGTE("1.35") && b.IsMaster {
696+
c.CrashLoopBackOffMaxContainerRestartPeriod = &metav1.Duration{Duration: time.Minute}
697+
}
698+
691699
// Respect any MaxPods value the user sets explicitly.
692700
if (b.NodeupConfig.Networking.AmazonVPC != nil || (b.NodeupConfig.Networking.Cilium != nil && b.NodeupConfig.Networking.Cilium.IPAM == kops.CiliumIpamEni)) && c.MaxPods == nil {
693701
config, err := awsconfig.LoadDefaultConfig(ctx)

pkg/apis/kops/componentconfig.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ type KubeletConfigSpec struct {
250250
// MemorySwapBehavior defines how swap is used by container workloads.
251251
// Supported values: LimitedSwap, "UnlimitedSwap.
252252
MemorySwapBehavior string `json:"memorySwapBehavior,omitempty"`
253+
// CrashLoopBackOffMaxContainerRestartPeriod is the maximum duration the backoff delay can accrue to for container restarts, minimum 1 second, maximum 300 seconds. If not set, defaults to the internal crashloopbackoff maximum (300s).
254+
CrashLoopBackOffMaxContainerRestartPeriod *metav1.Duration `json:"crashLoopBackOffMaxContainerRestartPeriod,omitempty"`
253255
}
254256

255257
// KubeProxyConfig defines the configuration for a proxy

pkg/apis/kops/v1alpha2/componentconfig.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ type KubeletConfigSpec struct {
250250
// MemorySwapBehavior defines how swap is used by container workloads.
251251
// Supported values: LimitedSwap, "UnlimitedSwap.
252252
MemorySwapBehavior string `json:"memorySwapBehavior,omitempty"`
253+
// CrashLoopBackOffMaxContainerRestartPeriod is the maximum duration the backoff delay can accrue to for container restarts, minimum 1 second, maximum 300 seconds. If not set, defaults to the internal crashloopbackoff maximum (300s).
254+
CrashLoopBackOffMaxContainerRestartPeriod *metav1.Duration `json:"crashLoopBackOffMaxContainerRestartPeriod,omitempty"`
253255
}
254256

255257
// KubeProxyConfig defines the configuration for a proxy

pkg/apis/kops/v1alpha2/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kops/v1alpha3/componentconfig.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ type KubeletConfigSpec struct {
248248
// MemorySwapBehavior defines how swap is used by container workloads.
249249
// Supported values: LimitedSwap, "UnlimitedSwap.
250250
MemorySwapBehavior string `json:"memorySwapBehavior,omitempty"`
251+
// CrashLoopBackOffMaxContainerRestartPeriod is the maximum duration the backoff delay can accrue to for container restarts, minimum 1 second, maximum 300 seconds. If not set, defaults to the internal crashloopbackoff maximum (300s).
252+
CrashLoopBackOffMaxContainerRestartPeriod *metav1.Duration `json:"crashLoopBackOffMaxContainerRestartPeriod,omitempty"`
251253
}
252254

253255
// KubeProxyConfig defines the configuration for a proxy

pkg/apis/kops/v1alpha3/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kops/v1alpha3/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)