Skip to content

Commit ecd8b8a

Browse files
committed
kubelet: Wait less for control-plane pods to restart
1 parent 3a9e01b commit ecd8b8a

12 files changed

+61
-0
lines changed

k8s/crds/kops.k8s.io_clusters.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4115,6 +4115,12 @@ spec:
41154115
description: CpuManagerPolicy allows for changing the default
41164116
policy of None to static
41174117
type: string
4118+
crashLoopBackOffMaxContainerRestartPeriod:
4119+
description: CrashLoopBackOffMaxContainerRestartPeriod is the
4120+
maximum duration the backoff delay can accrue to for container
4121+
restarts, minimum 1 second, maximum 300 seconds. If not set,
4122+
defaults to the internal crashloopbackoff maximum (300s).
4123+
type: string
41184124
dockerDisableSharedPID:
41194125
description: DockerDisableSharedPID was removed.
41204126
type: boolean
@@ -4568,6 +4574,12 @@ spec:
45684574
description: CpuManagerPolicy allows for changing the default
45694575
policy of None to static
45704576
type: string
4577+
crashLoopBackOffMaxContainerRestartPeriod:
4578+
description: CrashLoopBackOffMaxContainerRestartPeriod is the
4579+
maximum duration the backoff delay can accrue to for container
4580+
restarts, minimum 1 second, maximum 300 seconds. If not set,
4581+
defaults to the internal crashloopbackoff maximum (300s).
4582+
type: string
45714583
dockerDisableSharedPID:
45724584
description: DockerDisableSharedPID was removed.
45734585
type: boolean

k8s/crds/kops.k8s.io_instancegroups.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,12 @@ spec:
506506
description: CpuManagerPolicy allows for changing the default
507507
policy of None to static
508508
type: string
509+
crashLoopBackOffMaxContainerRestartPeriod:
510+
description: CrashLoopBackOffMaxContainerRestartPeriod is the
511+
maximum duration the backoff delay can accrue to for container
512+
restarts, minimum 1 second, maximum 300 seconds. If not set,
513+
defaults to the internal crashloopbackoff maximum (300s).
514+
type: string
509515
dockerDisableSharedPID:
510516
description: DockerDisableSharedPID was removed.
511517
type: boolean

nodeup/pkg/model/kubelet.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ import (
2626
"path"
2727
"path/filepath"
2828
"strings"
29+
"time"
2930

3031
awsconfig "github.com/aws/aws-sdk-go-v2/config"
3132
"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
3233
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
34+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3335
"k8s.io/apimachinery/pkg/runtime"
3436
"k8s.io/apimachinery/pkg/runtime/serializer"
3537
"k8s.io/klog/v2"
@@ -242,6 +244,9 @@ func buildKubeletComponentConfig(kubeletConfig *kops.KubeletConfigSpec, provider
242244
if providerID != "" {
243245
componentConfig.ProviderID = providerID
244246
}
247+
componentConfig.CrashLoopBackOff = kubelet.CrashLoopBackOffConfig{
248+
MaxContainerRestartPeriod: kubeletConfig.CrashLoopBackOffMaxContainerRestartPeriod,
249+
}
245250
if kubeletConfig.ShutdownGracePeriod != nil {
246251
componentConfig.ShutdownGracePeriod = *kubeletConfig.ShutdownGracePeriod
247252
}
@@ -648,6 +653,11 @@ func (b *KubeletBuilder) buildKubeletConfigSpec(ctx context.Context) (*kops.Kube
648653

649654
c.ClientCAFile = filepath.Join(b.PathSrvKubernetes(), "ca.crt")
650655

656+
// Wait less for pods to restart, especially during the bootstrap sequence
657+
if b.IsMaster && c.CrashLoopBackOffMaxContainerRestartPeriod == nil {
658+
c.CrashLoopBackOffMaxContainerRestartPeriod = &metav1.Duration{Duration: time.Minute}
659+
}
660+
651661
// Respect any MaxPods value the user sets explicitly.
652662
if (b.NodeupConfig.Networking.AmazonVPC != nil || (b.NodeupConfig.Networking.Cilium != nil && b.NodeupConfig.Networking.Cilium.IPAM == kops.CiliumIpamEni)) && c.MaxPods == nil {
653663
config, err := awsconfig.LoadDefaultConfig(ctx)

pkg/apis/kops/componentconfig.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ type KubeletConfigSpec struct {
243243
// MemorySwapBehavior defines how swap is used by container workloads.
244244
// Supported values: LimitedSwap, "UnlimitedSwap.
245245
MemorySwapBehavior string `json:"memorySwapBehavior,omitempty"`
246+
// 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).
247+
CrashLoopBackOffMaxContainerRestartPeriod *metav1.Duration `json:"crashLoopBackOffMaxContainerRestartPeriod,omitempty"`
246248
}
247249

248250
// 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
@@ -243,6 +243,8 @@ type KubeletConfigSpec struct {
243243
// MemorySwapBehavior defines how swap is used by container workloads.
244244
// Supported values: LimitedSwap, "UnlimitedSwap.
245245
MemorySwapBehavior string `json:"memorySwapBehavior,omitempty"`
246+
// 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).
247+
CrashLoopBackOffMaxContainerRestartPeriod *metav1.Duration `json:"crashLoopBackOffMaxContainerRestartPeriod,omitempty"`
246248
}
247249

248250
// 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
@@ -241,6 +241,8 @@ type KubeletConfigSpec struct {
241241
// MemorySwapBehavior defines how swap is used by container workloads.
242242
// Supported values: LimitedSwap, "UnlimitedSwap.
243243
MemorySwapBehavior string `json:"memorySwapBehavior,omitempty"`
244+
// 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).
245+
CrashLoopBackOffMaxContainerRestartPeriod *metav1.Duration `json:"crashLoopBackOffMaxContainerRestartPeriod,omitempty"`
244246
}
245247

246248
// 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)