mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
cleanup: DualStack GA for kubeadm
This commit is contained in:
parent
81e41b7fc4
commit
a0cc3f1c9a
@ -375,7 +375,7 @@ func ValidateHostPort(endpoint string, fldPath *field.Path) field.ErrorList {
|
||||
}
|
||||
|
||||
// ValidateIPNetFromString validates network portion of ip address
|
||||
func ValidateIPNetFromString(subnetStr string, minAddrs int64, isDualStack bool, fldPath *field.Path) field.ErrorList {
|
||||
func ValidateIPNetFromString(subnetStr string, minAddrs int64, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
subnets, err := netutils.ParseCIDRs(strings.Split(subnetStr, ","))
|
||||
if err != nil {
|
||||
@ -384,19 +384,16 @@ func ValidateIPNetFromString(subnetStr string, minAddrs int64, isDualStack bool,
|
||||
}
|
||||
switch {
|
||||
// if DualStack only 2 CIDRs allowed
|
||||
case isDualStack && len(subnets) > 2:
|
||||
case len(subnets) > 2:
|
||||
allErrs = append(allErrs, field.Invalid(fldPath, subnetStr, "expected one (IPv4 or IPv6) CIDR or two CIDRs from each family for dual-stack networking"))
|
||||
// if DualStack and there are 2 CIDRs validate if there is at least one of each IP family
|
||||
case isDualStack && len(subnets) == 2:
|
||||
case len(subnets) == 2:
|
||||
areDualStackCIDRs, err := netutils.IsDualStackCIDRs(subnets)
|
||||
if err != nil {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath, subnetStr, err.Error()))
|
||||
} else if !areDualStackCIDRs {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath, subnetStr, "expected one (IPv4 or IPv6) CIDR or two CIDRs from each family for dual-stack networking"))
|
||||
}
|
||||
// if not DualStack only one CIDR allowed
|
||||
case !isDualStack && len(subnets) > 1:
|
||||
allErrs = append(allErrs, field.Invalid(fldPath, subnetStr, "only one CIDR allowed for single-stack networking"))
|
||||
}
|
||||
// validate the subnet/s
|
||||
for _, s := range subnets {
|
||||
@ -470,14 +467,11 @@ func getClusterNodeMask(c *kubeadm.ClusterConfiguration, isIPv6 bool) (int, erro
|
||||
var maskSize int
|
||||
var maskArg string
|
||||
var err error
|
||||
isDualStack := features.Enabled(c.FeatureGates, features.IPv6DualStack)
|
||||
|
||||
if isDualStack && isIPv6 {
|
||||
if isIPv6 {
|
||||
maskArg = "node-cidr-mask-size-ipv6"
|
||||
} else if isDualStack && !isIPv6 {
|
||||
maskArg = "node-cidr-mask-size-ipv4"
|
||||
} else {
|
||||
maskArg = "node-cidr-mask-size"
|
||||
maskArg = "node-cidr-mask-size-ipv4"
|
||||
}
|
||||
|
||||
if v, ok := c.ControllerManager.ExtraArgs[maskArg]; ok && v != "" {
|
||||
@ -513,16 +507,14 @@ func ValidateNetworking(c *kubeadm.ClusterConfiguration, fldPath *field.Path) fi
|
||||
for _, err := range validation.IsDNS1123Subdomain(c.Networking.DNSDomain) {
|
||||
allErrs = append(allErrs, field.Invalid(dnsDomainFldPath, c.Networking.DNSDomain, err))
|
||||
}
|
||||
// check if dual-stack feature-gate is enabled
|
||||
isDualStack := features.Enabled(c.FeatureGates, features.IPv6DualStack)
|
||||
|
||||
if len(c.Networking.ServiceSubnet) != 0 {
|
||||
allErrs = append(allErrs, ValidateIPNetFromString(c.Networking.ServiceSubnet, constants.MinimumAddressesInServiceSubnet, isDualStack, field.NewPath("serviceSubnet"))...)
|
||||
allErrs = append(allErrs, ValidateIPNetFromString(c.Networking.ServiceSubnet, constants.MinimumAddressesInServiceSubnet, field.NewPath("serviceSubnet"))...)
|
||||
// Service subnet was already validated, we need to validate now the subnet size
|
||||
allErrs = append(allErrs, ValidateServiceSubnetSize(c.Networking.ServiceSubnet, field.NewPath("serviceSubnet"))...)
|
||||
}
|
||||
if len(c.Networking.PodSubnet) != 0 {
|
||||
allErrs = append(allErrs, ValidateIPNetFromString(c.Networking.PodSubnet, constants.MinimumAddressesInPodSubnet, isDualStack, field.NewPath("podSubnet"))...)
|
||||
allErrs = append(allErrs, ValidateIPNetFromString(c.Networking.PodSubnet, constants.MinimumAddressesInPodSubnet, field.NewPath("podSubnet"))...)
|
||||
if c.ControllerManager.ExtraArgs["allocate-node-cidrs"] != "false" {
|
||||
// Pod subnet was already validated, we need to validate now against the node-mask
|
||||
allErrs = append(allErrs, ValidatePodSubnetNodeMask(c.Networking.PodSubnet, c, field.NewPath("podSubnet"))...)
|
||||
|
@ -187,41 +187,28 @@ func TestValidateIPFromString(t *testing.T) {
|
||||
|
||||
func TestValidateIPNetFromString(t *testing.T) {
|
||||
var tests = []struct {
|
||||
name string
|
||||
subnet string
|
||||
minaddrs int64
|
||||
checkDualStack bool
|
||||
expected bool
|
||||
name string
|
||||
subnet string
|
||||
minaddrs int64
|
||||
expected bool
|
||||
}{
|
||||
{"invalid missing CIDR", "", 0, false, false},
|
||||
{"invalid CIDR", "a", 0, false, false},
|
||||
{"invalid CIDR missing decimal points in IPv4 address and / mask", "1234", 0, false, false},
|
||||
{"invalid CIDR use of letters instead of numbers and / mask", "abc", 0, false, false},
|
||||
{"invalid IPv4 address provided instead of CIDR representation", "1.2.3.4", 0, false, false},
|
||||
{"invalid IPv6 address provided instead of CIDR representation", "2001:db8::1", 0, false, false},
|
||||
{"invalid multiple CIDR provided in a single stack cluster", "2001:db8::1/64,1.2.3.4/24", 0, false, false},
|
||||
{"invalid multiple CIDR provided in a single stack cluster and one invalid subnet", "2001:db8::1/64,a", 0, false, false},
|
||||
{"valid, but IPv4 CIDR too small. At least 10 addresses needed", "10.0.0.16/29", 10, false, false},
|
||||
{"valid, but IPv6 CIDR too small. At least 10 addresses needed", "2001:db8::/125", 10, false, false},
|
||||
{"valid IPv4 CIDR", "10.0.0.16/12", 10, false, true},
|
||||
{"valid IPv6 CIDR", "2001:db8::/98", 10, false, true},
|
||||
// dual-stack:
|
||||
{"invalid missing CIDR", "", 0, true, false},
|
||||
{"valid dual-stack enabled but only an IPv4 CIDR specified", "10.0.0.16/12", 10, true, true},
|
||||
{"valid dual-stack enabled but only an IPv6 CIDR specified", "2001:db8::/98", 10, true, true},
|
||||
{"invalid IPv4 address provided instead of CIDR representation", "1.2.3.4,2001:db8::/98", 0, true, false},
|
||||
{"invalid IPv6 address provided instead of CIDR representation", "2001:db8::1,10.0.0.16/12", 0, true, false},
|
||||
{"valid, but IPv4 CIDR too small. At least 10 addresses needed", "10.0.0.16/29,2001:db8::/98", 10, true, false},
|
||||
{"valid, but IPv6 CIDR too small. At least 10 addresses needed", "10.0.0.16/12,2001:db8::/125", 10, true, false},
|
||||
{"valid, but only IPv4 family addresses specified. IPv6 CIDR is necessary.", "10.0.0.16/12,192.168.0.0/16", 10, true, false},
|
||||
{"valid, but only IPv6 family addresses specified. IPv4 CIDR is necessary.", "2001:db8::/98,2005:db8::/98", 10, true, false},
|
||||
{"valid IPv4 and IPv6 CIDR", "10.0.0.16/12,2001:db8::/98", 10, true, true},
|
||||
{"valid IPv6 and IPv4 CIDR", "10.0.0.16/12,2001:db8::/98", 10, true, true},
|
||||
{"invalid IPv6 and IPv4 CIDR with more than 2 subnets", "10.0.0.16/12,2001:db8::/98,192.168.0.0/16", 10, true, false},
|
||||
{"invalid IPv6 and IPv4 CIDR with more than 2 subnets", "10.0.0.16/12,2001:db8::/98,192.168.0.0/16,a.b.c.d/24", 10, true, false},
|
||||
{"invalid missing CIDR", "", 0, false},
|
||||
{"valid dual-stack enabled but only an IPv4 CIDR specified", "10.0.0.16/12", 10, true},
|
||||
{"valid dual-stack enabled but only an IPv6 CIDR specified", "2001:db8::/98", 10, true},
|
||||
{"invalid IPv4 address provided instead of CIDR representation", "1.2.3.4,2001:db8::/98", 0, false},
|
||||
{"invalid IPv6 address provided instead of CIDR representation", "2001:db8::1,10.0.0.16/12", 0, false},
|
||||
{"valid, but IPv4 CIDR too small. At least 10 addresses needed", "10.0.0.16/29,2001:db8::/98", 10, false},
|
||||
{"valid, but IPv6 CIDR too small. At least 10 addresses needed", "10.0.0.16/12,2001:db8::/125", 10, false},
|
||||
{"valid, but only IPv4 family addresses specified. IPv6 CIDR is necessary.", "10.0.0.16/12,192.168.0.0/16", 10, false},
|
||||
{"valid, but only IPv6 family addresses specified. IPv4 CIDR is necessary.", "2001:db8::/98,2005:db8::/98", 10, false},
|
||||
{"valid IPv4 and IPv6 CIDR", "10.0.0.16/12,2001:db8::/98", 10, true},
|
||||
{"valid IPv6 and IPv4 CIDR", "10.0.0.16/12,2001:db8::/98", 10, true},
|
||||
{"invalid IPv6 and IPv4 CIDR with more than 2 subnets", "10.0.0.16/12,2001:db8::/98,192.168.0.0/16", 10, false},
|
||||
{"invalid IPv6 and IPv4 CIDR with more than 2 subnets", "10.0.0.16/12,2001:db8::/98,192.168.0.0/16,a.b.c.d/24", 10, false},
|
||||
}
|
||||
for _, rt := range tests {
|
||||
actual := ValidateIPNetFromString(rt.subnet, rt.minaddrs, rt.checkDualStack, nil)
|
||||
actual := ValidateIPNetFromString(rt.subnet, rt.minaddrs, nil)
|
||||
if (len(actual) == 0) != rt.expected {
|
||||
t.Errorf(
|
||||
"%s test case failed :\n\texpected: %t\n\t actual: %t\n\t err(s): %v\n\t",
|
||||
@ -1137,55 +1124,6 @@ func TestGetClusterNodeMask(t *testing.T) {
|
||||
expectedMask int
|
||||
expectedError bool
|
||||
}{
|
||||
{
|
||||
name: "ipv4 default mask",
|
||||
cfg: &kubeadmapi.ClusterConfiguration{
|
||||
FeatureGates: map[string]bool{features.IPv6DualStack: false},
|
||||
},
|
||||
isIPv6: false,
|
||||
expectedMask: 24,
|
||||
},
|
||||
{
|
||||
name: "ipv4 custom mask",
|
||||
cfg: &kubeadmapi.ClusterConfiguration{
|
||||
FeatureGates: map[string]bool{features.IPv6DualStack: false},
|
||||
ControllerManager: kubeadmapi.ControlPlaneComponent{
|
||||
ExtraArgs: map[string]string{"node-cidr-mask-size": "23"},
|
||||
},
|
||||
},
|
||||
isIPv6: false,
|
||||
expectedMask: 23,
|
||||
},
|
||||
{
|
||||
name: "ipv4 wrong mask",
|
||||
cfg: &kubeadmapi.ClusterConfiguration{
|
||||
FeatureGates: map[string]bool{features.IPv6DualStack: false},
|
||||
ControllerManager: kubeadmapi.ControlPlaneComponent{
|
||||
ExtraArgs: map[string]string{"node-cidr-mask-size": "aa23"},
|
||||
},
|
||||
},
|
||||
isIPv6: false,
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "ipv6 default mask",
|
||||
cfg: &kubeadmapi.ClusterConfiguration{
|
||||
FeatureGates: map[string]bool{features.IPv6DualStack: false},
|
||||
},
|
||||
isIPv6: true,
|
||||
expectedMask: 64,
|
||||
},
|
||||
{
|
||||
name: "ipv6 custom mask",
|
||||
cfg: &kubeadmapi.ClusterConfiguration{
|
||||
FeatureGates: map[string]bool{features.IPv6DualStack: false},
|
||||
ControllerManager: kubeadmapi.ControlPlaneComponent{
|
||||
ExtraArgs: map[string]string{"node-cidr-mask-size": "83"},
|
||||
},
|
||||
},
|
||||
isIPv6: true,
|
||||
expectedMask: 83,
|
||||
},
|
||||
{
|
||||
name: "dual ipv4 default mask",
|
||||
cfg: &kubeadmapi.ClusterConfiguration{
|
||||
|
@ -525,7 +525,7 @@ func (d *initData) OutputWriter() io.Writer {
|
||||
func (d *initData) Client() (clientset.Interface, error) {
|
||||
if d.client == nil {
|
||||
if d.dryRun {
|
||||
svcSubnetCIDR, err := kubeadmconstants.GetKubernetesServiceCIDR(d.cfg.Networking.ServiceSubnet, features.Enabled(d.cfg.FeatureGates, features.IPv6DualStack))
|
||||
svcSubnetCIDR, err := kubeadmconstants.GetKubernetesServiceCIDR(d.cfg.Networking.ServiceSubnet)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to get internal Kubernetes Service IP from the given service CIDR (%s)", d.cfg.Networking.ServiceSubnet)
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ import (
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/features"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/util/initsystem"
|
||||
)
|
||||
|
||||
@ -117,12 +116,6 @@ 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 = kubeadmapiv1.DefaultManifestsDir
|
||||
} else if kc.config.StaticPodPath != kubeadmapiv1.DefaultManifestsDir {
|
||||
@ -130,7 +123,7 @@ func (kc *kubeletConfig) Default(cfg *kubeadmapi.ClusterConfiguration, _ *kubead
|
||||
}
|
||||
|
||||
clusterDNS := ""
|
||||
dnsIP, err := constants.GetDNSIP(cfg.Networking.ServiceSubnet, features.Enabled(cfg.FeatureGates, features.IPv6DualStack))
|
||||
dnsIP, err := constants.GetDNSIP(cfg.Networking.ServiceSubnet)
|
||||
if err != nil {
|
||||
clusterDNS = kubeadmapiv1.DefaultClusterDNSIP
|
||||
} else {
|
||||
|
@ -125,45 +125,6 @@ func TestKubeletDefault(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
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: kubeadmapiv1.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,
|
||||
CgroupDriver: constants.CgroupDriverSystemd,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Service subnet, enabled dual stack defaulting works",
|
||||
clusterCfg: kubeadmapi.ClusterConfiguration{
|
||||
|
@ -24,7 +24,6 @@ import (
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/features"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -118,10 +117,4 @@ func (kp *kubeProxyConfig) Default(cfg *kubeadmapi.ClusterConfiguration, localAP
|
||||
} else if kp.config.ClientConnection.Kubeconfig != kubeproxyKubeConfigFileName {
|
||||
warnDefaultComponentConfigValue(kind, "clientConnection.kubeconfig", kubeproxyKubeConfigFileName, kp.config.ClientConnection.Kubeconfig)
|
||||
}
|
||||
|
||||
// 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 {
|
||||
kp.config.FeatureGates[features.IPv6DualStack] = enabled
|
||||
}
|
||||
}
|
||||
|
@ -124,26 +124,6 @@ func TestKubeProxyDefault(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "IPv6DualStack feature gate set to false",
|
||||
clusterCfg: kubeadmapi.ClusterConfiguration{
|
||||
FeatureGates: map[string]bool{
|
||||
features.IPv6DualStack: false,
|
||||
},
|
||||
},
|
||||
endpoint: kubeadmapi.APIEndpoint{},
|
||||
expected: kubeProxyConfig{
|
||||
config: kubeproxyconfig.KubeProxyConfiguration{
|
||||
FeatureGates: map[string]bool{
|
||||
features.IPv6DualStack: false,
|
||||
},
|
||||
BindAddress: kubeadmapiv1.DefaultProxyBindAddressv6,
|
||||
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
|
||||
Kubeconfig: kubeproxyKubeConfigFileName,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
@ -627,9 +627,9 @@ func CreateTimestampDirForKubeadm(kubernetesDir, dirName string) (string, error)
|
||||
}
|
||||
|
||||
// GetDNSIP returns a dnsIP, which is 10th IP in svcSubnet CIDR range
|
||||
func GetDNSIP(svcSubnetList string, isDualStack bool) (net.IP, error) {
|
||||
func GetDNSIP(svcSubnetList string) (net.IP, error) {
|
||||
// Get the service subnet CIDR
|
||||
svcSubnetCIDR, err := GetKubernetesServiceCIDR(svcSubnetList, isDualStack)
|
||||
svcSubnetCIDR, err := GetKubernetesServiceCIDR(svcSubnetList)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to get internal Kubernetes Service IP from the given service CIDR (%s)", svcSubnetList)
|
||||
}
|
||||
@ -644,31 +644,23 @@ func GetDNSIP(svcSubnetList string, isDualStack bool) (net.IP, error) {
|
||||
}
|
||||
|
||||
// GetKubernetesServiceCIDR returns the default Service CIDR for the Kubernetes internal service
|
||||
func GetKubernetesServiceCIDR(svcSubnetList string, isDualStack bool) (*net.IPNet, error) {
|
||||
if isDualStack {
|
||||
// The default service address family for the cluster is the address family of the first
|
||||
// service cluster IP range configured via the `--service-cluster-ip-range` flag
|
||||
// of the kube-controller-manager and kube-apiserver.
|
||||
svcSubnets, err := netutils.ParseCIDRs(strings.Split(svcSubnetList, ","))
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to parse ServiceSubnet %v", svcSubnetList)
|
||||
}
|
||||
if len(svcSubnets) == 0 {
|
||||
return nil, errors.New("received empty ServiceSubnet for dual-stack")
|
||||
}
|
||||
return svcSubnets[0], nil
|
||||
}
|
||||
// internal IP address for the API server
|
||||
_, svcSubnet, err := netutils.ParseCIDRSloppy(svcSubnetList)
|
||||
func GetKubernetesServiceCIDR(svcSubnetList string) (*net.IPNet, error) {
|
||||
// The default service address family for the cluster is the address family of the first
|
||||
// service cluster IP range configured via the `--service-cluster-ip-range` flag
|
||||
// of the kube-controller-manager and kube-apiserver.
|
||||
svcSubnets, err := netutils.ParseCIDRs(strings.Split(svcSubnetList, ","))
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to parse ServiceSubnet %v", svcSubnetList)
|
||||
}
|
||||
return svcSubnet, nil
|
||||
if len(svcSubnets) == 0 {
|
||||
return nil, errors.New("received empty ServiceSubnet for dual-stack")
|
||||
}
|
||||
return svcSubnets[0], nil
|
||||
}
|
||||
|
||||
// GetAPIServerVirtualIP returns the IP of the internal Kubernetes API service
|
||||
func GetAPIServerVirtualIP(svcSubnetList string, isDualStack bool) (net.IP, error) {
|
||||
svcSubnet, err := GetKubernetesServiceCIDR(svcSubnetList, isDualStack)
|
||||
func GetAPIServerVirtualIP(svcSubnetList string) (net.IP, error) {
|
||||
svcSubnet, err := GetKubernetesServiceCIDR(svcSubnetList)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "unable to get internal Kubernetes Service IP from the given service CIDR")
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ import (
|
||||
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmconstants "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"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/util/apiclient"
|
||||
@ -120,7 +119,7 @@ func coreDNSAddon(cfg *kubeadmapi.ClusterConfiguration, client clientset.Interfa
|
||||
return errors.Wrap(err, "error when parsing CoreDNS configMap template")
|
||||
}
|
||||
|
||||
dnsip, err := kubeadmconstants.GetDNSIP(cfg.Networking.ServiceSubnet, features.Enabled(cfg.FeatureGates, features.IPv6DualStack))
|
||||
dnsip, err := kubeadmconstants.GetDNSIP(cfg.Networking.ServiceSubnet)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -220,12 +220,6 @@ func getAPIServerCommand(cfg *kubeadmapi.ClusterConfiguration, localAPIEndpoint
|
||||
}
|
||||
}
|
||||
|
||||
// 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 {
|
||||
defaultArguments["feature-gates"] = fmt.Sprintf("%s=%t", features.IPv6DualStack, enabled)
|
||||
}
|
||||
|
||||
if cfg.APIServer.ExtraArgs == nil {
|
||||
cfg.APIServer.ExtraArgs = map[string]string{}
|
||||
}
|
||||
@ -343,13 +337,6 @@ func getControllerManagerCommand(cfg *kubeadmapi.ClusterConfiguration) []string
|
||||
defaultArguments["cluster-name"] = cfg.ClusterName
|
||||
}
|
||||
|
||||
// TODO: The following code should be remvoved 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.
|
||||
enabled, present := cfg.FeatureGates[features.IPv6DualStack]
|
||||
if present {
|
||||
defaultArguments["feature-gates"] = fmt.Sprintf("%s=%t", features.IPv6DualStack, enabled)
|
||||
}
|
||||
|
||||
command := []string{"kube-controller-manager"}
|
||||
command = append(command, kubeadmutil.BuildArgumentListFromMap(defaultArguments, cfg.ControllerManager.ExtraArgs)...)
|
||||
|
||||
@ -368,12 +355,6 @@ func getSchedulerCommand(cfg *kubeadmapi.ClusterConfiguration) []string {
|
||||
"authorization-kubeconfig": kubeconfigFile,
|
||||
}
|
||||
|
||||
// TODO: The following code should be remvoved 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 {
|
||||
defaultArguments["feature-gates"] = fmt.Sprintf("%s=%t", features.IPv6DualStack, enabled)
|
||||
}
|
||||
|
||||
command := []string{"kube-scheduler"}
|
||||
command = append(command, kubeadmutil.BuildArgumentListFromMap(defaultArguments, cfg.Scheduler.ExtraArgs)...)
|
||||
return command
|
||||
|
@ -540,33 +540,6 @@ func TestGetControllerManagerCommand(t *testing.T) {
|
||||
cfg *kubeadmapi.ClusterConfiguration
|
||||
expected []string
|
||||
}{
|
||||
{
|
||||
name: "custom cluster name for " + cpVersion,
|
||||
cfg: &kubeadmapi.ClusterConfiguration{
|
||||
KubernetesVersion: cpVersion,
|
||||
CertificatesDir: testCertsDir,
|
||||
ClusterName: "some-other-cluster-name",
|
||||
FeatureGates: map[string]bool{features.IPv6DualStack: false},
|
||||
},
|
||||
expected: []string{
|
||||
"kube-controller-manager",
|
||||
"--bind-address=127.0.0.1",
|
||||
"--leader-elect=true",
|
||||
"--kubeconfig=" + kubeadmconstants.KubernetesDir + "/controller-manager.conf",
|
||||
"--root-ca-file=" + testCertsDir + "/ca.crt",
|
||||
"--service-account-private-key-file=" + testCertsDir + "/sa.key",
|
||||
"--cluster-signing-cert-file=" + testCertsDir + "/ca.crt",
|
||||
"--cluster-signing-key-file=" + testCertsDir + "/ca.key",
|
||||
"--use-service-account-credentials=true",
|
||||
"--controllers=*,bootstrapsigner,tokencleaner",
|
||||
"--authentication-kubeconfig=" + kubeadmconstants.KubernetesDir + "/controller-manager.conf",
|
||||
"--authorization-kubeconfig=" + kubeadmconstants.KubernetesDir + "/controller-manager.conf",
|
||||
"--client-ca-file=" + testCertsDir + "/ca.crt",
|
||||
"--requestheader-client-ca-file=" + testCertsDir + "/front-proxy-ca.crt",
|
||||
"--feature-gates=IPv6DualStack=false",
|
||||
"--cluster-name=some-other-cluster-name",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "custom certs dir for " + cpVersion,
|
||||
cfg: &kubeadmapi.ClusterConfiguration{
|
||||
@ -626,7 +599,7 @@ func TestGetControllerManagerCommand(t *testing.T) {
|
||||
},
|
||||
CertificatesDir: testCertsDir,
|
||||
KubernetesVersion: cpVersion,
|
||||
FeatureGates: map[string]bool{features.IPv6DualStack: false},
|
||||
FeatureGates: map[string]bool{features.IPv6DualStack: true},
|
||||
},
|
||||
expected: []string{
|
||||
"kube-controller-manager",
|
||||
@ -643,7 +616,7 @@ func TestGetControllerManagerCommand(t *testing.T) {
|
||||
"--authorization-kubeconfig=" + kubeadmconstants.KubernetesDir + "/controller-manager.conf",
|
||||
"--client-ca-file=" + testCertsDir + "/ca.crt",
|
||||
"--requestheader-client-ca-file=" + testCertsDir + "/front-proxy-ca.crt",
|
||||
"--feature-gates=IPv6DualStack=false",
|
||||
"--feature-gates=IPv6DualStack=true",
|
||||
"--allocate-node-cidrs=true",
|
||||
"--cluster-cidr=10.0.1.15/16",
|
||||
"--service-cluster-ip-range=172.20.0.0/24",
|
||||
|
@ -45,7 +45,6 @@ import (
|
||||
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/features"
|
||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||
)
|
||||
|
||||
@ -424,7 +423,7 @@ func GetAPIServerAltNames(cfg *kubeadmapi.InitConfiguration) (*certutil.AltNames
|
||||
cfg.LocalAPIEndpoint.AdvertiseAddress)
|
||||
}
|
||||
|
||||
internalAPIServerVirtualIP, err := kubeadmconstants.GetAPIServerVirtualIP(cfg.Networking.ServiceSubnet, features.Enabled(cfg.FeatureGates, features.IPv6DualStack))
|
||||
internalAPIServerVirtualIP, err := kubeadmconstants.GetAPIServerVirtualIP(cfg.Networking.ServiceSubnet)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to get first IP address from the given CIDR: %v", cfg.Networking.ServiceSubnet)
|
||||
}
|
||||
|
@ -265,8 +265,8 @@ func TestCmdInitFeatureGates(t *testing.T) {
|
||||
args: "",
|
||||
},
|
||||
{
|
||||
name: "feature gate IPv6DualStack=false",
|
||||
args: "--feature-gates=IPv6DualStack=false",
|
||||
name: "feature gate IPv6DualStack=true",
|
||||
args: "--feature-gates=IPv6DualStack=true",
|
||||
},
|
||||
{
|
||||
name: "feature gate PublicKeysECDSA=true",
|
||||
|
Loading…
Reference in New Issue
Block a user