kubelet: remove --register-schedulable flag

This commit is contained in:
carlory
2023-12-19 15:53:52 +08:00
parent 9d967ff973
commit ff74405bd3
8 changed files with 7 additions and 25 deletions

View File

@@ -794,7 +794,6 @@ function construct-linux-kubelet-flags {
#flags+=" --kubeconfig=/var/lib/kubelet/kubeconfig"
flags+=" --register-with-taints=node-role.kubernetes.io/control-plane=:NoSchedule"
flags+=" --kubeconfig=/var/lib/kubelet/bootstrap-kubeconfig"
flags+=" --register-schedulable=false"
fi
if [[ "${MASTER_OS_DISTRIBUTION}" == "ubuntu" ]]; then
# Configure the file path for host dns configuration

View File

@@ -127,10 +127,6 @@ type KubeletFlags struct {
// maxContainerCount is the maximum number of old instances of containers
// to retain globally. Each container takes up some disk space.
MaxContainerCount int32
// registerSchedulable tells the kubelet to register the node as
// schedulable. Won't have any effect if register-node is false.
// DEPRECATED: use registerWithTaints instead
RegisterSchedulable bool
// SeccompDefault enables the use of `RuntimeDefault` as the default seccomp profile for all workloads on the node.
SeccompDefault bool
}
@@ -144,7 +140,6 @@ func NewKubeletFlags() *KubeletFlags {
MaxContainerCount: -1,
MaxPerPodContainerCount: 1,
MinimumGCAge: metav1.Duration{Duration: 0},
RegisterSchedulable: true,
NodeLabels: make(map[string]string),
}
}
@@ -316,8 +311,6 @@ func (f *KubeletFlags) AddFlags(mainfs *pflag.FlagSet) {
fs.MarkDeprecated("maximum-dead-containers-per-container", "Use --eviction-hard or --eviction-soft instead. Will be removed in a future version.")
fs.Int32Var(&f.MaxContainerCount, "maximum-dead-containers", f.MaxContainerCount, "Maximum number of old instances of containers to retain globally. Each container takes up some disk space. To disable, set to a negative number.")
fs.MarkDeprecated("maximum-dead-containers", "Use --eviction-hard or --eviction-soft instead. Will be removed in a future version.")
fs.BoolVar(&f.RegisterSchedulable, "register-schedulable", f.RegisterSchedulable, "Register the node as schedulable. Won't have any effect if register-node is false.")
fs.MarkDeprecated("register-schedulable", "will be removed in a future version")
fs.StringVar(&f.ExperimentalMounterPath, "experimental-mounter-path", f.ExperimentalMounterPath, "[Experimental] Path of mounter binary. Leave empty to use the default mount.")
fs.MarkDeprecated("experimental-mounter-path", "will be removed in 1.25 or later. in favor of using CSI.")
fs.StringVar(&f.CloudConfigFile, "cloud-config", f.CloudConfigFile, "The path to the cloud provider configuration file. Empty string for no configuration file.")

View File

@@ -1345,7 +1345,6 @@ func createAndInitKubelet(kubeServer *options.KubeletServer,
kubeServer.MinimumGCAge,
kubeServer.MaxPerPodContainerCount,
kubeServer.MaxContainerCount,
kubeServer.RegisterSchedulable,
kubeServer.NodeLabels,
kubeServer.NodeStatusMaxImages,
kubeServer.KubeletFlags.SeccompDefault || kubeServer.KubeletConfiguration.SeccompDefault)

View File

@@ -368,7 +368,6 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
minimumGCAge metav1.Duration,
maxPerPodContainerCount int32,
maxContainerCount int32,
registerSchedulable bool,
nodeLabels map[string]string,
nodeStatusMaxImages int32,
seccompDefault bool,
@@ -540,7 +539,6 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
sourcesReady: config.NewSourcesReady(kubeDeps.PodConfig.SeenAllSources),
registerNode: registerNode,
registerWithTaints: registerWithTaints,
registerSchedulable: registerSchedulable,
dnsConfigurer: dns.NewConfigurer(kubeDeps.Recorder, nodeRef, nodeIPs, clusterDNS, kubeCfg.ClusterDomain, kubeCfg.ResolverConfig),
serviceLister: serviceLister,
serviceHasSynced: serviceHasSynced,
@@ -1093,8 +1091,6 @@ type Kubelet struct {
registerNode bool
// List of taints to add to a node object when the kubelet registers itself.
registerWithTaints []v1.Taint
// Set to true to have the node register itself as schedulable.
registerSchedulable bool
// for internal book keeping; access only from within registerWithApiserver
registrationCompleted bool

View File

@@ -311,9 +311,6 @@ func (kl *Kubelet) initialNode(ctx context.Context) (*v1.Node, error) {
kubeletapis.LabelArch: goruntime.GOARCH,
},
},
Spec: v1.NodeSpec{
Unschedulable: !kl.registerSchedulable,
},
}
osLabels, err := getOSSpecificLabels()
if err != nil {

View File

@@ -2758,8 +2758,12 @@ func TestRegisterWithApiServerWithTaint(t *testing.T) {
addNotImplatedReaction(kubeClient)
// Make node to be unschedulable.
kubelet.registerSchedulable = false
unschedulableTaint := v1.Taint{
Key: v1.TaintNodeUnschedulable,
Effect: v1.TaintEffectNoSchedule,
}
// Mark node with unschedulable taints
kubelet.registerWithTaints = []v1.Taint{unschedulableTaint}
// Reset kubelet status for each test.
kubelet.registrationCompleted = false
@@ -2769,13 +2773,9 @@ func TestRegisterWithApiServerWithTaint(t *testing.T) {
// Check the unschedulable taint.
got := gotNode.(*v1.Node)
unschedulableTaint := &v1.Taint{
Key: v1.TaintNodeUnschedulable,
Effect: v1.TaintEffectNoSchedule,
}
require.True(t,
taintutil.TaintExists(got.Spec.Taints, unschedulableTaint),
taintutil.TaintExists(got.Spec.Taints, &unschedulableTaint),
"test unschedulable taint for TaintNodesByCondition")
}

View File

@@ -3111,7 +3111,6 @@ func TestNewMainKubeletStandAlone(t *testing.T) {
metav1.Duration{Duration: time.Minute},
1024,
110,
true,
map[string]string{},
1024,
false,

View File

@@ -160,7 +160,6 @@ func GetHollowKubeletConfig(opt *HollowKubeletOptions) (*options.KubeletFlags, *
f.MaxContainerCount = 100
f.MaxPerPodContainerCount = 2
f.NodeLabels = opt.NodeLabels
f.RegisterSchedulable = true
// Config struct
c, err := options.NewKubeletConfiguration()