mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
kubeadm: Move IPv6DualStack feature gate to component config
kubeadm is setting the IPv6DualStack feature gate in the command line of the kubelet. However, the kubelet is gradually moving away from command line flags towards component config use. Hence, we should set the IPv6DualStack feature gate in the component config instead. Signed-off-by: Rostislav M. Georgiev <rostislavg@vmware.com>
This commit is contained in:
parent
9f76518c40
commit
b46259b7af
@ -105,6 +105,12 @@ func (kc *kubeletConfig) Default(cfg *kubeadmapi.ClusterConfiguration, _ *kubead
|
||||
kc.config.FeatureGates = map[string]bool{}
|
||||
}
|
||||
|
||||
// TODO: The following code should be removed after dual-stack is GA.
|
||||
// Note: The user still retains the ability to explicitly set feature-gates and that value will overwrite this base value.
|
||||
if enabled, present := cfg.FeatureGates[features.IPv6DualStack]; present {
|
||||
kc.config.FeatureGates[features.IPv6DualStack] = enabled
|
||||
}
|
||||
|
||||
if kc.config.StaticPodPath == "" {
|
||||
kc.config.StaticPodPath = kubeadmapiv1beta2.DefaultManifestsDir
|
||||
} else if kc.config.StaticPodPath != kubeadmapiv1beta2.DefaultManifestsDir {
|
||||
|
@ -229,7 +229,45 @@ func TestKubeletDefault(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Service subnet, dual stack defaulting works",
|
||||
name: "Service subnet, explicitly disabled dual stack defaulting works",
|
||||
clusterCfg: kubeadmapi.ClusterConfiguration{
|
||||
FeatureGates: map[string]bool{
|
||||
features.IPv6DualStack: false,
|
||||
},
|
||||
Networking: kubeadmapi.Networking{
|
||||
ServiceSubnet: "192.168.0.0/16",
|
||||
},
|
||||
},
|
||||
expected: kubeletConfig{
|
||||
config: kubeletconfig.KubeletConfiguration{
|
||||
FeatureGates: map[string]bool{
|
||||
features.IPv6DualStack: false,
|
||||
},
|
||||
StaticPodPath: kubeadmapiv1beta2.DefaultManifestsDir,
|
||||
ClusterDNS: []string{"192.168.0.10"},
|
||||
Authentication: kubeletconfig.KubeletAuthentication{
|
||||
X509: kubeletconfig.KubeletX509Authentication{
|
||||
ClientCAFile: constants.CACertName,
|
||||
},
|
||||
Anonymous: kubeletconfig.KubeletAnonymousAuthentication{
|
||||
Enabled: utilpointer.BoolPtr(kubeletAuthenticationAnonymousEnabled),
|
||||
},
|
||||
Webhook: kubeletconfig.KubeletWebhookAuthentication{
|
||||
Enabled: utilpointer.BoolPtr(kubeletAuthenticationWebhookEnabled),
|
||||
},
|
||||
},
|
||||
Authorization: kubeletconfig.KubeletAuthorization{
|
||||
Mode: kubeletconfig.KubeletAuthorizationModeWebhook,
|
||||
},
|
||||
HealthzBindAddress: kubeletHealthzBindAddress,
|
||||
HealthzPort: utilpointer.Int32Ptr(constants.KubeletHealthzPort),
|
||||
RotateCertificates: kubeletRotateCertificates,
|
||||
ResolverConfig: resolverConfig,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Service subnet, enabled dual stack defaulting works",
|
||||
clusterCfg: kubeadmapi.ClusterConfiguration{
|
||||
FeatureGates: map[string]bool{
|
||||
features.IPv6DualStack: true,
|
||||
@ -240,7 +278,9 @@ func TestKubeletDefault(t *testing.T) {
|
||||
},
|
||||
expected: kubeletConfig{
|
||||
config: kubeletconfig.KubeletConfiguration{
|
||||
FeatureGates: map[string]bool{},
|
||||
FeatureGates: map[string]bool{
|
||||
features.IPv6DualStack: true,
|
||||
},
|
||||
StaticPodPath: kubeadmapiv1beta2.DefaultManifestsDir,
|
||||
ClusterDNS: []string{"192.168.0.10"},
|
||||
Authentication: kubeletconfig.KubeletAuthentication{
|
||||
|
@ -14,7 +14,6 @@ go_library(
|
||||
"//cmd/kubeadm/app/apis/kubeadm:go_default_library",
|
||||
"//cmd/kubeadm/app/componentconfigs:go_default_library",
|
||||
"//cmd/kubeadm/app/constants:go_default_library",
|
||||
"//cmd/kubeadm/app/features:go_default_library",
|
||||
"//cmd/kubeadm/app/images:go_default_library",
|
||||
"//cmd/kubeadm/app/util:go_default_library",
|
||||
"//cmd/kubeadm/app/util/apiclient:go_default_library",
|
||||
|
@ -28,14 +28,12 @@ import (
|
||||
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/features"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/images"
|
||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||
)
|
||||
|
||||
type kubeletFlagsOpts struct {
|
||||
nodeRegOpts *kubeadmapi.NodeRegistrationOptions
|
||||
featureGates map[string]bool
|
||||
pauseImage string
|
||||
registerTaintsUsingFlags bool
|
||||
}
|
||||
@ -63,7 +61,6 @@ func GetNodeNameAndHostname(cfg *kubeadmapi.NodeRegistrationOptions) (string, st
|
||||
func WriteKubeletDynamicEnvFile(cfg *kubeadmapi.ClusterConfiguration, nodeReg *kubeadmapi.NodeRegistrationOptions, registerTaintsUsingFlags bool, kubeletDir string) error {
|
||||
flagOpts := kubeletFlagsOpts{
|
||||
nodeRegOpts: nodeReg,
|
||||
featureGates: cfg.FeatureGates,
|
||||
pauseImage: images.GetPauseImage(cfg),
|
||||
registerTaintsUsingFlags: registerTaintsUsingFlags,
|
||||
}
|
||||
@ -109,12 +106,6 @@ func buildKubeletArgMapCommon(opts kubeletFlagsOpts) map[string]string {
|
||||
kubeletFlags["hostname-override"] = nodeName
|
||||
}
|
||||
|
||||
// TODO: The following code should be removed after dual-stack is GA.
|
||||
// Note: The user still retains the ability to explicitly set feature-gates and that value will overwrite this base value.
|
||||
if enabled, present := opts.featureGates[features.IPv6DualStack]; present {
|
||||
kubeletFlags["feature-gates"] = fmt.Sprintf("%s=%t", features.IPv6DualStack, enabled)
|
||||
}
|
||||
|
||||
return kubeletFlags
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user