mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-20 09:33:52 +00:00
migrate --register-with-taints to KubeletConfiguration
This commit is contained in:
@@ -256,10 +256,12 @@ var (
|
||||
"ProtectKernelDefaults",
|
||||
"ProviderID",
|
||||
"ReadOnlyPort",
|
||||
"RegisterNode",
|
||||
"RegistryBurst",
|
||||
"RegistryPullQPS",
|
||||
"ReservedMemory",
|
||||
"ReservedSystemCPUs",
|
||||
"RegisterWithTaints",
|
||||
"RuntimeRequestTimeout.Duration",
|
||||
"RunOnce",
|
||||
"SeccompDefault",
|
||||
|
@@ -35,6 +35,7 @@ func TestComponentConfigSetup(t *testing.T) {
|
||||
reflect.TypeOf(metav1.TypeMeta{}): true,
|
||||
reflect.TypeOf(metav1.Duration{}): true,
|
||||
reflect.TypeOf(v1.NodeConfigSource{}): true,
|
||||
reflect.TypeOf(v1.Taint{}): true,
|
||||
},
|
||||
}
|
||||
|
||||
|
@@ -72,6 +72,7 @@ nodeStatusUpdateFrequency: 10s
|
||||
oomScoreAdj: -999
|
||||
podPidsLimit: -1
|
||||
port: 10250
|
||||
registerNode: true
|
||||
registryBurst: 10
|
||||
registryPullQPS: 5
|
||||
resolvConf: /etc/resolv.conf
|
||||
|
@@ -72,6 +72,7 @@ nodeStatusUpdateFrequency: 10s
|
||||
oomScoreAdj: -999
|
||||
podPidsLimit: -1
|
||||
port: 10250
|
||||
registerNode: true
|
||||
registryBurst: 10
|
||||
registryPullQPS: 5
|
||||
resolvConf: /etc/resolv.conf
|
||||
|
@@ -426,6 +426,15 @@ type KubeletConfiguration struct {
|
||||
// +featureGate=MemoryQoS
|
||||
// +optional
|
||||
MemoryThrottlingFactor *float64
|
||||
// registerWithTaints are an array of taints to add to a node object when
|
||||
// the kubelet registers itself. This only takes effect when registerNode
|
||||
// is true and upon the initial registration of the node.
|
||||
// +optional
|
||||
RegisterWithTaints []v1.Taint
|
||||
|
||||
// registerNode enables automatic registration with the apiserver.
|
||||
// +optional
|
||||
RegisterNode bool
|
||||
}
|
||||
|
||||
// KubeletAuthorizationMode denotes the authorization mode for the kubelet
|
||||
|
@@ -261,4 +261,7 @@ func SetDefaults_KubeletConfiguration(obj *kubeletconfigv1beta1.KubeletConfigura
|
||||
if obj.MemoryThrottlingFactor == nil {
|
||||
obj.MemoryThrottlingFactor = utilpointer.Float64Ptr(DefaultMemoryThrottlingFactor)
|
||||
}
|
||||
if obj.RegisterNode == nil {
|
||||
obj.RegisterNode = utilpointer.BoolPtr(true)
|
||||
}
|
||||
}
|
||||
|
@@ -120,6 +120,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
|
||||
EnableDebugFlagsHandler: utilpointer.BoolPtr(true),
|
||||
SeccompDefault: utilpointer.BoolPtr(false),
|
||||
MemoryThrottlingFactor: utilpointer.Float64Ptr(DefaultMemoryThrottlingFactor),
|
||||
RegisterNode: utilpointer.BoolPtr(true),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -244,6 +245,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
|
||||
EnableDebugFlagsHandler: utilpointer.Bool(false),
|
||||
SeccompDefault: utilpointer.Bool(false),
|
||||
MemoryThrottlingFactor: utilpointer.Float64(0),
|
||||
RegisterNode: utilpointer.BoolPtr(false),
|
||||
},
|
||||
&v1beta1.KubeletConfiguration{
|
||||
EnableServer: utilpointer.BoolPtr(false),
|
||||
@@ -339,6 +341,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
|
||||
EnableDebugFlagsHandler: utilpointer.Bool(false),
|
||||
SeccompDefault: utilpointer.Bool(false),
|
||||
MemoryThrottlingFactor: utilpointer.Float64(0),
|
||||
RegisterNode: utilpointer.BoolPtr(false),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -488,6 +491,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
|
||||
EnableDebugFlagsHandler: utilpointer.Bool(true),
|
||||
SeccompDefault: utilpointer.Bool(true),
|
||||
MemoryThrottlingFactor: utilpointer.Float64(1),
|
||||
RegisterNode: utilpointer.BoolPtr(true),
|
||||
},
|
||||
&v1beta1.KubeletConfiguration{
|
||||
EnableServer: utilpointer.BoolPtr(true),
|
||||
@@ -634,6 +638,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
|
||||
EnableDebugFlagsHandler: utilpointer.Bool(true),
|
||||
SeccompDefault: utilpointer.Bool(true),
|
||||
MemoryThrottlingFactor: utilpointer.Float64(1),
|
||||
RegisterNode: utilpointer.BoolPtr(true),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -719,6 +724,7 @@ func TestSetDefaultsKubeletConfiguration(t *testing.T) {
|
||||
EnableDebugFlagsHandler: utilpointer.BoolPtr(true),
|
||||
SeccompDefault: utilpointer.BoolPtr(false),
|
||||
MemoryThrottlingFactor: utilpointer.Float64Ptr(DefaultMemoryThrottlingFactor),
|
||||
RegisterNode: utilpointer.BoolPtr(true),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@@ -392,6 +392,10 @@ func autoConvert_v1beta1_KubeletConfiguration_To_config_KubeletConfiguration(in
|
||||
return err
|
||||
}
|
||||
out.MemoryThrottlingFactor = (*float64)(unsafe.Pointer(in.MemoryThrottlingFactor))
|
||||
out.RegisterWithTaints = *(*[]corev1.Taint)(unsafe.Pointer(&in.RegisterWithTaints))
|
||||
if err := v1.Convert_Pointer_bool_To_bool(&in.RegisterNode, &out.RegisterNode, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -563,6 +567,10 @@ func autoConvert_config_KubeletConfiguration_To_v1beta1_KubeletConfiguration(in
|
||||
return err
|
||||
}
|
||||
out.MemoryThrottlingFactor = (*float64)(unsafe.Pointer(in.MemoryThrottlingFactor))
|
||||
out.RegisterWithTaints = *(*[]corev1.Taint)(unsafe.Pointer(&in.RegisterWithTaints))
|
||||
if err := v1.Convert_bool_To_Pointer_bool(&in.RegisterNode, &out.RegisterNode, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@@ -31,6 +31,7 @@ import (
|
||||
kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
|
||||
"k8s.io/kubernetes/pkg/kubelet/cm/cpuset"
|
||||
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
|
||||
utiltaints "k8s.io/kubernetes/pkg/util/taints"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -126,6 +127,16 @@ func ValidateKubeletConfiguration(kc *kubeletconfig.KubeletConfiguration) error
|
||||
if kc.TopologyManagerPolicy != kubeletconfig.NoneTopologyManagerPolicy && !localFeatureGate.Enabled(features.TopologyManager) {
|
||||
allErrors = append(allErrors, fmt.Errorf("invalid configuration: topologyManagerPolicy %v requires feature gate TopologyManager", kc.TopologyManagerPolicy))
|
||||
}
|
||||
|
||||
for _, nodeTaint := range kc.RegisterWithTaints {
|
||||
if err := utiltaints.CheckTaintValidation(nodeTaint); err != nil {
|
||||
allErrors = append(allErrors, fmt.Errorf("invalid taint: %v", nodeTaint))
|
||||
}
|
||||
if nodeTaint.TimeAdded != nil {
|
||||
allErrors = append(allErrors, fmt.Errorf("taint TimeAdded is not nil"))
|
||||
}
|
||||
}
|
||||
|
||||
switch kc.TopologyManagerPolicy {
|
||||
case kubeletconfig.NoneTopologyManagerPolicy:
|
||||
case kubeletconfig.BestEffortTopologyManagerPolicy:
|
||||
|
7
pkg/kubelet/apis/config/zz_generated.deepcopy.go
generated
7
pkg/kubelet/apis/config/zz_generated.deepcopy.go
generated
@@ -295,6 +295,13 @@ func (in *KubeletConfiguration) DeepCopyInto(out *KubeletConfiguration) {
|
||||
*out = new(float64)
|
||||
**out = **in
|
||||
}
|
||||
if in.RegisterWithTaints != nil {
|
||||
in, out := &in.RegisterWithTaints, &out.RegisterWithTaints
|
||||
*out = make([]corev1.Taint, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user