Skip to content

Commit 03cd30b

Browse files
authored
Merge pull request kubernetes#90494 from knabben/kubelet-provider
Migrating Kubelet --enable-server and --provider-id flags to config
2 parents 6b15b1f + 8459c9b commit 03cd30b

File tree

11 files changed

+46
-14
lines changed

11 files changed

+46
-14
lines changed

cmd/kubelet/app/options/options.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,13 @@ type KubeletFlags struct {
6161
// Crash immediately, rather than eating panics.
6262
ReallyCrashForTesting bool
6363

64-
// enableServer enables the Kubelet's server
65-
EnableServer bool
66-
6764
// HostnameOverride is the hostname used to identify the kubelet instead
6865
// of the actual hostname.
6966
HostnameOverride string
7067
// NodeIP is IP address of the node.
7168
// If set, kubelet will use this IP address for the node.
7269
NodeIP string
7370

74-
// This flag, if set, sets the unique id of the instance that an external provider (i.e. cloudprovider)
75-
// can use to identify a specific node
76-
ProviderID string
77-
7871
// Container-runtime-specific options.
7972
config.ContainerRuntimeOptions
8073

@@ -190,7 +183,6 @@ func NewKubeletFlags() *KubeletFlags {
190183
}
191184

192185
return &KubeletFlags{
193-
EnableServer: true,
194186
ContainerRuntimeOptions: *NewContainerRuntimeOptions(),
195187
CertDirectory: "/var/lib/kubelet/pki",
196188
RootDirectory: defaultRootDir,
@@ -345,14 +337,10 @@ func (f *KubeletFlags) AddFlags(mainfs *pflag.FlagSet) {
345337
"On success, a kubeconfig file referencing the generated client certificate and key is written to the path specified by --kubeconfig. "+
346338
"The client certificate and key file will be stored in the directory pointed by --cert-dir.")
347339

348-
fs.BoolVar(&f.EnableServer, "enable-server", f.EnableServer, "Enable the Kubelet's server")
349-
350340
fs.StringVar(&f.HostnameOverride, "hostname-override", f.HostnameOverride, "If non-empty, will use this string as identification instead of the actual hostname. If --cloud-provider is set, the cloud provider determines the name of the node (consult cloud provider documentation to determine if and how the hostname is used).")
351341

352342
fs.StringVar(&f.NodeIP, "node-ip", f.NodeIP, "IP address of the node. If set, kubelet will use this IP address for the node. If unset, kubelet will use the node's default IPv4 address, if any, or its default IPv6 address if it has no IPv4 addresses. You can pass '::' to make it prefer the default IPv6 address rather than the default IPv4 address.")
353343

354-
fs.StringVar(&f.ProviderID, "provider-id", f.ProviderID, "Unique identifier for identifying the node in a machine database, i.e cloudprovider")
355-
356344
fs.StringVar(&f.CertDirectory, "cert-dir", f.CertDirectory, "The directory where the TLS certs are located. "+
357345
"If --tls-cert-file and --tls-private-key-file are provided, this flag will be ignored.")
358346

@@ -425,6 +413,8 @@ func AddKubeletConfigFlags(mainfs *pflag.FlagSet, c *kubeletconfig.KubeletConfig
425413
mainfs.AddFlagSet(fs)
426414
}()
427415

416+
fs.BoolVar(&c.EnableServer, "enable-server", c.EnableServer, "Enable the Kubelet's server")
417+
428418
fs.BoolVar(&c.FailSwapOn, "fail-swap-on", c.FailSwapOn, "Makes the Kubelet fail to start if swap is enabled on the node. ")
429419
fs.StringVar(&c.StaticPodPath, "pod-manifest-path", c.StaticPodPath, "Path to the directory containing static pod files to run, or the path to a single static pod file. Files starting with dots will be ignored.")
430420
fs.DurationVar(&c.SyncFrequency.Duration, "sync-frequency", c.SyncFrequency.Duration, "Max period between synchronizing running containers and config")
@@ -503,6 +493,8 @@ func AddKubeletConfigFlags(mainfs *pflag.FlagSet, c *kubeletconfig.KubeletConfig
503493
fs.StringVar(&c.KubeletCgroups, "kubelet-cgroups", c.KubeletCgroups, "Optional absolute name of cgroups to create and run the Kubelet in.")
504494
fs.StringVar(&c.SystemCgroups, "system-cgroups", c.SystemCgroups, "Optional absolute name of cgroups in which to place all non-kernel processes that are not already inside a cgroup under '/'. Empty for no container. Rolling back the flag requires a reboot.")
505495

496+
fs.StringVar(&c.ProviderID, "provider-id", c.ProviderID, "Unique identifier for identifying the node in a machine database, i.e cloudprovider")
497+
506498
fs.BoolVar(&c.CgroupsPerQOS, "cgroups-per-qos", c.CgroupsPerQOS, "Enable creation of QoS cgroup hierarchy, if true top level QoS and pod cgroups are created.")
507499
fs.StringVar(&c.CgroupDriver, "cgroup-driver", c.CgroupDriver, "Driver that the kubelet uses to manipulate cgroups on the host. Possible values: 'cgroupfs', 'systemd'")
508500
fs.StringVar(&c.CgroupRoot, "cgroup-root", c.CgroupRoot, "Optional root cgroup to use for pods. This is handled by the container runtime on a best effort basis. Default: '', which means use the container runtime default.")

pkg/kubelet/apis/config/fuzzer/fuzzer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
3737
// provide non-empty values for fields with defaults, so the defaulter doesn't change values during round-trip
3838
func(obj *kubeletconfig.KubeletConfiguration, c fuzz.Continue) {
3939
c.FuzzNoCustom(obj)
40+
obj.EnableServer = true
4041
obj.Authentication.Anonymous.Enabled = true
4142
obj.Authentication.Webhook.Enabled = false
4243
obj.Authentication.Webhook.CacheTTL = metav1.Duration{Duration: 2 * time.Minute}

pkg/kubelet/apis/config/helpers_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ var (
165165
"EnableContentionProfiling",
166166
"EnableControllerAttachDetach",
167167
"EnableDebuggingHandlers",
168+
"EnableServer",
168169
"EnforceNodeAllocatable[*]",
169170
"EventBurst",
170171
"EventRecordQPS",
@@ -209,6 +210,7 @@ var (
209210
"PodsPerCore",
210211
"Port",
211212
"ProtectKernelDefaults",
213+
"ProviderID",
212214
"ReadOnlyPort",
213215
"RegistryBurst",
214216
"RegistryPullQPS",

pkg/kubelet/apis/config/scheme/testdata/KubeletConfiguration/after/v1beta1.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ cpuManagerPolicy: none
2424
cpuManagerReconcilePeriod: 10s
2525
enableControllerAttachDetach: true
2626
enableDebuggingHandlers: true
27+
enableServer: true
2728
enforceNodeAllocatable:
2829
- pods
2930
eventBurst: 10

pkg/kubelet/apis/config/scheme/testdata/KubeletConfiguration/roundtrip/default/v1beta1.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ cpuManagerPolicy: none
2424
cpuManagerReconcilePeriod: 10s
2525
enableControllerAttachDetach: true
2626
enableDebuggingHandlers: true
27+
enableServer: true
2728
enforceNodeAllocatable:
2829
- pods
2930
eventBurst: 10

pkg/kubelet/apis/config/types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ const (
7474
type KubeletConfiguration struct {
7575
metav1.TypeMeta
7676

77+
// enableServer enables Kubelet's secured server.
78+
// Note: Kubelet's insecure port is controlled by the readOnlyPort option.
79+
EnableServer bool
7780
// staticPodPath is the path to the directory containing local (static) pods to
7881
// run, or the path to a single static pod file.
7982
StaticPodPath string
@@ -100,6 +103,9 @@ type KubeletConfiguration struct {
100103
// volumePluginDir is the full path of the directory in which to search
101104
// for additional third party volume plugins.
102105
VolumePluginDir string
106+
// providerID, if set, sets the unique id of the instance that an external provider (i.e. cloudprovider)
107+
// can use to identify a specific node
108+
ProviderID string
103109
// tlsCertFile is the file containing x509 Certificate for HTTPS. (CA cert,
104110
// if any, concatenated after server cert). If tlsCertFile and
105111
// tlsPrivateKeyFile are not provided, a self-signed certificate

pkg/kubelet/apis/config/v1beta1/defaults.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ func addDefaultingFuncs(scheme *kruntime.Scheme) error {
4848
}
4949

5050
func SetDefaults_KubeletConfiguration(obj *kubeletconfigv1beta1.KubeletConfiguration) {
51+
if obj.EnableServer == nil {
52+
obj.EnableServer = utilpointer.BoolPtr(true)
53+
}
5154
if obj.SyncFrequency == zeroDuration {
5255
obj.SyncFrequency = metav1.Duration{Duration: 1 * time.Minute}
5356
}

pkg/kubelet/apis/config/v1beta1/zz_generated.conversion.go

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

pkg/kubemark/hollow_kubelet.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ func GetHollowKubeletConfig(opt *HollowKubletOptions) (*options.KubeletFlags, *k
155155

156156
// Flags struct
157157
f := options.NewKubeletFlags()
158-
f.EnableServer = true
159158
f.RootDirectory = testRootDir
160159
f.HostnameOverride = opt.NodeName
161160
f.MinimumGCAge = metav1.Duration{Duration: 1 * time.Minute}
@@ -165,7 +164,6 @@ func GetHollowKubeletConfig(opt *HollowKubletOptions) (*options.KubeletFlags, *k
165164
f.ContainerRuntimeOptions.ContainerRuntime = kubetypes.RemoteContainerRuntime
166165
f.RegisterNode = true
167166
f.RegisterSchedulable = true
168-
f.ProviderID = fmt.Sprintf("kubemark://%v", opt.NodeName)
169167

170168
// Config struct
171169
c, err := options.NewKubeletConfiguration()
@@ -174,6 +172,7 @@ func GetHollowKubeletConfig(opt *HollowKubletOptions) (*options.KubeletFlags, *k
174172
}
175173

176174
c.StaticPodURL = ""
175+
c.EnableServer = true
177176
c.Address = "0.0.0.0" /* bind address */
178177
c.Port = int32(opt.KubeletPort)
179178
c.ReadOnlyPort = int32(opt.KubeletReadOnlyPort)
@@ -189,6 +188,7 @@ func GetHollowKubeletConfig(opt *HollowKubletOptions) (*options.KubeletFlags, *k
189188
c.ClusterDNS = []string{}
190189
c.ImageGCHighThresholdPercent = 90
191190
c.ImageGCLowThresholdPercent = 80
191+
c.ProviderID = fmt.Sprintf("kubemark://%v", opt.NodeName)
192192
c.VolumeStatsAggPeriod.Duration = time.Minute
193193
c.CgroupRoot = ""
194194
c.CPUCFSQuota = true

staging/src/k8s.io/kubelet/config/v1beta1/types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ const (
7474
type KubeletConfiguration struct {
7575
metav1.TypeMeta `json:",inline"`
7676

77+
// enableServer enables Kubelet's secured server.
78+
// Note: Kubelet's insecure port is controlled by the readOnlyPort option.
79+
// Dynamic Kubelet Config (beta): If dynamically updating this field, consider that
80+
// it may disrupt components that interact with the Kubelet server.
81+
// Default: true
82+
EnableServer *bool `json:"enableServer,omitempty"`
7783
// staticPodPath is the path to the directory containing local (static) pods to
7884
// run, or the path to a single static pod file.
7985
// Dynamic Kubelet Config (beta): If dynamically updating this field, consider that
@@ -767,6 +773,13 @@ type KubeletConfiguration struct {
767773
// Default: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec/"
768774
// +optional
769775
VolumePluginDir string `json:"volumePluginDir,omitempty"`
776+
// providerID, if set, sets the unique id of the instance that an external provider (i.e. cloudprovider)
777+
// can use to identify a specific node.
778+
// Dynamic Kubelet Config (beta): If dynamically updating this field, consider that
779+
// it may impact the ability of the Kubelet to interact with cloud providers.
780+
// Default: ""
781+
// +optional
782+
ProviderID string `json:"providerID,omitempty"`
770783
}
771784

772785
type KubeletAuthorizationMode string

0 commit comments

Comments
 (0)