mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
kubeadm: fix unit tests for v1beta1 removal
This commit is contained in:
parent
02b455b565
commit
c2bddf3998
@ -379,14 +379,14 @@ func TestGenCSRConfig(t *testing.T) {
|
|||||||
// A minimal kubeadm config with just enough values to avoid triggering
|
// A minimal kubeadm config with just enough values to avoid triggering
|
||||||
// auto-detection of config values at runtime.
|
// auto-detection of config values at runtime.
|
||||||
var kubeadmConfig = `
|
var kubeadmConfig = `
|
||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
kind: InitConfiguration
|
kind: InitConfiguration
|
||||||
localAPIEndpoint:
|
localAPIEndpoint:
|
||||||
advertiseAddress: 192.0.2.1
|
advertiseAddress: 192.0.2.1
|
||||||
nodeRegistration:
|
nodeRegistration:
|
||||||
criSocket: /path/to/dockershim.sock
|
criSocket: /path/to/dockershim.sock
|
||||||
---
|
---
|
||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
kind: ClusterConfiguration
|
kind: ClusterConfiguration
|
||||||
certificatesDir: /custom/config/certificates-dir
|
certificatesDir: /custom/config/certificates-dir
|
||||||
kubernetesVersion: ` + kubeadmconstants.MinimumControlPlaneVersion.String()
|
kubernetesVersion: ` + kubeadmconstants.MinimumControlPlaneVersion.String()
|
||||||
|
@ -81,7 +81,7 @@ func TestImagesListRunWithCustomConfigPath(t *testing.T) {
|
|||||||
constants.CurrentKubernetesVersion.String(),
|
constants.CurrentKubernetesVersion.String(),
|
||||||
},
|
},
|
||||||
configContents: []byte(dedent.Dedent(fmt.Sprintf(`
|
configContents: []byte(dedent.Dedent(fmt.Sprintf(`
|
||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
kind: ClusterConfiguration
|
kind: ClusterConfiguration
|
||||||
kubernetesVersion: %s
|
kubernetesVersion: %s
|
||||||
`, constants.CurrentKubernetesVersion))),
|
`, constants.CurrentKubernetesVersion))),
|
||||||
@ -93,7 +93,7 @@ func TestImagesListRunWithCustomConfigPath(t *testing.T) {
|
|||||||
"coredns",
|
"coredns",
|
||||||
},
|
},
|
||||||
configContents: []byte(dedent.Dedent(fmt.Sprintf(`
|
configContents: []byte(dedent.Dedent(fmt.Sprintf(`
|
||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
kind: ClusterConfiguration
|
kind: ClusterConfiguration
|
||||||
kubernetesVersion: %s
|
kubernetesVersion: %s
|
||||||
`, constants.MinimumControlPlaneVersion))),
|
`, constants.MinimumControlPlaneVersion))),
|
||||||
@ -384,7 +384,7 @@ func TestImagesPull(t *testing.T) {
|
|||||||
func TestMigrate(t *testing.T) {
|
func TestMigrate(t *testing.T) {
|
||||||
cfg := []byte(dedent.Dedent(`
|
cfg := []byte(dedent.Dedent(`
|
||||||
# This is intentionally testing an old API version. Sometimes this may be the latest version (if no old configs are supported).
|
# This is intentionally testing an old API version. Sometimes this may be the latest version (if no old configs are supported).
|
||||||
apiVersion: kubeadm.k8s.io/v1beta1
|
apiVersion: kubeadm.k8s.io/v1beta2
|
||||||
kind: InitConfiguration
|
kind: InitConfiguration
|
||||||
`))
|
`))
|
||||||
configFile, cleanup := tempConfig(t, cfg)
|
configFile, cleanup := tempConfig(t, cfg)
|
||||||
|
@ -28,7 +28,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
testInitConfig = `---
|
testInitConfig = `---
|
||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
kind: InitConfiguration
|
kind: InitConfiguration
|
||||||
localAPIEndpoint:
|
localAPIEndpoint:
|
||||||
advertiseAddress: "1.2.3.4"
|
advertiseAddress: "1.2.3.4"
|
||||||
@ -41,7 +41,7 @@ nodeRegistration:
|
|||||||
- c
|
- c
|
||||||
- d
|
- d
|
||||||
---
|
---
|
||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
kind: ClusterConfiguration
|
kind: ClusterConfiguration
|
||||||
controlPlaneEndpoint: "3.4.5.6"
|
controlPlaneEndpoint: "3.4.5.6"
|
||||||
`
|
`
|
||||||
|
@ -28,7 +28,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
testJoinConfig = `apiVersion: kubeadm.k8s.io/v1beta2
|
testJoinConfig = `apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
kind: JoinConfiguration
|
kind: JoinConfiguration
|
||||||
discovery:
|
discovery:
|
||||||
bootstrapToken:
|
bootstrapToken:
|
||||||
|
@ -43,7 +43,7 @@ func TestRunDiff(t *testing.T) {
|
|||||||
currentVersion := "v" + constants.CurrentKubernetesVersion.String()
|
currentVersion := "v" + constants.CurrentKubernetesVersion.String()
|
||||||
|
|
||||||
// create a temporary file with valid ClusterConfiguration
|
// create a temporary file with valid ClusterConfiguration
|
||||||
testUpgradeDiffConfigContents := []byte("apiVersion: kubeadm.k8s.io/v1beta2\n" +
|
testUpgradeDiffConfigContents := []byte("apiVersion: kubeadm.k8s.io/v1beta3\n" +
|
||||||
"kind: ClusterConfiguration\n" +
|
"kind: ClusterConfiguration\n" +
|
||||||
"kubernetesVersion: " + currentVersion)
|
"kubernetesVersion: " + currentVersion)
|
||||||
testUpgradeDiffConfig, err := createTestRunDiffFile(testUpgradeDiffConfigContents)
|
testUpgradeDiffConfig, err := createTestRunDiffFile(testUpgradeDiffConfigContents)
|
||||||
|
@ -33,7 +33,7 @@ import (
|
|||||||
clientsetfake "k8s.io/client-go/kubernetes/fake"
|
clientsetfake "k8s.io/client-go/kubernetes/fake"
|
||||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||||
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
||||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||||
outputapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/output"
|
outputapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/output"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||||
@ -206,7 +206,7 @@ var (
|
|||||||
yaml: dedent.Dedent(`
|
yaml: dedent.Dedent(`
|
||||||
apiServer:
|
apiServer:
|
||||||
timeoutForControlPlane: 4m
|
timeoutForControlPlane: 4m
|
||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
certificatesDir: /etc/kubernetes/pki
|
certificatesDir: /etc/kubernetes/pki
|
||||||
clusterName: LeCluster
|
clusterName: LeCluster
|
||||||
controllerManager: {}
|
controllerManager: {}
|
||||||
@ -277,7 +277,7 @@ func TestConfigBaseMarshal(t *testing.T) {
|
|||||||
got := strings.TrimSpace(string(b))
|
got := strings.TrimSpace(string(b))
|
||||||
expected := strings.TrimSpace(dedent.Dedent(`
|
expected := strings.TrimSpace(dedent.Dedent(`
|
||||||
apiServer: {}
|
apiServer: {}
|
||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
clusterName: LeCluster
|
clusterName: LeCluster
|
||||||
controllerManager: {}
|
controllerManager: {}
|
||||||
dns:
|
dns:
|
||||||
@ -327,7 +327,7 @@ func TestConfigBaseUnmarshal(t *testing.T) {
|
|||||||
func TestGeneratedConfigFromCluster(t *testing.T) {
|
func TestGeneratedConfigFromCluster(t *testing.T) {
|
||||||
fakeKnownContext(func() {
|
fakeKnownContext(func() {
|
||||||
testYAML := dedent.Dedent(`
|
testYAML := dedent.Dedent(`
|
||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
kind: ClusterConfiguration
|
kind: ClusterConfiguration
|
||||||
`)
|
`)
|
||||||
testYAMLHash := fmt.Sprintf("sha256:%x", sha256.Sum256([]byte(testYAML)))
|
testYAMLHash := fmt.Sprintf("sha256:%x", sha256.Sum256([]byte(testYAML)))
|
||||||
@ -406,7 +406,7 @@ func runClusterConfigFromTest(t *testing.T, perform func(t *testing.T, in string
|
|||||||
{
|
{
|
||||||
name: "Unknown kind returns an error",
|
name: "Unknown kind returns an error",
|
||||||
in: dedent.Dedent(`
|
in: dedent.Dedent(`
|
||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
kind: Configuration
|
kind: Configuration
|
||||||
`),
|
`),
|
||||||
expectErr: true,
|
expectErr: true,
|
||||||
|
@ -55,7 +55,7 @@ const (
|
|||||||
waitForPodsWithLabel = "wait-for-pods-with-label"
|
waitForPodsWithLabel = "wait-for-pods-with-label"
|
||||||
|
|
||||||
testConfiguration = `
|
testConfiguration = `
|
||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
kind: InitConfiguration
|
kind: InitConfiguration
|
||||||
nodeRegistration:
|
nodeRegistration:
|
||||||
name: foo
|
name: foo
|
||||||
@ -67,7 +67,7 @@ bootstrapTokens:
|
|||||||
- token: ce3aa5.5ec8455bb76b379f
|
- token: ce3aa5.5ec8455bb76b379f
|
||||||
ttl: 24h
|
ttl: 24h
|
||||||
---
|
---
|
||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
kind: ClusterConfiguration
|
kind: ClusterConfiguration
|
||||||
|
|
||||||
apiServer:
|
apiServer:
|
||||||
|
@ -46,15 +46,6 @@ var k8sVersionString = kubeadmconstants.MinimumControlPlaneVersion.String()
|
|||||||
var k8sVersion = version.MustParseGeneric(k8sVersionString)
|
var k8sVersion = version.MustParseGeneric(k8sVersionString)
|
||||||
var nodeName = "mynode"
|
var nodeName = "mynode"
|
||||||
var cfgFiles = map[string][]byte{
|
var cfgFiles = map[string][]byte{
|
||||||
"InitConfiguration_v1beta1": []byte(`
|
|
||||||
apiVersion: kubeadm.k8s.io/v1beta1
|
|
||||||
kind: InitConfiguration
|
|
||||||
`),
|
|
||||||
"ClusterConfiguration_v1beta1": []byte(`
|
|
||||||
apiVersion: kubeadm.k8s.io/v1beta1
|
|
||||||
kind: ClusterConfiguration
|
|
||||||
kubernetesVersion: ` + k8sVersionString + `
|
|
||||||
`),
|
|
||||||
"InitConfiguration_v1beta2": []byte(`
|
"InitConfiguration_v1beta2": []byte(`
|
||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta2
|
||||||
kind: InitConfiguration
|
kind: InitConfiguration
|
||||||
@ -63,6 +54,15 @@ kind: InitConfiguration
|
|||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta2
|
||||||
kind: ClusterConfiguration
|
kind: ClusterConfiguration
|
||||||
kubernetesVersion: ` + k8sVersionString + `
|
kubernetesVersion: ` + k8sVersionString + `
|
||||||
|
`),
|
||||||
|
"InitConfiguration_v1beta3": []byte(`
|
||||||
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
|
kind: InitConfiguration
|
||||||
|
`),
|
||||||
|
"ClusterConfiguration_v1beta3": []byte(`
|
||||||
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
|
kind: ClusterConfiguration
|
||||||
|
kubernetesVersion: ` + k8sVersionString + `
|
||||||
`),
|
`),
|
||||||
"Kube-proxy_componentconfig": []byte(`
|
"Kube-proxy_componentconfig": []byte(`
|
||||||
apiVersion: kubeproxy.config.k8s.io/v1alpha1
|
apiVersion: kubeproxy.config.k8s.io/v1alpha1
|
||||||
@ -541,83 +541,6 @@ func TestGetInitConfigurationFromCluster(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedError: true,
|
expectedError: true,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "valid v1beta1 - new control plane == false", // InitConfiguration composed with data from different places, with also node specific information from ClusterStatus and node
|
|
||||||
staticPods: []testresources.FakeStaticPod{
|
|
||||||
{
|
|
||||||
NodeName: nodeName,
|
|
||||||
Component: kubeadmconstants.KubeAPIServer,
|
|
||||||
Annotations: map[string]string{
|
|
||||||
kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
configMaps: []testresources.FakeConfigMap{
|
|
||||||
{
|
|
||||||
Name: kubeadmconstants.KubeadmConfigConfigMap, // ClusterConfiguration from kubeadm-config.
|
|
||||||
Data: map[string]string{
|
|
||||||
kubeadmconstants.ClusterConfigurationConfigMapKey: string(cfgFiles["ClusterConfiguration_v1beta1"]),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: kubeadmconstants.KubeProxyConfigMap, // Kube-proxy component config from corresponding ConfigMap.
|
|
||||||
Data: map[string]string{
|
|
||||||
kubeadmconstants.KubeProxyConfigMapKey: string(cfgFiles["Kube-proxy_componentconfig"]),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: kubeadmconstants.GetKubeletConfigMapName(k8sVersion), // Kubelet component config from corresponding ConfigMap.
|
|
||||||
Data: map[string]string{
|
|
||||||
kubeadmconstants.KubeletBaseConfigurationConfigMapKey: string(cfgFiles["Kubelet_componentconfig"]),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
fileContents: kubeletConfFiles["configWithEmbeddedCert"],
|
|
||||||
node: &v1.Node{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: nodeName,
|
|
||||||
Annotations: map[string]string{
|
|
||||||
kubeadmconstants.AnnotationKubeadmCRISocket: "myCRIsocket",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Spec: v1.NodeSpec{
|
|
||||||
Taints: []v1.Taint{kubeadmconstants.OldControlPlaneTaint},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "valid v1beta1 - new control plane == true", // InitConfiguration composed with data from different places, without node specific information
|
|
||||||
staticPods: []testresources.FakeStaticPod{
|
|
||||||
{
|
|
||||||
NodeName: nodeName,
|
|
||||||
Component: kubeadmconstants.KubeAPIServer,
|
|
||||||
Annotations: map[string]string{
|
|
||||||
kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
configMaps: []testresources.FakeConfigMap{
|
|
||||||
{
|
|
||||||
Name: kubeadmconstants.KubeadmConfigConfigMap, // ClusterConfiguration from kubeadm-config.
|
|
||||||
Data: map[string]string{
|
|
||||||
kubeadmconstants.ClusterConfigurationConfigMapKey: string(cfgFiles["ClusterConfiguration_v1beta1"]),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: kubeadmconstants.KubeProxyConfigMap, // Kube-proxy component config from corresponding ConfigMap.
|
|
||||||
Data: map[string]string{
|
|
||||||
kubeadmconstants.KubeProxyConfigMapKey: string(cfgFiles["Kube-proxy_componentconfig"]),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: kubeadmconstants.GetKubeletConfigMapName(k8sVersion), // Kubelet component config from corresponding ConfigMap.
|
|
||||||
Data: map[string]string{
|
|
||||||
kubeadmconstants.KubeletBaseConfigurationConfigMapKey: string(cfgFiles["Kubelet_componentconfig"]),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
newControlPlane: true,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "valid v1beta2 - new control plane == false", // InitConfiguration composed with data from different places, with also node specific information from ClusterStatus and node
|
name: "valid v1beta2 - new control plane == false", // InitConfiguration composed with data from different places, with also node specific information from ClusterStatus and node
|
||||||
staticPods: []testresources.FakeStaticPod{
|
staticPods: []testresources.FakeStaticPod{
|
||||||
@ -695,6 +618,83 @@ func TestGetInitConfigurationFromCluster(t *testing.T) {
|
|||||||
},
|
},
|
||||||
newControlPlane: true,
|
newControlPlane: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "valid v1beta3 - new control plane == false", // InitConfiguration composed with data from different places, with also node specific information from ClusterStatus and node
|
||||||
|
staticPods: []testresources.FakeStaticPod{
|
||||||
|
{
|
||||||
|
NodeName: nodeName,
|
||||||
|
Component: kubeadmconstants.KubeAPIServer,
|
||||||
|
Annotations: map[string]string{
|
||||||
|
kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
configMaps: []testresources.FakeConfigMap{
|
||||||
|
{
|
||||||
|
Name: kubeadmconstants.KubeadmConfigConfigMap, // ClusterConfiguration from kubeadm-config.
|
||||||
|
Data: map[string]string{
|
||||||
|
kubeadmconstants.ClusterConfigurationConfigMapKey: string(cfgFiles["ClusterConfiguration_v1beta3"]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: kubeadmconstants.KubeProxyConfigMap, // Kube-proxy component config from corresponding ConfigMap.
|
||||||
|
Data: map[string]string{
|
||||||
|
kubeadmconstants.KubeProxyConfigMapKey: string(cfgFiles["Kube-proxy_componentconfig"]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: kubeadmconstants.GetKubeletConfigMapName(k8sVersion), // Kubelet component config from corresponding ConfigMap.
|
||||||
|
Data: map[string]string{
|
||||||
|
kubeadmconstants.KubeletBaseConfigurationConfigMapKey: string(cfgFiles["Kubelet_componentconfig"]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fileContents: kubeletConfFiles["configWithEmbeddedCert"],
|
||||||
|
node: &v1.Node{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: nodeName,
|
||||||
|
Annotations: map[string]string{
|
||||||
|
kubeadmconstants.AnnotationKubeadmCRISocket: "myCRIsocket",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Spec: v1.NodeSpec{
|
||||||
|
Taints: []v1.Taint{kubeadmconstants.OldControlPlaneTaint},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "valid v1beta3 - new control plane == true", // InitConfiguration composed with data from different places, without node specific information
|
||||||
|
staticPods: []testresources.FakeStaticPod{
|
||||||
|
{
|
||||||
|
NodeName: nodeName,
|
||||||
|
Component: kubeadmconstants.KubeAPIServer,
|
||||||
|
Annotations: map[string]string{
|
||||||
|
kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
configMaps: []testresources.FakeConfigMap{
|
||||||
|
{
|
||||||
|
Name: kubeadmconstants.KubeadmConfigConfigMap, // ClusterConfiguration from kubeadm-config.
|
||||||
|
Data: map[string]string{
|
||||||
|
kubeadmconstants.ClusterConfigurationConfigMapKey: string(cfgFiles["ClusterConfiguration_v1beta3"]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: kubeadmconstants.KubeProxyConfigMap, // Kube-proxy component config from corresponding ConfigMap.
|
||||||
|
Data: map[string]string{
|
||||||
|
kubeadmconstants.KubeProxyConfigMapKey: string(cfgFiles["Kube-proxy_componentconfig"]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: kubeadmconstants.GetKubeletConfigMapName(k8sVersion), // Kubelet component config from corresponding ConfigMap.
|
||||||
|
Data: map[string]string{
|
||||||
|
kubeadmconstants.KubeletBaseConfigurationConfigMapKey: string(cfgFiles["Kubelet_componentconfig"]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
newControlPlane: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, rt := range tests {
|
for _, rt := range tests {
|
||||||
@ -773,17 +773,6 @@ func TestGetGetClusterStatus(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "invalid missing config map",
|
name: "invalid missing config map",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "valid v1beta1",
|
|
||||||
configMaps: []testresources.FakeConfigMap{
|
|
||||||
{
|
|
||||||
Name: kubeadmconstants.KubeadmConfigConfigMap,
|
|
||||||
Data: map[string]string{
|
|
||||||
kubeadmconstants.ClusterStatusConfigMapKey: string(cfgFiles["ClusterStatus_v1beta1"]),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "valid v1beta2",
|
name: "valid v1beta2",
|
||||||
configMaps: []testresources.FakeConfigMap{
|
configMaps: []testresources.FakeConfigMap{
|
||||||
@ -795,6 +784,17 @@ func TestGetGetClusterStatus(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "valid v1beta3",
|
||||||
|
configMaps: []testresources.FakeConfigMap{
|
||||||
|
{
|
||||||
|
Name: kubeadmconstants.KubeadmConfigConfigMap,
|
||||||
|
Data: map[string]string{
|
||||||
|
kubeadmconstants.ClusterStatusConfigMapKey: string(cfgFiles["ClusterStatus_v1beta3"]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "invalid missing ClusterStatusConfigMapKey in the config map",
|
name: "invalid missing ClusterStatusConfigMapKey in the config map",
|
||||||
configMaps: []testresources.FakeConfigMap{
|
configMaps: []testresources.FakeConfigMap{
|
||||||
|
@ -56,16 +56,16 @@ func validateSupportedVersion(gv schema.GroupVersion, allowDeprecated bool) erro
|
|||||||
// v1.13: v1alpha3 read-only, writes only v1beta1 config. Errors if the user tries to use v1alpha1 or v1alpha2
|
// v1.13: v1alpha3 read-only, writes only v1beta1 config. Errors if the user tries to use v1alpha1 or v1alpha2
|
||||||
// v1.14: v1alpha3 convert only, writes only v1beta1 config. Errors if the user tries to use v1alpha1 or v1alpha2
|
// v1.14: v1alpha3 convert only, writes only v1beta1 config. Errors if the user tries to use v1alpha1 or v1alpha2
|
||||||
// v1.15: v1beta1 read-only, writes only v1beta2 config. Errors if the user tries to use v1alpha1, v1alpha2 or v1alpha3
|
// v1.15: v1beta1 read-only, writes only v1beta2 config. Errors if the user tries to use v1alpha1, v1alpha2 or v1alpha3
|
||||||
|
// v1.22: v1beta2 read-only, writes only v1beta3 config. Errors if the user tries to use v1beta1 and older
|
||||||
oldKnownAPIVersions := map[string]string{
|
oldKnownAPIVersions := map[string]string{
|
||||||
"kubeadm.k8s.io/v1alpha1": "v1.11",
|
"kubeadm.k8s.io/v1alpha1": "v1.11",
|
||||||
"kubeadm.k8s.io/v1alpha2": "v1.12",
|
"kubeadm.k8s.io/v1alpha2": "v1.12",
|
||||||
"kubeadm.k8s.io/v1alpha3": "v1.14",
|
"kubeadm.k8s.io/v1alpha3": "v1.14",
|
||||||
|
"kubeadm.k8s.io/v1beta1": "v1.15",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated API versions are supported by us, but can only be used for migration.
|
// Deprecated API versions are supported by us, but can only be used for migration.
|
||||||
deprecatedAPIVersions := map[string]struct{}{
|
deprecatedAPIVersions := map[string]struct{}{}
|
||||||
"kubeadm.k8s.io/v1beta1": {},
|
|
||||||
}
|
|
||||||
|
|
||||||
gvString := gv.String()
|
gvString := gv.String()
|
||||||
|
|
||||||
|
@ -57,21 +57,12 @@ func TestValidateSupportedVersion(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedErr: true,
|
expectedErr: true,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
gv: schema.GroupVersion{
|
|
||||||
Group: KubeadmGroupName,
|
|
||||||
Version: "v1alpha3",
|
|
||||||
},
|
|
||||||
allowDeprecated: true,
|
|
||||||
expectedErr: true,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
gv: schema.GroupVersion{
|
gv: schema.GroupVersion{
|
||||||
Group: KubeadmGroupName,
|
Group: KubeadmGroupName,
|
||||||
Version: "v1beta1",
|
Version: "v1beta1",
|
||||||
},
|
},
|
||||||
allowDeprecated: true,
|
expectedErr: true,
|
||||||
expectedErr: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
gv: schema.GroupVersion{
|
gv: schema.GroupVersion{
|
||||||
@ -79,6 +70,12 @@ func TestValidateSupportedVersion(t *testing.T) {
|
|||||||
Version: "v1beta2",
|
Version: "v1beta2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
gv: schema.GroupVersion{
|
||||||
|
Group: KubeadmGroupName,
|
||||||
|
Version: "v1beta3",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
gv: schema.GroupVersion{
|
gv: schema.GroupVersion{
|
||||||
Group: "foo.k8s.io",
|
Group: "foo.k8s.io",
|
||||||
@ -213,7 +210,7 @@ func TestMigrateOldConfigFromFile(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "bad config produces error",
|
desc: "bad config produces error",
|
||||||
oldCfg: dedent.Dedent(`
|
oldCfg: dedent.Dedent(`
|
||||||
apiVersion: kubeadm.k8s.io/v1beta1
|
apiVersion: kubeadm.k8s.io/v1beta2
|
||||||
`),
|
`),
|
||||||
expectErr: true,
|
expectErr: true,
|
||||||
},
|
},
|
||||||
@ -341,13 +338,13 @@ func TestMigrateOldConfigFromFile(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "component configs are not migrated",
|
desc: "component configs are not migrated",
|
||||||
oldCfg: dedent.Dedent(`
|
oldCfg: dedent.Dedent(`
|
||||||
apiVersion: kubeadm.k8s.io/v1beta1
|
apiVersion: kubeadm.k8s.io/v1beta2
|
||||||
kind: InitConfiguration
|
kind: InitConfiguration
|
||||||
---
|
---
|
||||||
apiVersion: kubeadm.k8s.io/v1beta1
|
apiVersion: kubeadm.k8s.io/v1beta2
|
||||||
kind: ClusterConfiguration
|
kind: ClusterConfiguration
|
||||||
---
|
---
|
||||||
apiVersion: kubeadm.k8s.io/v1beta1
|
apiVersion: kubeadm.k8s.io/v1beta2
|
||||||
kind: JoinConfiguration
|
kind: JoinConfiguration
|
||||||
discovery:
|
discovery:
|
||||||
bootstrapToken:
|
bootstrapToken:
|
||||||
|
@ -23,9 +23,9 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
kubeadmapiv1beta3 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
)
|
)
|
||||||
@ -44,23 +44,6 @@ func TestLoadInitConfigurationFromFile(t *testing.T) {
|
|||||||
fileContents []byte
|
fileContents []byte
|
||||||
expectErr bool
|
expectErr bool
|
||||||
}{
|
}{
|
||||||
{
|
|
||||||
name: "v1beta1.partial1",
|
|
||||||
fileContents: cfgFiles["InitConfiguration_v1beta1"],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "v1beta1.partial2",
|
|
||||||
fileContents: cfgFiles["ClusterConfiguration_v1beta1"],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "v1beta1.full",
|
|
||||||
fileContents: bytes.Join([][]byte{
|
|
||||||
cfgFiles["InitConfiguration_v1beta1"],
|
|
||||||
cfgFiles["ClusterConfiguration_v1beta1"],
|
|
||||||
cfgFiles["Kube-proxy_componentconfig"],
|
|
||||||
cfgFiles["Kubelet_componentconfig"],
|
|
||||||
}, []byte(constants.YAMLDocumentSeparator)),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "v1beta2.partial1",
|
name: "v1beta2.partial1",
|
||||||
fileContents: cfgFiles["InitConfiguration_v1beta2"],
|
fileContents: cfgFiles["InitConfiguration_v1beta2"],
|
||||||
@ -78,6 +61,23 @@ func TestLoadInitConfigurationFromFile(t *testing.T) {
|
|||||||
cfgFiles["Kubelet_componentconfig"],
|
cfgFiles["Kubelet_componentconfig"],
|
||||||
}, []byte(constants.YAMLDocumentSeparator)),
|
}, []byte(constants.YAMLDocumentSeparator)),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "v1beta3.partial1",
|
||||||
|
fileContents: cfgFiles["InitConfiguration_v1beta3"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "v1beta3.partial2",
|
||||||
|
fileContents: cfgFiles["ClusterConfiguration_v1beta3"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "v1beta3.full",
|
||||||
|
fileContents: bytes.Join([][]byte{
|
||||||
|
cfgFiles["InitConfiguration_v1beta3"],
|
||||||
|
cfgFiles["ClusterConfiguration_v1beta3"],
|
||||||
|
cfgFiles["Kube-proxy_componentconfig"],
|
||||||
|
cfgFiles["Kubelet_componentconfig"],
|
||||||
|
}, []byte(constants.YAMLDocumentSeparator)),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, rt := range tests {
|
for _, rt := range tests {
|
||||||
@ -111,14 +111,14 @@ func TestLoadInitConfigurationFromFile(t *testing.T) {
|
|||||||
func TestDefaultTaintsMarshaling(t *testing.T) {
|
func TestDefaultTaintsMarshaling(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
desc string
|
desc string
|
||||||
cfg kubeadmapiv1beta2.InitConfiguration
|
cfg kubeadmapiv1beta3.InitConfiguration
|
||||||
expectedTaintCnt int
|
expectedTaintCnt int
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
desc: "Uninitialized nodeRegistration field produces a single taint (the master one)",
|
desc: "Uninitialized nodeRegistration field produces a single taint (the master one)",
|
||||||
cfg: kubeadmapiv1beta2.InitConfiguration{
|
cfg: kubeadmapiv1beta3.InitConfiguration{
|
||||||
TypeMeta: metav1.TypeMeta{
|
TypeMeta: metav1.TypeMeta{
|
||||||
APIVersion: "kubeadm.k8s.io/v1beta2",
|
APIVersion: "kubeadm.k8s.io/v1beta3",
|
||||||
Kind: constants.InitConfigurationKind,
|
Kind: constants.InitConfigurationKind,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -126,23 +126,23 @@ func TestDefaultTaintsMarshaling(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "Uninitialized taints field produces a single taint (the master one)",
|
desc: "Uninitialized taints field produces a single taint (the master one)",
|
||||||
cfg: kubeadmapiv1beta2.InitConfiguration{
|
cfg: kubeadmapiv1beta3.InitConfiguration{
|
||||||
TypeMeta: metav1.TypeMeta{
|
TypeMeta: metav1.TypeMeta{
|
||||||
APIVersion: "kubeadm.k8s.io/v1beta2",
|
APIVersion: "kubeadm.k8s.io/v1beta3",
|
||||||
Kind: constants.InitConfigurationKind,
|
Kind: constants.InitConfigurationKind,
|
||||||
},
|
},
|
||||||
NodeRegistration: kubeadmapiv1beta2.NodeRegistrationOptions{},
|
NodeRegistration: kubeadmapiv1beta3.NodeRegistrationOptions{},
|
||||||
},
|
},
|
||||||
expectedTaintCnt: 1,
|
expectedTaintCnt: 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "Forsing taints to an empty slice produces no taints",
|
desc: "Forsing taints to an empty slice produces no taints",
|
||||||
cfg: kubeadmapiv1beta2.InitConfiguration{
|
cfg: kubeadmapiv1beta3.InitConfiguration{
|
||||||
TypeMeta: metav1.TypeMeta{
|
TypeMeta: metav1.TypeMeta{
|
||||||
APIVersion: "kubeadm.k8s.io/v1beta2",
|
APIVersion: "kubeadm.k8s.io/v1beta3",
|
||||||
Kind: constants.InitConfigurationKind,
|
Kind: constants.InitConfigurationKind,
|
||||||
},
|
},
|
||||||
NodeRegistration: kubeadmapiv1beta2.NodeRegistrationOptions{
|
NodeRegistration: kubeadmapiv1beta3.NodeRegistrationOptions{
|
||||||
Taints: []v1.Taint{},
|
Taints: []v1.Taint{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -150,12 +150,12 @@ func TestDefaultTaintsMarshaling(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "Custom taints are used",
|
desc: "Custom taints are used",
|
||||||
cfg: kubeadmapiv1beta2.InitConfiguration{
|
cfg: kubeadmapiv1beta3.InitConfiguration{
|
||||||
TypeMeta: metav1.TypeMeta{
|
TypeMeta: metav1.TypeMeta{
|
||||||
APIVersion: "kubeadm.k8s.io/v1beta2",
|
APIVersion: "kubeadm.k8s.io/v1beta3",
|
||||||
Kind: constants.InitConfigurationKind,
|
Kind: constants.InitConfigurationKind,
|
||||||
},
|
},
|
||||||
NodeRegistration: kubeadmapiv1beta2.NodeRegistrationOptions{
|
NodeRegistration: kubeadmapiv1beta3.NodeRegistrationOptions{
|
||||||
Taints: []v1.Taint{
|
Taints: []v1.Taint{
|
||||||
{Key: "taint1"},
|
{Key: "taint1"},
|
||||||
{Key: "taint2"},
|
{Key: "taint2"},
|
||||||
|
@ -44,17 +44,17 @@ func TestLoadJoinConfigurationFromFile(t *testing.T) {
|
|||||||
expectErr: true,
|
expectErr: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Invalid v1beta1 causes error",
|
name: "Invalid v1beta2 causes error",
|
||||||
fileContents: dedent.Dedent(`
|
fileContents: dedent.Dedent(`
|
||||||
apiVersion: kubeadm.k8s.io/v1beta1
|
apiVersion: kubeadm.k8s.io/v1beta2
|
||||||
kind: JoinConfiguration
|
kind: JoinConfiguration
|
||||||
`),
|
`),
|
||||||
expectErr: true,
|
expectErr: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "valid v1beta1 is loaded",
|
name: "valid v1beta2 is loaded",
|
||||||
fileContents: dedent.Dedent(`
|
fileContents: dedent.Dedent(`
|
||||||
apiVersion: kubeadm.k8s.io/v1beta1
|
apiVersion: kubeadm.k8s.io/v1beta2
|
||||||
kind: JoinConfiguration
|
kind: JoinConfiguration
|
||||||
caCertPath: /etc/kubernetes/pki/ca.crt
|
caCertPath: /etc/kubernetes/pki/ca.crt
|
||||||
discovery:
|
discovery:
|
||||||
@ -67,17 +67,17 @@ func TestLoadJoinConfigurationFromFile(t *testing.T) {
|
|||||||
`),
|
`),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Invalid v1beta2 causes error",
|
name: "Invalid v1beta3 causes error",
|
||||||
fileContents: dedent.Dedent(`
|
fileContents: dedent.Dedent(`
|
||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
kind: JoinConfiguration
|
kind: JoinConfiguration
|
||||||
`),
|
`),
|
||||||
expectErr: true,
|
expectErr: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "valid v1beta2 is loaded",
|
name: "valid v1beta3 is loaded",
|
||||||
fileContents: dedent.Dedent(`
|
fileContents: dedent.Dedent(`
|
||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
kind: JoinConfiguration
|
kind: JoinConfiguration
|
||||||
caCertPath: /etc/kubernetes/pki/ca.crt
|
caCertPath: /etc/kubernetes/pki/ca.crt
|
||||||
discovery:
|
discovery:
|
||||||
|
@ -137,28 +137,13 @@ func TestCmdInitConfig(t *testing.T) {
|
|||||||
expected: false,
|
expected: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "can't load old v1alpha1 config",
|
name: "can't load v1beta1 config",
|
||||||
args: "--config=testdata/init/v1alpha1.yaml",
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "can't load old v1alpha2 config",
|
|
||||||
args: "--config=testdata/init/v1alpha2.yaml",
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "can't load old v1alpha3 config",
|
|
||||||
args: "--config=testdata/init/v1alpha3.yaml",
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "can load v1beta1 config",
|
|
||||||
args: "--config=testdata/init/v1beta1.yaml",
|
args: "--config=testdata/init/v1beta1.yaml",
|
||||||
expected: true,
|
expected: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "don't allow mixed arguments v1beta1",
|
name: "don't allow mixed arguments v1beta2",
|
||||||
args: "--kubernetes-version=1.11.0 --config=testdata/init/v1beta1.yaml",
|
args: "--kubernetes-version=1.11.0 --config=testdata/init/v1beta2.yaml",
|
||||||
expected: false,
|
expected: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -167,8 +152,13 @@ func TestCmdInitConfig(t *testing.T) {
|
|||||||
expected: true,
|
expected: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "don't allow mixed arguments v1beta2",
|
name: "can load v1beta3 config",
|
||||||
args: "--kubernetes-version=1.11.0 --config=testdata/init/v1beta2.yaml",
|
args: "--config=testdata/init/v1beta3.yaml",
|
||||||
|
expected: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "don't allow mixed arguments v1beta3",
|
||||||
|
args: "--kubernetes-version=1.11.0 --config=testdata/init/v1beta3.yaml",
|
||||||
expected: false,
|
expected: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
kind: ClusterConfiguration
|
kind: ClusterConfiguration
|
||||||
---
|
---
|
||||||
apiVersion: kubelet.config.k8s.io/v1beta1
|
apiVersion: kubelet.config.k8s.io/v1beta1
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
apiVersion: kubeadm.k8s.io/v1beta2
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
kind: ClusterConfiguration
|
kind: ClusterConfiguration
|
||||||
---
|
---
|
||||||
apiVersion: kubelet.config.k8s.io/v1alpha1
|
apiVersion: kubelet.config.k8s.io/v1alpha1
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
apiVersion: kubeadm.k8s.io/v1alpha1
|
|
||||||
kind: MasterConfiguration
|
|
@ -1,2 +0,0 @@
|
|||||||
apiVersion: kubeadm.k8s.io/v1alpha2
|
|
||||||
kind: MasterConfiguration
|
|
@ -1,2 +0,0 @@
|
|||||||
apiVersion: kubeadm.k8s.io/v1alpha3
|
|
||||||
kind: InitConfiguration
|
|
2
cmd/kubeadm/test/cmd/testdata/init/v1beta3.yaml
vendored
Normal file
2
cmd/kubeadm/test/cmd/testdata/init/v1beta3.yaml
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
apiVersion: kubeadm.k8s.io/v1beta3
|
||||||
|
kind: InitConfiguration
|
Loading…
Reference in New Issue
Block a user