mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #127577 from vaibhav2107/eviction-hard
Added the MergeDefaultEvictionSettings Kubelet Config
This commit is contained in:
commit
1b4c3483ce
@ -443,6 +443,12 @@ func loadConfigFile(name string) (*kubeletconfiginternal.KubeletConfiguration, e
|
||||
// See: https://github.com/kubernetes/kubernetes/pull/110263
|
||||
if kc.EvictionHard == nil {
|
||||
kc.EvictionHard = eviction.DefaultEvictionHard
|
||||
} else if kc.MergeDefaultEvictionSettings {
|
||||
for k, v := range eviction.DefaultEvictionHard {
|
||||
if _, exists := kc.EvictionHard[k]; !exists {
|
||||
kc.EvictionHard[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
return kc, err
|
||||
}
|
||||
|
7
pkg/generated/openapi/zz_generated.openapi.go
generated
7
pkg/generated/openapi/zz_generated.openapi.go
generated
@ -64977,6 +64977,13 @@ func schema_k8sio_kubelet_config_v1beta1_KubeletConfiguration(ref common.Referen
|
||||
},
|
||||
},
|
||||
},
|
||||
"mergeDefaultEvictionSettings": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "mergeDefaultEvictionSettings indicates that defaults for the evictionHard, evictionSoft, evictionSoftGracePeriod, and evictionMinimumReclaim fields should be merged into values specified for those fields in this configuration. Signals specified in this configuration take precedence. Signals not specified in this configuration inherit their defaults. If false, and if any signal is specified in this configuration then other signals that are not specified in this configuration will be set to 0. It applies to merging the fields for which the default exists, and currently only evictionHard has default values. Default: false",
|
||||
Type: []string{"boolean"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"podsPerCore": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "podsPerCore is the maximum number of pods per core. Cannot exceed maxPods. The value must be a non-negative integer. If 0, there is no limit on the number of Pods. Default: 0",
|
||||
|
@ -98,6 +98,7 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||
obj.HairpinMode = v1beta1.PromiscuousBridge
|
||||
obj.EvictionHard = eviction.DefaultEvictionHard
|
||||
obj.EvictionPressureTransitionPeriod = metav1.Duration{Duration: 5 * time.Minute}
|
||||
obj.MergeDefaultEvictionSettings = false
|
||||
obj.MakeIPTablesUtilChains = true
|
||||
obj.IPTablesMasqueradeBit = kubeletconfigv1beta1.DefaultIPTablesMasqueradeBit
|
||||
obj.IPTablesDropBit = kubeletconfigv1beta1.DefaultIPTablesDropBit
|
||||
|
@ -258,6 +258,7 @@ var (
|
||||
"MaxPods",
|
||||
"MemoryManagerPolicy",
|
||||
"MemorySwap.SwapBehavior",
|
||||
"MergeDefaultEvictionSettings",
|
||||
"NodeLeaseDurationSeconds",
|
||||
"NodeStatusMaxImages",
|
||||
"NodeStatusUpdateFrequency.Duration",
|
||||
|
@ -70,6 +70,7 @@ maxPods: 110
|
||||
memoryManagerPolicy: None
|
||||
memorySwap: {}
|
||||
memoryThrottlingFactor: 0.9
|
||||
mergeDefaultEvictionSettings: false
|
||||
nodeLeaseDurationSeconds: 40
|
||||
nodeStatusMaxImages: 50
|
||||
nodeStatusReportFrequency: 5m0s
|
||||
|
@ -70,6 +70,7 @@ maxPods: 110
|
||||
memoryManagerPolicy: None
|
||||
memorySwap: {}
|
||||
memoryThrottlingFactor: 0.9
|
||||
mergeDefaultEvictionSettings: false
|
||||
nodeLeaseDurationSeconds: 40
|
||||
nodeStatusMaxImages: 50
|
||||
nodeStatusReportFrequency: 5m0s
|
||||
|
@ -322,6 +322,14 @@ type KubeletConfiguration struct {
|
||||
// amount of a given resource the kubelet will reclaim when performing a pod eviction while
|
||||
// that resource is under pressure. For example: {"imagefs.available": "2Gi"}
|
||||
EvictionMinimumReclaim map[string]string
|
||||
// mergeDefaultEvictionSettings indicates that defaults for the evictionHard, evictionSoft, evictionSoftGracePeriod, and evictionMinimumReclaim
|
||||
// fields should be merged into values specified for those fields in this configuration.
|
||||
// Signals specified in this configuration take precedence.
|
||||
// Signals not specified in this configuration inherit their defaults.
|
||||
// If false, and if any signal is specified in this configuration then other signals that
|
||||
// are not specified in this configuration will be set to 0.
|
||||
// It applies to merging the fields for which the default exists, and currently only evictionHard has default values.
|
||||
MergeDefaultEvictionSettings bool
|
||||
// podsPerCore is the maximum number of pods per core. Cannot exceed MaxPods.
|
||||
// If 0, this field is ignored.
|
||||
PodsPerCore int32
|
||||
|
@ -236,6 +236,9 @@ func SetDefaults_KubeletConfiguration(obj *kubeletconfigv1beta1.KubeletConfigura
|
||||
if obj.EvictionPressureTransitionPeriod == zeroDuration {
|
||||
obj.EvictionPressureTransitionPeriod = metav1.Duration{Duration: 5 * time.Minute}
|
||||
}
|
||||
if obj.MergeDefaultEvictionSettings == nil {
|
||||
obj.MergeDefaultEvictionSettings = ptr.To(false)
|
||||
}
|
||||
if obj.EnableControllerAttachDetach == nil {
|
||||
obj.EnableControllerAttachDetach = ptr.To(true)
|
||||
}
|
||||
|
@ -104,6 +104,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
|
||||
MaxParallelImagePulls: nil,
|
||||
EvictionHard: nil,
|
||||
EvictionPressureTransitionPeriod: metav1.Duration{Duration: 5 * time.Minute},
|
||||
MergeDefaultEvictionSettings: ptr.To(false),
|
||||
EnableControllerAttachDetach: ptr.To(true),
|
||||
MakeIPTablesUtilChains: ptr.To(true),
|
||||
IPTablesMasqueradeBit: ptr.To[int32](DefaultIPTablesMasqueradeBit),
|
||||
@ -221,6 +222,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
|
||||
EvictionPressureTransitionPeriod: zeroDuration,
|
||||
EvictionMaxPodGracePeriod: 0,
|
||||
EvictionMinimumReclaim: map[string]string{},
|
||||
MergeDefaultEvictionSettings: ptr.To(false),
|
||||
PodsPerCore: 0,
|
||||
EnableControllerAttachDetach: ptr.To(false),
|
||||
ProtectKernelDefaults: false,
|
||||
@ -334,6 +336,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
|
||||
EvictionSoftGracePeriod: map[string]string{},
|
||||
EvictionPressureTransitionPeriod: metav1.Duration{Duration: 5 * time.Minute},
|
||||
EvictionMinimumReclaim: map[string]string{},
|
||||
MergeDefaultEvictionSettings: ptr.To(false),
|
||||
EnableControllerAttachDetach: ptr.To(false),
|
||||
MakeIPTablesUtilChains: ptr.To(false),
|
||||
IPTablesMasqueradeBit: ptr.To[int32](0),
|
||||
@ -472,6 +475,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
|
||||
EvictionMinimumReclaim: map[string]string{
|
||||
"imagefs.available": "1Gi",
|
||||
},
|
||||
MergeDefaultEvictionSettings: ptr.To(true),
|
||||
PodsPerCore: 1,
|
||||
EnableControllerAttachDetach: ptr.To(true),
|
||||
ProtectKernelDefaults: true,
|
||||
@ -630,6 +634,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
|
||||
PodsPerCore: 1,
|
||||
EnableControllerAttachDetach: ptr.To(true),
|
||||
ProtectKernelDefaults: true,
|
||||
MergeDefaultEvictionSettings: ptr.To(true),
|
||||
MakeIPTablesUtilChains: ptr.To(true),
|
||||
IPTablesMasqueradeBit: ptr.To[int32](1),
|
||||
IPTablesDropBit: ptr.To[int32](1),
|
||||
@ -748,6 +753,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
|
||||
MaxParallelImagePulls: nil,
|
||||
EvictionHard: nil,
|
||||
EvictionPressureTransitionPeriod: metav1.Duration{Duration: 5 * time.Minute},
|
||||
MergeDefaultEvictionSettings: ptr.To(false),
|
||||
EnableControllerAttachDetach: ptr.To(true),
|
||||
MakeIPTablesUtilChains: ptr.To(true),
|
||||
IPTablesMasqueradeBit: ptr.To[int32](DefaultIPTablesMasqueradeBit),
|
||||
@ -843,6 +849,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
|
||||
MaxParallelImagePulls: ptr.To[int32](5),
|
||||
EvictionHard: nil,
|
||||
EvictionPressureTransitionPeriod: metav1.Duration{Duration: 5 * time.Minute},
|
||||
MergeDefaultEvictionSettings: ptr.To(false),
|
||||
EnableControllerAttachDetach: ptr.To(true),
|
||||
MakeIPTablesUtilChains: ptr.To(true),
|
||||
IPTablesMasqueradeBit: ptr.To[int32](DefaultIPTablesMasqueradeBit),
|
||||
@ -938,6 +945,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
|
||||
MaxParallelImagePulls: ptr.To[int32](1),
|
||||
EvictionHard: nil,
|
||||
EvictionPressureTransitionPeriod: metav1.Duration{Duration: 5 * time.Minute},
|
||||
MergeDefaultEvictionSettings: ptr.To(false),
|
||||
EnableControllerAttachDetach: ptr.To(true),
|
||||
MakeIPTablesUtilChains: ptr.To(true),
|
||||
IPTablesMasqueradeBit: ptr.To[int32](DefaultIPTablesMasqueradeBit),
|
||||
@ -1033,6 +1041,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
|
||||
MaxParallelImagePulls: nil,
|
||||
EvictionHard: nil,
|
||||
EvictionPressureTransitionPeriod: metav1.Duration{Duration: 5 * time.Minute},
|
||||
MergeDefaultEvictionSettings: ptr.To(false),
|
||||
EnableControllerAttachDetach: ptr.To(true),
|
||||
MakeIPTablesUtilChains: ptr.To(true),
|
||||
IPTablesMasqueradeBit: ptr.To[int32](DefaultIPTablesMasqueradeBit),
|
||||
|
@ -483,6 +483,9 @@ func autoConvert_v1beta1_KubeletConfiguration_To_config_KubeletConfiguration(in
|
||||
out.EvictionPressureTransitionPeriod = in.EvictionPressureTransitionPeriod
|
||||
out.EvictionMaxPodGracePeriod = in.EvictionMaxPodGracePeriod
|
||||
out.EvictionMinimumReclaim = *(*map[string]string)(unsafe.Pointer(&in.EvictionMinimumReclaim))
|
||||
if err := v1.Convert_Pointer_bool_To_bool(&in.MergeDefaultEvictionSettings, &out.MergeDefaultEvictionSettings, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.PodsPerCore = in.PodsPerCore
|
||||
if err := v1.Convert_Pointer_bool_To_bool(&in.EnableControllerAttachDetach, &out.EnableControllerAttachDetach, s); err != nil {
|
||||
return err
|
||||
@ -685,6 +688,9 @@ func autoConvert_config_KubeletConfiguration_To_v1beta1_KubeletConfiguration(in
|
||||
out.EvictionPressureTransitionPeriod = in.EvictionPressureTransitionPeriod
|
||||
out.EvictionMaxPodGracePeriod = in.EvictionMaxPodGracePeriod
|
||||
out.EvictionMinimumReclaim = *(*map[string]string)(unsafe.Pointer(&in.EvictionMinimumReclaim))
|
||||
if err := v1.Convert_bool_To_Pointer_bool(&in.MergeDefaultEvictionSettings, &out.MergeDefaultEvictionSettings, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.PodsPerCore = in.PodsPerCore
|
||||
if err := v1.Convert_bool_To_Pointer_bool(&in.EnableControllerAttachDetach, &out.EnableControllerAttachDetach, s); err != nil {
|
||||
return err
|
||||
|
@ -547,6 +547,16 @@ type KubeletConfiguration struct {
|
||||
// Default: nil
|
||||
// +optional
|
||||
EvictionMinimumReclaim map[string]string `json:"evictionMinimumReclaim,omitempty"`
|
||||
// mergeDefaultEvictionSettings indicates that defaults for the evictionHard, evictionSoft, evictionSoftGracePeriod, and evictionMinimumReclaim
|
||||
// fields should be merged into values specified for those fields in this configuration.
|
||||
// Signals specified in this configuration take precedence.
|
||||
// Signals not specified in this configuration inherit their defaults.
|
||||
// If false, and if any signal is specified in this configuration then other signals that
|
||||
// are not specified in this configuration will be set to 0.
|
||||
// It applies to merging the fields for which the default exists, and currently only evictionHard has default values.
|
||||
// Default: false
|
||||
// +optional
|
||||
MergeDefaultEvictionSettings *bool `json:"mergeDefaultEvictionSettings,omitempty"`
|
||||
// podsPerCore is the maximum number of pods per core. Cannot exceed maxPods.
|
||||
// The value must be a non-negative integer.
|
||||
// If 0, there is no limit on the number of Pods.
|
||||
|
@ -372,6 +372,11 @@ func (in *KubeletConfiguration) DeepCopyInto(out *KubeletConfiguration) {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.MergeDefaultEvictionSettings != nil {
|
||||
in, out := &in.MergeDefaultEvictionSettings, &out.MergeDefaultEvictionSettings
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
if in.EnableControllerAttachDetach != nil {
|
||||
in, out := &in.EnableControllerAttachDetach, &out.EnableControllerAttachDetach
|
||||
*out = new(bool)
|
||||
|
Loading…
Reference in New Issue
Block a user