From 6866460cfce5fb91da6453bb792e60b49effb814 Mon Sep 17 00:00:00 2001 From: Artiom Diomin Date: Fri, 12 Jan 2024 18:00:29 +0200 Subject: [PATCH 1/8] remove docker entirely --- pkg/apis/kubeone/config/config.go | 4 - pkg/apis/kubeone/helpers.go | 14 -- pkg/apis/kubeone/helpers_test.go | 77 ------- pkg/apis/kubeone/types.go | 9 - pkg/apis/kubeone/v1beta1/conversion.go | 9 +- .../v1beta1/zz_generated.conversion.go | 58 +----- pkg/apis/kubeone/v1beta2/conversion.go | 4 + .../v1beta2/zz_generated.conversion.go | 48 +---- pkg/apis/kubeone/validation/validation.go | 38 ---- .../kubeone/validation/validation_test.go | 59 ------ pkg/apis/kubeone/zz_generated.deepcopy.go | 26 --- pkg/cmd/apply.go | 9 - pkg/containerruntime/docker_config.go | 62 ------ pkg/containerruntime/docker_config_test.go | 98 --------- pkg/containerruntime/map.go | 2 - pkg/scripts/funcs.go | 5 +- pkg/scripts/os_amzn.go | 7 - pkg/scripts/os_centos.go | 7 - pkg/scripts/os_debian.go | 7 - pkg/scripts/os_flatcar.go | 15 -- pkg/scripts/os_test.go | 113 ++--------- pkg/scripts/render.go | 133 ++---------- ...teControlPlaneManifests-not-verbose.golden | 7 - ...nerateControlPlaneManifests-verbose.golden | 7 - ...tionUpdateKubeletConfig-not-verbose.golden | 4 - ...igrationUpdateKubeletConfig-verbose.golden | 4 - .../TestKubeadmAmazonLinux-force.golden | 57 +++--- ...beadmAmazonLinux-overwrite_registry.golden | 57 +++--- ...onLinux-overwrite_registry_insecure.golden | 189 ------------------ .../TestKubeadmAmazonLinux-proxy.golden | 57 +++--- .../TestKubeadmAmazonLinux-simple.golden | 186 ----------------- .../TestKubeadmAmazonLinux-v1.16.1.golden | 169 ---------------- .../TestKubeadmAmazonLinux-v1.23.9.golden | 174 ---------------- .../TestKubeadmAmazonLinux-v1.26.0.golden | 57 +++--- .../TestKubeadmAmazonLinux-with_cilium.golden | 2 - ...tKubeadmAmazonLinux-with_containerd.golden | 2 - ...h_containerd_with_insecure_registry.golden | 2 - .../TestKubeadmCentOS-cilium_cluster.golden | 2 - .../testdata/TestKubeadmCentOS-force.golden | 155 -------------- .../TestKubeadmCentOS-nutanix_cluster.golden | 2 - ...estKubeadmCentOS-overwrite_registry.golden | 154 -------------- ...mCentOS-overwrite_registry_insecure.golden | 157 --------------- .../testdata/TestKubeadmCentOS-proxy.golden | 154 -------------- .../testdata/TestKubeadmCentOS-simple.golden | 154 -------------- .../testdata/TestKubeadmCentOS-v1.16.1.golden | 135 ------------- .../TestKubeadmCentOS-with_containerd.golden | 2 - ...h_containerd_with_insecure_registry.golden | 2 - .../TestKubeadmDebian-cilium_cluster.golden | 2 - .../TestKubeadmDebian-nutanix_cluster.golden | 2 - ...estKubeadmDebian-overwrite_registry.golden | 142 ------------- ...mDebian-overwrite_registry_insecure.golden | 145 -------------- .../testdata/TestKubeadmDebian-simple.golden | 142 ------------- .../TestKubeadmDebian-with_containerd.golden | 2 - ...h_containerd_with_insecure_registry.golden | 2 - .../testdata/TestKubeadmFlatcar-force.golden | 58 +++--- ...stKubeadmFlatcar-overwrite_registry.golden | 58 +++--- ...Flatcar-overwrite_registry_insecure.golden | 145 -------------- .../testdata/TestKubeadmFlatcar-simple.golden | 142 ------------- .../TestKubeadmFlatcar-with_cilium.golden | 2 - .../TestKubeadmFlatcar-with_containerd.golden | 2 - ...h_containerd_with_insecure_registry.golden | 2 - ...TestUpgradeKubeadmAndCNIAmazonLinux.golden | 57 +++--- .../TestUpgradeKubeadmAndCNICentOS.golden | 61 +++--- .../TestUpgradeKubeadmAndCNIDebian.golden | 68 +++---- ...UpgradeKubeletAndKubectlAmazonLinux.golden | 57 +++--- .../TestUpgradeKubeletAndKubectlCentOS.golden | 61 +++--- .../TestUpgradeKubeletAndKubectlDebian.golden | 68 +++---- pkg/state/cluster.go | 15 +- pkg/tasks/probes.go | 34 +--- 69 files changed, 416 insertions(+), 3546 deletions(-) delete mode 100644 pkg/containerruntime/docker_config.go delete mode 100644 pkg/containerruntime/docker_config_test.go delete mode 100644 pkg/scripts/testdata/TestCCMMigrationRegenerateControlPlaneManifests-not-verbose.golden delete mode 100644 pkg/scripts/testdata/TestCCMMigrationRegenerateControlPlaneManifests-verbose.golden delete mode 100644 pkg/scripts/testdata/TestCCMMigrationUpdateKubeletConfig-not-verbose.golden delete mode 100644 pkg/scripts/testdata/TestCCMMigrationUpdateKubeletConfig-verbose.golden delete mode 100644 pkg/scripts/testdata/TestKubeadmAmazonLinux-overwrite_registry_insecure.golden delete mode 100644 pkg/scripts/testdata/TestKubeadmAmazonLinux-simple.golden delete mode 100644 pkg/scripts/testdata/TestKubeadmAmazonLinux-v1.16.1.golden delete mode 100644 pkg/scripts/testdata/TestKubeadmAmazonLinux-v1.23.9.golden delete mode 100644 pkg/scripts/testdata/TestKubeadmCentOS-force.golden delete mode 100644 pkg/scripts/testdata/TestKubeadmCentOS-overwrite_registry.golden delete mode 100644 pkg/scripts/testdata/TestKubeadmCentOS-overwrite_registry_insecure.golden delete mode 100644 pkg/scripts/testdata/TestKubeadmCentOS-proxy.golden delete mode 100644 pkg/scripts/testdata/TestKubeadmCentOS-simple.golden delete mode 100644 pkg/scripts/testdata/TestKubeadmCentOS-v1.16.1.golden delete mode 100644 pkg/scripts/testdata/TestKubeadmDebian-overwrite_registry.golden delete mode 100644 pkg/scripts/testdata/TestKubeadmDebian-overwrite_registry_insecure.golden delete mode 100644 pkg/scripts/testdata/TestKubeadmDebian-simple.golden delete mode 100644 pkg/scripts/testdata/TestKubeadmFlatcar-overwrite_registry_insecure.golden delete mode 100644 pkg/scripts/testdata/TestKubeadmFlatcar-simple.golden diff --git a/pkg/apis/kubeone/config/config.go b/pkg/apis/kubeone/config/config.go index ba7d2b058..03ced3458 100644 --- a/pkg/apis/kubeone/config/config.go +++ b/pkg/apis/kubeone/config/config.go @@ -348,10 +348,6 @@ func checkClusterFeatures(cluster kubeoneapi.KubeOneCluster, logger logrus.Field logger.Warnf("Nutanix support is planned to graduate to beta/stable in KubeOne 1.5+") } - if cluster.ContainerRuntime.Docker != nil { - logger.Warnf("Support for docker will be removed with Kubernetes 1.24 release. It is recommended to switch to containerd as container runtime using `kubeone migrate to-containerd`") - } - if cluster.CloudProvider.Vsphere != nil && !cluster.CloudProvider.External && len(cluster.CloudProvider.CSIConfig) > 0 { logger.Warnf(".cloudProvider.csiConfig is provided, but is ignored when used with the in-tree cloud provider") } diff --git a/pkg/apis/kubeone/helpers.go b/pkg/apis/kubeone/helpers.go index aa11c85fb..b49c2cf87 100644 --- a/pkg/apis/kubeone/helpers.go +++ b/pkg/apis/kubeone/helpers.go @@ -130,12 +130,6 @@ func (h *HostConfig) SetLeader(leader bool) { func (crc ContainerRuntimeConfig) MachineControllerFlags() []string { var mcFlags []string switch { - case crc.Docker != nil: - if len(crc.Docker.RegistryMirrors) > 0 { - mcFlags = append(mcFlags, - fmt.Sprintf("-node-registry-mirrors=%s", strings.Join(crc.Docker.RegistryMirrors, ",")), - ) - } case crc.Containerd != nil: // example output: // -node-containerd-registry-mirrors=docker.io=custom.tld @@ -199,8 +193,6 @@ func (crc ContainerRuntimeConfig) String() string { switch { case crc.Containerd != nil: return "containerd" - case crc.Docker != nil: - return "docker" } return "unknown" @@ -208,8 +200,6 @@ func (crc ContainerRuntimeConfig) String() string { func (crc *ContainerRuntimeConfig) UnmarshalText(text []byte) error { switch { - case bytes.Equal(text, []byte("docker")): - *crc = ContainerRuntimeConfig{Docker: &ContainerRuntimeDocker{}} case bytes.Equal(text, []byte("containerd")): *crc = ContainerRuntimeConfig{Containerd: &ContainerRuntimeContainerd{}} default: @@ -223,8 +213,6 @@ func (crc ContainerRuntimeConfig) ConfigPath() string { switch { case crc.Containerd != nil: return "/etc/containerd/config.toml" - case crc.Docker != nil: - return "/etc/docker/daemon.json" } return "" @@ -234,8 +222,6 @@ func (crc ContainerRuntimeConfig) CRISocket() string { switch { case crc.Containerd != nil: return "/run/containerd/containerd.sock" - case crc.Docker != nil: - return "/var/run/dockershim.sock" } return "" diff --git a/pkg/apis/kubeone/helpers_test.go b/pkg/apis/kubeone/helpers_test.go index 5ae351344..b254feb94 100644 --- a/pkg/apis/kubeone/helpers_test.go +++ b/pkg/apis/kubeone/helpers_test.go @@ -75,83 +75,6 @@ func TestFeatureGatesString(t *testing.T) { } } -func TestContainerRuntimeConfig_MachineControllerFlags(t *testing.T) { - type fields struct { - Docker *ContainerRuntimeDocker - Containerd *ContainerRuntimeContainerd - } - tests := []struct { - name string - fields fields - want []string - }{ - { - name: "docker empty", - fields: fields{ - Docker: &ContainerRuntimeDocker{}, - }, - }, - { - name: "docker with mirrors", - fields: fields{ - Docker: &ContainerRuntimeDocker{ - RegistryMirrors: []string{"my-registry", "other-registry"}, - }, - }, - want: []string{"-node-registry-mirrors=my-registry,other-registry"}, - }, - { - name: "containerd empty", - fields: fields{ - Containerd: &ContainerRuntimeContainerd{}, - }, - }, - { - name: "containerd with mirrors", - fields: fields{ - Containerd: &ContainerRuntimeContainerd{ - Registries: map[string]ContainerdRegistry{ - "docker.io": { - Mirrors: []string{ - "http://registry1", - "https://registry2", - "registry3", - }, - }, - "registry.k8s.io": { - Mirrors: []string{ - "https://insecure.registry", - }, - TLSConfig: &ContainerdTLSConfig{ - InsecureSkipVerify: true, - }, - }, - }, - }, - }, - want: []string{ - "-node-containerd-registry-mirrors=docker.io=http://registry1", - "-node-containerd-registry-mirrors=docker.io=https://registry2", - "-node-containerd-registry-mirrors=docker.io=registry3", - "-node-containerd-registry-mirrors=registry.k8s.io=https://insecure.registry", - "-node-insecure-registries=registry.k8s.io", - }, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - crc := ContainerRuntimeConfig{ - Docker: tt.fields.Docker, - Containerd: tt.fields.Containerd, - } - if got := crc.MachineControllerFlags(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("ContainerRuntimeConfig.MachineControllerFlags() = \n%v, \nwant\n%v", got, tt.want) - } - }) - } -} - func TestMapStringStringToString(t *testing.T) { tests := []struct { name string diff --git a/pkg/apis/kubeone/types.go b/pkg/apis/kubeone/types.go index 3352cc45c..31cde2e19 100644 --- a/pkg/apis/kubeone/types.go +++ b/pkg/apis/kubeone/types.go @@ -140,19 +140,10 @@ type LoggingConfig struct { // ContainerRuntimeConfig type ContainerRuntimeConfig struct { - // Dockerd related configurations - Docker *ContainerRuntimeDocker `json:"docker,omitempty"` - // Containerd related configurations Containerd *ContainerRuntimeContainerd `json:"containerd,omitempty"` } -// ContainerRuntimeDocker defines docker container runtime -type ContainerRuntimeDocker struct { - // Configures dockerd with "registry-mirrors" - RegistryMirrors []string `json:"registryMirrors"` -} - // ContainerRuntimeContainerd defines docker container runtime type ContainerRuntimeContainerd struct { // A map of registries to use to render configs and mirrors for containerd registries diff --git a/pkg/apis/kubeone/v1beta1/conversion.go b/pkg/apis/kubeone/v1beta1/conversion.go index 921df9247..98b740d4a 100644 --- a/pkg/apis/kubeone/v1beta1/conversion.go +++ b/pkg/apis/kubeone/v1beta1/conversion.go @@ -30,11 +30,6 @@ func Convert_kubeone_ContainerRuntimeContainerd_To_v1beta1_ContainerRuntimeConta return nil } -func Convert_kubeone_ContainerRuntimeDocker_To_v1beta1_ContainerRuntimeDocker(*kubeoneapi.ContainerRuntimeDocker, *ContainerRuntimeDocker, conversion.Scope) error { - // Skip conversion - return nil -} - // Convert_v1beta1_Features_To_kubeone_Features is an autogenerated conversion function. func Convert_v1beta1_Features_To_kubeone_Features(in *Features, out *kubeoneapi.Features, s conversion.Scope) error { if err := autoConvert_v1beta1_Features_To_kubeone_Features(in, out, s); err != nil { @@ -105,3 +100,7 @@ func Convert_kubeone_ProviderStaticNetworkConfig_To_v1beta1_ProviderStaticNetwor func Convert_kubeone_Addon_To_v1beta1_Addon(in *kubeoneapi.Addon, out *Addon, s conversion.Scope) error { return autoConvert_kubeone_Addon_To_v1beta1_Addon(in, out, s) } + +func Convert_v1beta1_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(*ContainerRuntimeConfig, *kubeoneapi.ContainerRuntimeConfig, conversion.Scope) error { + return nil +} diff --git a/pkg/apis/kubeone/v1beta1/zz_generated.conversion.go b/pkg/apis/kubeone/v1beta1/zz_generated.conversion.go index f79435c1b..d62d20d77 100644 --- a/pkg/apis/kubeone/v1beta1/zz_generated.conversion.go +++ b/pkg/apis/kubeone/v1beta1/zz_generated.conversion.go @@ -138,11 +138,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*ContainerRuntimeConfig)(nil), (*kubeone.ContainerRuntimeConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(a.(*ContainerRuntimeConfig), b.(*kubeone.ContainerRuntimeConfig), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*kubeone.ContainerRuntimeConfig)(nil), (*ContainerRuntimeConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_kubeone_ContainerRuntimeConfig_To_v1beta1_ContainerRuntimeConfig(a.(*kubeone.ContainerRuntimeConfig), b.(*ContainerRuntimeConfig), scope) }); err != nil { @@ -153,11 +148,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*ContainerRuntimeDocker)(nil), (*kubeone.ContainerRuntimeDocker)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_ContainerRuntimeDocker_To_kubeone_ContainerRuntimeDocker(a.(*ContainerRuntimeDocker), b.(*kubeone.ContainerRuntimeDocker), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*ControlPlaneConfig)(nil), (*kubeone.ControlPlaneConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_ControlPlaneConfig_To_kubeone_ControlPlaneConfig(a.(*ControlPlaneConfig), b.(*kubeone.ControlPlaneConfig), scope) }); err != nil { @@ -508,11 +498,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddConversionFunc((*kubeone.ContainerRuntimeDocker)(nil), (*ContainerRuntimeDocker)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_kubeone_ContainerRuntimeDocker_To_v1beta1_ContainerRuntimeDocker(a.(*kubeone.ContainerRuntimeDocker), b.(*ContainerRuntimeDocker), scope) - }); err != nil { - return err - } if err := s.AddConversionFunc((*kubeone.Features)(nil), (*Features)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_kubeone_Features_To_v1beta1_Features(a.(*kubeone.Features), b.(*Features), scope) }); err != nil { @@ -543,6 +528,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*ContainerRuntimeConfig)(nil), (*kubeone.ContainerRuntimeConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(a.(*ContainerRuntimeConfig), b.(*kubeone.ContainerRuntimeConfig), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*Features)(nil), (*kubeone.Features)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_Features_To_kubeone_Features(a.(*Features), b.(*kubeone.Features), scope) }); err != nil { @@ -898,15 +888,7 @@ func autoConvert_kubeone_ClusterNetworkConfig_To_v1beta1_ClusterNetworkConfig(in } func autoConvert_v1beta1_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(in *ContainerRuntimeConfig, out *kubeone.ContainerRuntimeConfig, s conversion.Scope) error { - if in.Docker != nil { - in, out := &in.Docker, &out.Docker - *out = new(kubeone.ContainerRuntimeDocker) - if err := Convert_v1beta1_ContainerRuntimeDocker_To_kubeone_ContainerRuntimeDocker(*in, *out, s); err != nil { - return err - } - } else { - out.Docker = nil - } + // WARNING: in.Docker requires manual conversion: does not exist in peer-type if in.Containerd != nil { in, out := &in.Containerd, &out.Containerd *out = new(kubeone.ContainerRuntimeContainerd) @@ -919,21 +901,7 @@ func autoConvert_v1beta1_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfi return nil } -// Convert_v1beta1_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig is an autogenerated conversion function. -func Convert_v1beta1_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(in *ContainerRuntimeConfig, out *kubeone.ContainerRuntimeConfig, s conversion.Scope) error { - return autoConvert_v1beta1_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(in, out, s) -} - func autoConvert_kubeone_ContainerRuntimeConfig_To_v1beta1_ContainerRuntimeConfig(in *kubeone.ContainerRuntimeConfig, out *ContainerRuntimeConfig, s conversion.Scope) error { - if in.Docker != nil { - in, out := &in.Docker, &out.Docker - *out = new(ContainerRuntimeDocker) - if err := Convert_kubeone_ContainerRuntimeDocker_To_v1beta1_ContainerRuntimeDocker(*in, *out, s); err != nil { - return err - } - } else { - out.Docker = nil - } if in.Containerd != nil { in, out := &in.Containerd, &out.Containerd *out = new(ContainerRuntimeContainerd) @@ -965,20 +933,6 @@ func autoConvert_kubeone_ContainerRuntimeContainerd_To_v1beta1_ContainerRuntimeC return nil } -func autoConvert_v1beta1_ContainerRuntimeDocker_To_kubeone_ContainerRuntimeDocker(in *ContainerRuntimeDocker, out *kubeone.ContainerRuntimeDocker, s conversion.Scope) error { - return nil -} - -// Convert_v1beta1_ContainerRuntimeDocker_To_kubeone_ContainerRuntimeDocker is an autogenerated conversion function. -func Convert_v1beta1_ContainerRuntimeDocker_To_kubeone_ContainerRuntimeDocker(in *ContainerRuntimeDocker, out *kubeone.ContainerRuntimeDocker, s conversion.Scope) error { - return autoConvert_v1beta1_ContainerRuntimeDocker_To_kubeone_ContainerRuntimeDocker(in, out, s) -} - -func autoConvert_kubeone_ContainerRuntimeDocker_To_v1beta1_ContainerRuntimeDocker(in *kubeone.ContainerRuntimeDocker, out *ContainerRuntimeDocker, s conversion.Scope) error { - // WARNING: in.RegistryMirrors requires manual conversion: does not exist in peer-type - return nil -} - func autoConvert_v1beta1_ControlPlaneConfig_To_kubeone_ControlPlaneConfig(in *ControlPlaneConfig, out *kubeone.ControlPlaneConfig, s conversion.Scope) error { if in.Hosts != nil { in, out := &in.Hosts, &out.Hosts diff --git a/pkg/apis/kubeone/v1beta2/conversion.go b/pkg/apis/kubeone/v1beta2/conversion.go index 5956a8e3e..9d353dcaf 100644 --- a/pkg/apis/kubeone/v1beta2/conversion.go +++ b/pkg/apis/kubeone/v1beta2/conversion.go @@ -26,3 +26,7 @@ func Convert_kubeone_KubeOneCluster_To_v1beta2_KubeOneCluster(in *kubeoneapi.Kub // AssetsConfiguration has been removed in the v1beta2 API return autoConvert_kubeone_KubeOneCluster_To_v1beta2_KubeOneCluster(in, out, scope) } + +func Convert_v1beta2_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(*ContainerRuntimeConfig, *kubeoneapi.ContainerRuntimeConfig, conversion.Scope) error { + return nil +} diff --git a/pkg/apis/kubeone/v1beta2/zz_generated.conversion.go b/pkg/apis/kubeone/v1beta2/zz_generated.conversion.go index 83526afa0..1ee28cd38 100644 --- a/pkg/apis/kubeone/v1beta2/zz_generated.conversion.go +++ b/pkg/apis/kubeone/v1beta2/zz_generated.conversion.go @@ -148,11 +148,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*ContainerRuntimeConfig)(nil), (*kubeone.ContainerRuntimeConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(a.(*ContainerRuntimeConfig), b.(*kubeone.ContainerRuntimeConfig), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*kubeone.ContainerRuntimeConfig)(nil), (*ContainerRuntimeConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_kubeone_ContainerRuntimeConfig_To_v1beta2_ContainerRuntimeConfig(a.(*kubeone.ContainerRuntimeConfig), b.(*ContainerRuntimeConfig), scope) }); err != nil { @@ -168,16 +163,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*ContainerRuntimeDocker)(nil), (*kubeone.ContainerRuntimeDocker)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_ContainerRuntimeDocker_To_kubeone_ContainerRuntimeDocker(a.(*ContainerRuntimeDocker), b.(*kubeone.ContainerRuntimeDocker), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*kubeone.ContainerRuntimeDocker)(nil), (*ContainerRuntimeDocker)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_kubeone_ContainerRuntimeDocker_To_v1beta2_ContainerRuntimeDocker(a.(*kubeone.ContainerRuntimeDocker), b.(*ContainerRuntimeDocker), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*ContainerdRegistry)(nil), (*kubeone.ContainerdRegistry)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta2_ContainerdRegistry_To_kubeone_ContainerdRegistry(a.(*ContainerdRegistry), b.(*kubeone.ContainerdRegistry), scope) }); err != nil { @@ -668,6 +653,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*ContainerRuntimeConfig)(nil), (*kubeone.ContainerRuntimeConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(a.(*ContainerRuntimeConfig), b.(*kubeone.ContainerRuntimeConfig), scope) + }); err != nil { + return err + } return nil } @@ -962,18 +952,12 @@ func Convert_kubeone_ClusterNetworkConfig_To_v1beta2_ClusterNetworkConfig(in *ku } func autoConvert_v1beta2_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(in *ContainerRuntimeConfig, out *kubeone.ContainerRuntimeConfig, s conversion.Scope) error { - out.Docker = (*kubeone.ContainerRuntimeDocker)(unsafe.Pointer(in.Docker)) + // WARNING: in.Docker requires manual conversion: does not exist in peer-type out.Containerd = (*kubeone.ContainerRuntimeContainerd)(unsafe.Pointer(in.Containerd)) return nil } -// Convert_v1beta2_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig is an autogenerated conversion function. -func Convert_v1beta2_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(in *ContainerRuntimeConfig, out *kubeone.ContainerRuntimeConfig, s conversion.Scope) error { - return autoConvert_v1beta2_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(in, out, s) -} - func autoConvert_kubeone_ContainerRuntimeConfig_To_v1beta2_ContainerRuntimeConfig(in *kubeone.ContainerRuntimeConfig, out *ContainerRuntimeConfig, s conversion.Scope) error { - out.Docker = (*ContainerRuntimeDocker)(unsafe.Pointer(in.Docker)) out.Containerd = (*ContainerRuntimeContainerd)(unsafe.Pointer(in.Containerd)) return nil } @@ -1003,26 +987,6 @@ func Convert_kubeone_ContainerRuntimeContainerd_To_v1beta2_ContainerRuntimeConta return autoConvert_kubeone_ContainerRuntimeContainerd_To_v1beta2_ContainerRuntimeContainerd(in, out, s) } -func autoConvert_v1beta2_ContainerRuntimeDocker_To_kubeone_ContainerRuntimeDocker(in *ContainerRuntimeDocker, out *kubeone.ContainerRuntimeDocker, s conversion.Scope) error { - out.RegistryMirrors = *(*[]string)(unsafe.Pointer(&in.RegistryMirrors)) - return nil -} - -// Convert_v1beta2_ContainerRuntimeDocker_To_kubeone_ContainerRuntimeDocker is an autogenerated conversion function. -func Convert_v1beta2_ContainerRuntimeDocker_To_kubeone_ContainerRuntimeDocker(in *ContainerRuntimeDocker, out *kubeone.ContainerRuntimeDocker, s conversion.Scope) error { - return autoConvert_v1beta2_ContainerRuntimeDocker_To_kubeone_ContainerRuntimeDocker(in, out, s) -} - -func autoConvert_kubeone_ContainerRuntimeDocker_To_v1beta2_ContainerRuntimeDocker(in *kubeone.ContainerRuntimeDocker, out *ContainerRuntimeDocker, s conversion.Scope) error { - out.RegistryMirrors = *(*[]string)(unsafe.Pointer(&in.RegistryMirrors)) - return nil -} - -// Convert_kubeone_ContainerRuntimeDocker_To_v1beta2_ContainerRuntimeDocker is an autogenerated conversion function. -func Convert_kubeone_ContainerRuntimeDocker_To_v1beta2_ContainerRuntimeDocker(in *kubeone.ContainerRuntimeDocker, out *ContainerRuntimeDocker, s conversion.Scope) error { - return autoConvert_kubeone_ContainerRuntimeDocker_To_v1beta2_ContainerRuntimeDocker(in, out, s) -} - func autoConvert_v1beta2_ContainerdRegistry_To_kubeone_ContainerdRegistry(in *ContainerdRegistry, out *kubeone.ContainerdRegistry, s conversion.Scope) error { out.Mirrors = *(*[]string)(unsafe.Pointer(&in.Mirrors)) out.TLSConfig = (*kubeone.ContainerdTLSConfig)(unsafe.Pointer(in.TLSConfig)) diff --git a/pkg/apis/kubeone/validation/validation.go b/pkg/apis/kubeone/validation/validation.go index b9aed4943..1c3f6e0bc 100644 --- a/pkg/apis/kubeone/validation/validation.go +++ b/pkg/apis/kubeone/validation/validation.go @@ -22,7 +22,6 @@ import ( "fmt" "net" "os" - "reflect" "strings" "github.com/Masterminds/semver/v3" @@ -62,7 +61,6 @@ func ValidateKubeOneCluster(c kubeoneapi.KubeOneCluster) field.ErrorList { allErrs = append(allErrs, ValidateCloudProviderSpec(c.CloudProvider, c.ClusterNetwork, field.NewPath("provider"))...) allErrs = append(allErrs, ValidateVersionConfig(c.Versions, field.NewPath("versions"))...) allErrs = append(allErrs, ValidateKubernetesSupport(c, field.NewPath(""))...) - allErrs = append(allErrs, ValidateContainerRuntimeConfig(c.ContainerRuntime, c.Versions, field.NewPath("containerRuntime"))...) allErrs = append(allErrs, ValidateClusterNetworkConfig(c.ClusterNetwork, c.CloudProvider, field.NewPath("clusterNetwork"))...) allErrs = append(allErrs, ValidateStaticWorkersConfig(c.StaticWorkers, c.Versions, c.ClusterNetwork, field.NewPath("staticWorkers"))...) @@ -110,13 +108,6 @@ func ValidateContainerRuntimeVSRegistryConfiguration( "", fmt.Sprintf("can't have both %s and %s set", rcFldPath.String(), containerdRegistriesField.String()), )) - case cr.Docker != nil && cr.Docker.RegistryMirrors != nil: - dockerRegistryMirrorsField := crFldPath.Child("docker", "registryMirrors") - allErrs = append(allErrs, field.Invalid( - dockerRegistryMirrorsField, - "", - fmt.Sprintf("can't have both %s and %s set", rcFldPath.String(), dockerRegistryMirrorsField.String()), - )) } return allErrs @@ -345,35 +336,6 @@ func ValidateKubernetesSupport(c kubeoneapi.KubeOneCluster, fldPath *field.Path) return allErrs } -func ValidateContainerRuntimeConfig(cr kubeoneapi.ContainerRuntimeConfig, versions kubeoneapi.VersionConfig, fldPath *field.Path) field.ErrorList { - allErrs := field.ErrorList{} - - allCRs := []interface{}{ - cr.Docker, - cr.Containerd, - } - - var found bool - for _, x := range allCRs { - if !reflect.ValueOf(x).IsNil() { - if found { - allErrs = append(allErrs, field.Invalid(fldPath, x, "only 1 container runtime can be activated")) - } - found = true - } - } - - if cr.Docker != nil { - kubeVer, _ := semver.NewVersion(versions.Kubernetes) - gteKube124Condition, _ := semver.NewConstraint(">= 1.24") - if gteKube124Condition.Check(kubeVer) { - allErrs = append(allErrs, field.Invalid(fldPath, cr.Docker, "kubernetes v1.24+ requires containerd container runtime")) - } - } - - return allErrs -} - // ValidateClusterNetworkConfig validates the ClusterNetworkConfig structure func ValidateClusterNetworkConfig(c kubeoneapi.ClusterNetworkConfig, prov kubeoneapi.CloudProviderSpec, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} diff --git a/pkg/apis/kubeone/validation/validation_test.go b/pkg/apis/kubeone/validation/validation_test.go index 30ffb5844..13a2541f7 100644 --- a/pkg/apis/kubeone/validation/validation_test.go +++ b/pkg/apis/kubeone/validation/validation_test.go @@ -1141,65 +1141,6 @@ func TestValidateKubernetesSupport(t *testing.T) { } } -func TestValidateContainerRuntimeConfig(t *testing.T) { - tests := []struct { - name string - containerRuntime kubeoneapi.ContainerRuntimeConfig - versions kubeoneapi.VersionConfig - expectedError bool - }{ - { - name: "only docker defined", - containerRuntime: kubeoneapi.ContainerRuntimeConfig{Docker: &kubeoneapi.ContainerRuntimeDocker{}}, - versions: kubeoneapi.VersionConfig{Kubernetes: "1.20"}, - expectedError: false, - }, - { - name: "docker with kubernetes 1.24+", - containerRuntime: kubeoneapi.ContainerRuntimeConfig{Docker: &kubeoneapi.ContainerRuntimeDocker{}}, - versions: kubeoneapi.VersionConfig{Kubernetes: "1.24"}, - expectedError: true, - }, - { - name: "only containerd defined", - containerRuntime: kubeoneapi.ContainerRuntimeConfig{Containerd: &kubeoneapi.ContainerRuntimeContainerd{}}, - versions: kubeoneapi.VersionConfig{Kubernetes: "1.20"}, - expectedError: false, - }, - { - name: "both defined", - containerRuntime: kubeoneapi.ContainerRuntimeConfig{ - Docker: &kubeoneapi.ContainerRuntimeDocker{}, - Containerd: &kubeoneapi.ContainerRuntimeContainerd{}, - }, - versions: kubeoneapi.VersionConfig{Kubernetes: "1.20"}, - expectedError: true, - }, - { - name: "non defined", - containerRuntime: kubeoneapi.ContainerRuntimeConfig{}, - versions: kubeoneapi.VersionConfig{Kubernetes: "1.20"}, - expectedError: false, - }, - { - name: "non defined, 1.21+", - containerRuntime: kubeoneapi.ContainerRuntimeConfig{}, - versions: kubeoneapi.VersionConfig{Kubernetes: "1.21"}, - expectedError: false, - }, - } - - for _, tc := range tests { - tc := tc - t.Run(tc.name, func(t *testing.T) { - errs := ValidateContainerRuntimeConfig(tc.containerRuntime, tc.versions, &field.Path{}) - if (len(errs) == 0) == tc.expectedError { - t.Errorf("test case failed: expected %v, but got %v", tc.expectedError, (len(errs) != 0)) - } - }) - } -} - func TestValidateClusterNetworkConfig(t *testing.T) { tests := []struct { name string diff --git a/pkg/apis/kubeone/zz_generated.deepcopy.go b/pkg/apis/kubeone/zz_generated.deepcopy.go index 739478d85..9c3b62962 100644 --- a/pkg/apis/kubeone/zz_generated.deepcopy.go +++ b/pkg/apis/kubeone/zz_generated.deepcopy.go @@ -352,11 +352,6 @@ func (in *ClusterNetworkConfig) DeepCopy() *ClusterNetworkConfig { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ContainerRuntimeConfig) DeepCopyInto(out *ContainerRuntimeConfig) { *out = *in - if in.Docker != nil { - in, out := &in.Docker, &out.Docker - *out = new(ContainerRuntimeDocker) - (*in).DeepCopyInto(*out) - } if in.Containerd != nil { in, out := &in.Containerd, &out.Containerd *out = new(ContainerRuntimeContainerd) @@ -398,27 +393,6 @@ func (in *ContainerRuntimeContainerd) DeepCopy() *ContainerRuntimeContainerd { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ContainerRuntimeDocker) DeepCopyInto(out *ContainerRuntimeDocker) { - *out = *in - if in.RegistryMirrors != nil { - in, out := &in.RegistryMirrors, &out.RegistryMirrors - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerRuntimeDocker. -func (in *ContainerRuntimeDocker) DeepCopy() *ContainerRuntimeDocker { - if in == nil { - return nil - } - out := new(ContainerRuntimeDocker) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ContainerdRegistry) DeepCopyInto(out *ContainerdRegistry) { *out = *in diff --git a/pkg/cmd/apply.go b/pkg/cmd/apply.go index 691ae67fb..04996add5 100644 --- a/pkg/cmd/apply.go +++ b/pkg/cmd/apply.go @@ -459,26 +459,17 @@ func runApplyRotateKey(s *state.State, opts *applyOpts) error { func printHostInformation(host state.Host) { containerdCR := host.ContainerRuntimeContainerd - dockerCR := host.ContainerRuntimeDocker fmt.Printf("Host: %q\n", host.Config.Hostname) fmt.Printf("\tHost initialized: %s\n", boolStr(host.Initialized())) fmt.Printf("\t%s healthy: %s (%s)\n", containerdCR.Name, boolStr(containerdCR.Healthy()), printVersion(containerdCR.Version)) - if dockerCR.IsProvisioned() { - fmt.Printf("\t%s healthy: %s (%s)\n", dockerCR.Name, boolStr(dockerCR.Healthy()), printVersion(dockerCR.Version)) - } fmt.Printf("\tKubelet healthy: %s (%s)\n", boolStr(host.Kubelet.Healthy()), printVersion(host.Kubelet.Version)) fmt.Println() componentStatusReport(containerdCR) - if dockerCR.IsProvisioned() { - fmt.Println() - componentStatusReport(dockerCR) - } - fmt.Println() componentStatusReport(host.Kubelet) fmt.Println() diff --git a/pkg/containerruntime/docker_config.go b/pkg/containerruntime/docker_config.go deleted file mode 100644 index 8b47a2042..000000000 --- a/pkg/containerruntime/docker_config.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright 2021 The KubeOne Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package containerruntime - -import ( - "encoding/json" - "strconv" - "strings" - - kubeoneapi "k8c.io/kubeone/pkg/apis/kubeone" - "k8c.io/kubeone/pkg/fail" -) - -type dockerConfig struct { - ExecOpts []string `json:"exec-opts,omitempty"` - StorageDriver string `json:"storage-driver,omitempty"` - LogDriver string `json:"log-driver,omitempty"` - LogOpts map[string]string `json:"log-opts,omitempty"` - InsecureRegistries []string `json:"insecure-registries,omitempty"` - RegistryMirrors []string `json:"registry-mirrors,omitempty"` -} - -func marshalDockerConfig(cluster *kubeoneapi.KubeOneCluster) (string, error) { - // Parse log max size to ensure that it has the correct units - logSize := strings.ToLower(cluster.LoggingConfig.ContainerLogMaxSize) - logSize = strings.ReplaceAll(logSize, "ki", "k") - logSize = strings.ReplaceAll(logSize, "mi", "m") - logSize = strings.ReplaceAll(logSize, "gi", "g") - - cfg := dockerConfig{ - ExecOpts: []string{"native.cgroupdriver=systemd"}, - StorageDriver: "overlay2", - LogDriver: "json-file", - LogOpts: map[string]string{ - "max-size": logSize, - "max-file": strconv.Itoa(int(cluster.LoggingConfig.ContainerLogMaxFiles)), - }, - } - - insecureRegistry := cluster.RegistryConfiguration.InsecureRegistryAddress() - if insecureRegistry != "" { - cfg.InsecureRegistries = []string{insecureRegistry} - } - - b, err := json.MarshalIndent(cfg, "", " ") - - return string(b), fail.Runtime(err, "encoding docker config") -} diff --git a/pkg/containerruntime/docker_config_test.go b/pkg/containerruntime/docker_config_test.go deleted file mode 100644 index 3f2394cdd..000000000 --- a/pkg/containerruntime/docker_config_test.go +++ /dev/null @@ -1,98 +0,0 @@ -/* -Copyright 2022 The KubeOne Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package containerruntime - -import ( - "encoding/json" - "testing" - - kubeoneapi "k8c.io/kubeone/pkg/apis/kubeone" -) - -func Test_marshalDockerConfig(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - cluster *kubeoneapi.KubeOneCluster - want string - expectedMaxSize string - expectedMaxFiles string - }{ - { - name: "Should be convert 100Mi to 100m", - cluster: genCluster(withContainerLogMaxSize("100Mi")), - expectedMaxSize: "100m", - expectedMaxFiles: "0", - }, - { - name: "Should be convert 100Ki to 100k", - cluster: genCluster(withContainerLogMaxSize("100Ki")), - expectedMaxSize: "100k", - expectedMaxFiles: "0", - }, - { - name: "Should be convert 100Gi to 100g", - cluster: genCluster(withContainerLogMaxSize("100Gi")), - expectedMaxSize: "100g", - expectedMaxFiles: "0", - }, - { - name: "Should set max-file to 10 and max-size to 100m", - cluster: genCluster(withContainerLogMaxSize("100m"), withContainerLogMaxFiles(10)), - expectedMaxSize: "100m", - expectedMaxFiles: "10", - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - got, err := marshalDockerConfig(tt.cluster) - if err != nil { - t.Errorf("marshalDockerConfig() error = %v,", err) - } - cfg := dockerConfig{} - err = json.Unmarshal([]byte(got), &cfg) - if err != nil { - t.Errorf("marshalDockerConfig() error = %v,", err) - } - maxSize := cfg.LogOpts["max-size"] - if maxSize != tt.expectedMaxSize { - t.Errorf("marshalDockerConfig() got = %v, want %v", got, tt.expectedMaxSize) - } - - maxFiles := cfg.LogOpts["max-file"] - if maxFiles != tt.expectedMaxFiles { - t.Errorf("marshalDockerConfig() got = %v, want %v", got, tt.expectedMaxFiles) - } - }) - } -} - -func withContainerLogMaxSize(logSize string) clusterOpts { - return func(cls *kubeoneapi.KubeOneCluster) { - cls.LoggingConfig.ContainerLogMaxSize = logSize - } -} - -func withContainerLogMaxFiles(logFiles int32) clusterOpts { - return func(cls *kubeoneapi.KubeOneCluster) { - cls.LoggingConfig.ContainerLogMaxFiles = logFiles - } -} diff --git a/pkg/containerruntime/map.go b/pkg/containerruntime/map.go index e25e9e522..94fad16b6 100644 --- a/pkg/containerruntime/map.go +++ b/pkg/containerruntime/map.go @@ -27,8 +27,6 @@ func UpdateDataMap(cluster *kubeoneapi.KubeOneCluster, inputMap map[string]inter switch { case cluster.ContainerRuntime.Containerd != nil: crConfig, err = marshalContainerdConfig(cluster) - case cluster.ContainerRuntime.Docker != nil: - crConfig, err = marshalDockerConfig(cluster) } if err != nil { diff --git a/pkg/scripts/funcs.go b/pkg/scripts/funcs.go index c0c660727..c69a29bb5 100644 --- a/pkg/scripts/funcs.go +++ b/pkg/scripts/funcs.go @@ -20,8 +20,7 @@ import ( "github.com/MakeNowJust/heredoc/v2" ) -var ( - libraryTemplate = heredoc.Doc(` +var libraryTemplate = heredoc.Doc(` {{ define "detect-host-cpu-architecture" }} HOST_ARCH="" case $(uname -m) in @@ -82,10 +81,8 @@ var ( sudo systemctl force-reload systemd-journald {{ end }} `) -) const ( - latestDockerVersion = "'20.10.*'" defaultContainerdVersion = "'1.6.*'" defaultAmazonContainerdVersion = "'1.6.*'" ) diff --git a/pkg/scripts/os_amzn.go b/pkg/scripts/os_amzn.go index c4d6d52d2..9841963c5 100644 --- a/pkg/scripts/os_amzn.go +++ b/pkg/scripts/os_amzn.go @@ -78,10 +78,6 @@ sudo yum install -y \ iproute-tc \ rsync -{{ if .INSTALL_DOCKER }} -{{ template "yum-docker-ce-amzn" . }} -{{ end }} - {{ if .INSTALL_CONTAINERD }} {{ template "yum-containerd-amzn" . }} {{ end }} @@ -231,7 +227,6 @@ func KubeadmAmazonLinux(cluster *kubeoneapi.KubeOneCluster, force bool) (string, "CONFIGURE_REPOSITORIES": cluster.SystemPackages.ConfigureRepositories, "PROXY": proxy, "FORCE": force, - "INSTALL_DOCKER": cluster.ContainerRuntime.Docker, "INSTALL_CONTAINERD": cluster.ContainerRuntime.Containerd, "USE_KUBERNETES_REPO": cluster.AssetConfiguration.NodeBinaries.URL == "", "IPV6_ENABLED": cluster.ClusterNetwork.HasIPv6(), @@ -269,7 +264,6 @@ func UpgradeKubeadmAndCNIAmazonLinux(cluster *kubeoneapi.KubeOneCluster) (string "CRITOOLS_VERSION": criToolsVersion(cluster), "CONFIGURE_REPOSITORIES": cluster.SystemPackages.ConfigureRepositories, "PROXY": proxy, - "INSTALL_DOCKER": cluster.ContainerRuntime.Docker, "INSTALL_CONTAINERD": cluster.ContainerRuntime.Containerd, "USE_KUBERNETES_REPO": cluster.AssetConfiguration.NodeBinaries.URL == "", "IPV6_ENABLED": cluster.ClusterNetwork.HasIPv6(), @@ -302,7 +296,6 @@ func UpgradeKubeletAndKubectlAmazonLinux(cluster *kubeoneapi.KubeOneCluster) (st "CRITOOLS_VERSION": criToolsVersion(cluster), "CONFIGURE_REPOSITORIES": cluster.SystemPackages.ConfigureRepositories, "PROXY": proxy, - "INSTALL_DOCKER": cluster.ContainerRuntime.Docker, "INSTALL_CONTAINERD": cluster.ContainerRuntime.Containerd, "USE_KUBERNETES_REPO": cluster.AssetConfiguration.NodeBinaries.URL == "", "IPV6_ENABLED": cluster.ClusterNetwork.HasIPv6(), diff --git a/pkg/scripts/os_centos.go b/pkg/scripts/os_centos.go index d5f661977..2910050b2 100644 --- a/pkg/scripts/os_centos.go +++ b/pkg/scripts/os_centos.go @@ -92,10 +92,6 @@ sudo yum install -y \ sudo systemctl enable --now iscsid {{- end }} -{{ if .INSTALL_DOCKER }} -{{ template "yum-docker-ce" . }} -{{ end }} - {{ if .INSTALL_CONTAINERD }} {{ template "yum-containerd" . }} {{ end }} @@ -162,7 +158,6 @@ func KubeadmCentOS(cluster *kubeoneapi.KubeOneCluster, force bool) (string, erro "CONFIGURE_REPOSITORIES": cluster.SystemPackages.ConfigureRepositories, "PROXY": proxy, "FORCE": force, - "INSTALL_DOCKER": cluster.ContainerRuntime.Docker, "INSTALL_CONTAINERD": cluster.ContainerRuntime.Containerd, "INSTALL_ISCSI_AND_NFS": installISCSIAndNFS(cluster), "IPV6_ENABLED": cluster.ClusterNetwork.HasIPv6(), @@ -198,7 +193,6 @@ func UpgradeKubeadmAndCNICentOS(cluster *kubeoneapi.KubeOneCluster) (string, err "CRITOOLS_VERSION": criToolsVersion(cluster), "CONFIGURE_REPOSITORIES": cluster.SystemPackages.ConfigureRepositories, "PROXY": proxy, - "INSTALL_DOCKER": cluster.ContainerRuntime.Docker, "INSTALL_CONTAINERD": cluster.ContainerRuntime.Containerd, "INSTALL_ISCSI_AND_NFS": installISCSIAndNFS(cluster), "IPV6_ENABLED": cluster.ClusterNetwork.HasIPv6(), @@ -229,7 +223,6 @@ func UpgradeKubeletAndKubectlCentOS(cluster *kubeoneapi.KubeOneCluster) (string, "CRITOOLS_VERSION": criToolsVersion(cluster), "CONFIGURE_REPOSITORIES": cluster.SystemPackages.ConfigureRepositories, "PROXY": proxy, - "INSTALL_DOCKER": cluster.ContainerRuntime.Docker, "INSTALL_CONTAINERD": cluster.ContainerRuntime.Containerd, "INSTALL_ISCSI_AND_NFS": installISCSIAndNFS(cluster), "IPV6_ENABLED": cluster.ClusterNetwork.HasIPv6(), diff --git a/pkg/scripts/os_debian.go b/pkg/scripts/os_debian.go index 044b40e1a..1c1391d86 100644 --- a/pkg/scripts/os_debian.go +++ b/pkg/scripts/os_debian.go @@ -78,10 +78,6 @@ cri_ver="{{ .CRITOOLS_VERSION }}-*" sudo apt-mark unhold kubelet kubeadm kubectl kubernetes-cni cri-tools {{- end }} -{{ if .INSTALL_DOCKER }} -{{ template "apt-docker-ce" . }} -{{ end }} - {{ if .INSTALL_CONTAINERD }} {{ template "apt-containerd" . }} {{ end }} @@ -141,7 +137,6 @@ func KubeadmDebian(cluster *kubeoneapi.KubeOneCluster, force bool) (string, erro "HTTP_PROXY": cluster.Proxy.HTTP, "HTTPS_PROXY": cluster.Proxy.HTTPS, "FORCE": force, - "INSTALL_DOCKER": cluster.ContainerRuntime.Docker, "INSTALL_CONTAINERD": cluster.ContainerRuntime.Containerd, "INSTALL_ISCSI_AND_NFS": installISCSIAndNFS(cluster), "IPV6_ENABLED": cluster.ClusterNetwork.HasIPv6(), @@ -173,7 +168,6 @@ func UpgradeKubeadmAndCNIDebian(cluster *kubeoneapi.KubeOneCluster) (string, err "CONFIGURE_REPOSITORIES": cluster.SystemPackages.ConfigureRepositories, "HTTP_PROXY": cluster.Proxy.HTTP, "HTTPS_PROXY": cluster.Proxy.HTTPS, - "INSTALL_DOCKER": cluster.ContainerRuntime.Docker, "INSTALL_CONTAINERD": cluster.ContainerRuntime.Containerd, "INSTALL_ISCSI_AND_NFS": installISCSIAndNFS(cluster), "IPV6_ENABLED": cluster.ClusterNetwork.HasIPv6(), @@ -200,7 +194,6 @@ func UpgradeKubeletAndKubectlDebian(cluster *kubeoneapi.KubeOneCluster) (string, "CONFIGURE_REPOSITORIES": cluster.SystemPackages.ConfigureRepositories, "HTTP_PROXY": cluster.Proxy.HTTP, "HTTPS_PROXY": cluster.Proxy.HTTPS, - "INSTALL_DOCKER": cluster.ContainerRuntime.Docker, "INSTALL_CONTAINERD": cluster.ContainerRuntime.Containerd, "INSTALL_ISCSI_AND_NFS": installISCSIAndNFS(cluster), "IPV6_ENABLED": cluster.ClusterNetwork.HasIPv6(), diff --git a/pkg/scripts/os_flatcar.go b/pkg/scripts/os_flatcar.go index f3f818cc3..eb3db32dd 100644 --- a/pkg/scripts/os_flatcar.go +++ b/pkg/scripts/os_flatcar.go @@ -40,10 +40,6 @@ CRI_TOOLS_RELEASE="v{{ .CRITOOLS_VERSION }}" curl -L https://github.com/kubernetes-sigs/cri-tools/releases/download/${CRI_TOOLS_RELEASE}/crictl-${CRI_TOOLS_RELEASE}-linux-${HOST_ARCH}.tar.gz | sudo tar -C /opt/bin -xz -{{ if .INSTALL_DOCKER }} -{{ template "flatcar-docker" . }} -{{ end }} - {{ if .INSTALL_CONTAINERD }} {{ template "flatcar-containerd" . }} {{ end }} @@ -106,10 +102,6 @@ sudo systemctl daemon-reload upgradeKubeadmAndCNIFlatcarScriptTemplate = ` {{ template "detect-host-cpu-architecture" }} -{{- if .INSTALL_DOCKER -}} -{{ template "flatcar-docker" . }} -{{ end }} - {{- if .INSTALL_CONTAINERD -}} {{ template "flatcar-containerd" . }} {{ end }} @@ -138,10 +130,6 @@ source /etc/kubeone/proxy-env {{ template "detect-host-cpu-architecture" }} -{{- if .INSTALL_DOCKER -}} -{{ template "flatcar-docker" . }} -{{ end }} - {{- if .INSTALL_CONTAINERD -}} {{ template "flatcar-containerd" . }} {{ end }} @@ -198,7 +186,6 @@ func KubeadmFlatcar(cluster *kubeoneapi.KubeOneCluster) (string, error) { "KUBERNETES_VERSION": cluster.Versions.Kubernetes, "KUBERNETES_CNI_VERSION": defaultKubernetesCNIVersion, "CRITOOLS_VERSION": criToolsVersion(cluster), - "INSTALL_DOCKER": cluster.ContainerRuntime.Docker, "INSTALL_CONTAINERD": cluster.ContainerRuntime.Containerd, "IPV6_ENABLED": cluster.ClusterNetwork.HasIPv6(), } @@ -222,7 +209,6 @@ func UpgradeKubeadmAndCNIFlatcar(cluster *kubeoneapi.KubeOneCluster) (string, er data := Data{ "KUBERNETES_VERSION": cluster.Versions.Kubernetes, "KUBERNETES_CNI_VERSION": defaultKubernetesCNIVersion, - "INSTALL_DOCKER": cluster.ContainerRuntime.Docker, "INSTALL_CONTAINERD": cluster.ContainerRuntime.Containerd, } @@ -238,7 +224,6 @@ func UpgradeKubeadmAndCNIFlatcar(cluster *kubeoneapi.KubeOneCluster) (string, er func UpgradeKubeletAndKubectlFlatcar(cluster *kubeoneapi.KubeOneCluster) (string, error) { data := Data{ "KUBERNETES_VERSION": cluster.Versions.Kubernetes, - "INSTALL_DOCKER": cluster.ContainerRuntime.Docker, "INSTALL_CONTAINERD": cluster.ContainerRuntime.Containerd, } diff --git a/pkg/scripts/os_test.go b/pkg/scripts/os_test.go index ee89c24d8..a1e678443 100644 --- a/pkg/scripts/os_test.go +++ b/pkg/scripts/os_test.go @@ -28,12 +28,6 @@ type genClusterOpts func(*kubeoneapi.KubeOneCluster) func withContainerd(cls *kubeoneapi.KubeOneCluster) { cls.ContainerRuntime.Containerd = &kubeoneapi.ContainerRuntimeContainerd{} - cls.ContainerRuntime.Docker = nil -} - -func withDocker(cls *kubeoneapi.KubeOneCluster) { - cls.ContainerRuntime.Containerd = nil - cls.ContainerRuntime.Docker = &kubeoneapi.ContainerRuntimeDocker{} } func withKubeVersion(ver string) genClusterOpts { @@ -132,24 +126,6 @@ func TestKubeadmDebian(t *testing.T) { args args err error }{ - { - name: "simple", - args: args{ - cluster: genCluster(withDocker), - }, - }, - { - name: "overwrite registry", - args: args{ - cluster: genCluster(withDocker, withRegistry("127.0.0.1:5000")), - }, - }, - { - name: "overwrite registry insecure", - args: args{ - cluster: genCluster(withDocker, withInsecureRegistry("127.0.0.1:5000")), - }, - }, { name: "with containerd", args: args{ @@ -248,37 +224,6 @@ func TestKubeadmCentOS(t *testing.T) { args args err error }{ - { - name: "simple", - args: args{ - cluster: genCluster(withDocker), - }, - }, - { - name: "proxy", - args: args{ - cluster: genCluster(withDocker, withProxy("http://my-proxy.tld")), - }, - }, - { - name: "force", - args: args{ - cluster: genCluster(withDocker), - force: true, - }, - }, - { - name: "overwrite registry", - args: args{ - cluster: genCluster(withDocker, withRegistry("127.0.0.1:5000")), - }, - }, - { - name: "overwrite registry insecure", - args: args{ - cluster: genCluster(withDocker, withInsecureRegistry("127.0.0.1:5000")), - }, - }, { name: "with containerd", args: args{ @@ -333,20 +278,11 @@ func TestKubeadmAmazonLinux(t *testing.T) { args args err error }{ - { - name: "simple", - args: args{ - cluster: genCluster( - withDocker, - withDefaultAssetConfiguration, - ), - }, - }, { name: "proxy", args: args{ cluster: genCluster( - withDocker, + withContainerd, withProxy("http://my-proxy.tld"), withDefaultAssetConfiguration, ), @@ -356,7 +292,7 @@ func TestKubeadmAmazonLinux(t *testing.T) { name: "force", args: args{ cluster: genCluster( - withDocker, + withContainerd, withDefaultAssetConfiguration, ), force: true, @@ -366,7 +302,7 @@ func TestKubeadmAmazonLinux(t *testing.T) { name: "v1.26.0", args: args{ cluster: genCluster( - withDocker, + withContainerd, withKubeVersion("1.26.0"), withDefaultAssetConfiguration, ), @@ -376,22 +312,12 @@ func TestKubeadmAmazonLinux(t *testing.T) { name: "overwrite registry", args: args{ cluster: genCluster( - withDocker, + withContainerd, withRegistry("127.0.0.1:5000"), withDefaultAssetConfiguration, ), }, }, - { - name: "overwrite registry insecure", - args: args{ - cluster: genCluster( - withDocker, - withInsecureRegistry("127.0.0.1:5000"), - withDefaultAssetConfiguration, - ), - }, - }, { name: "with containerd", args: args{ @@ -439,36 +365,21 @@ func TestKubeadmFlatcar(t *testing.T) { args args err error }{ - { - name: "simple", - args: args{ - cluster: genCluster(withDocker), - }, - }, { name: "force", args: args{ - cluster: genCluster(withDocker), + cluster: genCluster(withContainerd), }, }, { name: "overwrite registry", args: args{ cluster: genCluster( - withDocker, + withContainerd, withRegistry("127.0.0.1:5000"), ), }, }, - { - name: "overwrite registry insecure", - args: args{ - cluster: genCluster( - withDocker, - withInsecureRegistry("127.0.0.1:5000"), - ), - }, - }, { name: "with containerd", args: args{ @@ -563,7 +474,7 @@ func TestRemoveBinariesFlatcar(t *testing.T) { func TestUpgradeKubeadmAndCNIDebian(t *testing.T) { t.Parallel() - cls := genCluster(withDocker) + cls := genCluster(withContainerd) got, err := UpgradeKubeadmAndCNIDebian(&cls) if err != nil { t.Errorf("UpgradeKubeadmAndCNIDebian() error = %v", err) @@ -577,7 +488,7 @@ func TestUpgradeKubeadmAndCNIDebian(t *testing.T) { func TestUpgradeKubeadmAndCNICentOS(t *testing.T) { t.Parallel() - cls := genCluster(withDocker) + cls := genCluster(withContainerd) got, err := UpgradeKubeadmAndCNICentOS(&cls) if err != nil { t.Errorf("UpgradeKubeadmAndCNICentOS() error = %v", err) @@ -591,7 +502,7 @@ func TestUpgradeKubeadmAndCNICentOS(t *testing.T) { func TestUpgradeKubeadmAndCNIAmazonLinux(t *testing.T) { t.Parallel() - cls := genCluster(withDocker, withDefaultAssetConfiguration) + cls := genCluster(withContainerd, withDefaultAssetConfiguration) got, err := UpgradeKubeadmAndCNIAmazonLinux(&cls) if err != nil { t.Errorf("UpgradeKubeadmAndCNIAmazonLinux() error = %v", err) @@ -623,7 +534,7 @@ func TestUpgradeKubeadmAndCNIFlatcar(t *testing.T) { func TestUpgradeKubeletAndKubectlDebian(t *testing.T) { t.Parallel() - cls := genCluster(withDocker) + cls := genCluster(withContainerd) got, err := UpgradeKubeletAndKubectlDebian(&cls) if err != nil { t.Errorf("UpgradeKubeletAndKubectlDebian() error = %v", err) @@ -637,7 +548,7 @@ func TestUpgradeKubeletAndKubectlDebian(t *testing.T) { func TestUpgradeKubeletAndKubectlCentOS(t *testing.T) { t.Parallel() - cls := genCluster(withDocker) + cls := genCluster(withContainerd) got, err := UpgradeKubeletAndKubectlCentOS(&cls) if err != nil { t.Errorf("UpgradeKubeletAndKubectlCentOS() error = %v", err) @@ -651,7 +562,7 @@ func TestUpgradeKubeletAndKubectlCentOS(t *testing.T) { func TestUpgradeKubeletAndKubectlAmazonLinux(t *testing.T) { t.Parallel() - cls := genCluster(withDocker, withDefaultAssetConfiguration) + cls := genCluster(withContainerd, withDefaultAssetConfiguration) got, err := UpgradeKubeletAndKubectlAmazonLinux(&cls) if err != nil { t.Errorf("UpgradeKubeletAndKubectlAmazonLinux() error = %v", err) diff --git a/pkg/scripts/render.go b/pkg/scripts/render.go index a673c78ac..c1d3f76ca 100644 --- a/pkg/scripts/render.go +++ b/pkg/scripts/render.go @@ -26,9 +26,8 @@ import ( "k8c.io/kubeone/pkg/fail" ) -var ( - containerRuntimeTemplates = map[string]string{ - "container-runtime-daemon-config": heredoc.Doc(` +var containerRuntimeTemplates = map[string]string{ + "container-runtime-daemon-config": heredoc.Doc(` {{- if .CONTAINER_RUNTIME_CONFIG_PATH }} sudo mkdir -p $(dirname {{ .CONTAINER_RUNTIME_CONFIG_PATH }}) sudo touch {{ .CONTAINER_RUNTIME_CONFIG_PATH }} @@ -45,100 +44,13 @@ var ( {{- end }} `), - "containerd-systemd-setup": heredoc.Doc(` + "containerd-systemd-setup": heredoc.Doc(` sudo systemctl daemon-reload sudo systemctl enable containerd sudo systemctl restart containerd `), - "apt-docker-ce": heredoc.Docf(` - {{ if .CONFIGURE_REPOSITORIES }} - sudo install -m 0755 -d /etc/apt/keyrings - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg - # Docker provides two different apt repos for ubuntu, bionic and focal. The focal repo currently - # contains only Docker 19.03.14, which is not validated for all Kubernetes version. - # Therefore, we use bionic repo which has all Docker versions. - echo "deb [signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu bionic stable" | - sudo tee /etc/apt/sources.list.d/docker.list - sudo apt-get update - {{ end }} - - sudo apt-mark unhold docker-ce docker-ce-cli containerd.io || true - {{- $DOCKER_VERSION_TO_INSTALL := "%s" }} - - sudo DEBIAN_FRONTEND=noninteractive apt-get install \ - --option "Dpkg::Options::=--force-confold" \ - --no-install-recommends \ - -y \ - {{- if .FORCE }} - --allow-downgrades \ - {{- end }} - docker-ce=5:{{ $DOCKER_VERSION_TO_INSTALL }} \ - docker-ce-cli=5:{{ $DOCKER_VERSION_TO_INSTALL }} \ - containerd.io=%s - sudo apt-mark hold docker-ce docker-ce-cli containerd.io - {{ template "container-runtime-daemon-config" . }} - {{ template "containerd-systemd-setup" . -}} - sudo systemctl enable --now docker - if systemctl status kubelet 2>&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 - fi - `, - latestDockerVersion, - defaultContainerdVersion, - ), - - "yum-docker-ce-amzn": heredoc.Docf(` - sudo yum versionlock delete docker containerd || true - - {{- $DOCKER_VERSION_TO_INSTALL := "%s" }} - - sudo yum install -y \ - docker-{{ $DOCKER_VERSION_TO_INSTALL }} \ - containerd.io-%s - sudo yum versionlock add docker containerd - {{ template "container-runtime-daemon-config" . }} - {{ template "containerd-systemd-setup" . -}} - sudo systemctl enable --now docker - if systemctl status kubelet 2>&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 - fi - `, - latestDockerVersion, - defaultAmazonContainerdVersion, - ), - - "yum-docker-ce": heredoc.Docf(` - {{- if .CONFIGURE_REPOSITORIES }} - sudo yum install -y yum-utils - sudo yum-config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo - sudo yum-config-manager --save --setopt=docker-ce-stable.module_hotfixes=true >/dev/null - {{- end }} - - sudo yum versionlock delete docker-ce docker-ce-cli containerd.io || true - - {{- $DOCKER_VERSION_TO_INSTALL := "%s" }} - - sudo yum install -y \ - docker-ce-{{ $DOCKER_VERSION_TO_INSTALL }} \ - docker-ce-cli-{{ $DOCKER_VERSION_TO_INSTALL }} \ - containerd.io-%s - sudo yum versionlock add docker-ce docker-ce-cli containerd.io - {{ template "container-runtime-daemon-config" . }} - {{ template "containerd-systemd-setup" . -}} - sudo systemctl enable --now docker - if systemctl status kubelet 2>&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 - fi - `, - latestDockerVersion, - defaultContainerdVersion, - ), - - "apt-containerd": heredoc.Docf(` + "apt-containerd": heredoc.Docf(` {{ if .CONFIGURE_REPOSITORIES }} sudo apt-get update sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common lsb-release @@ -161,10 +73,10 @@ var ( {{ template "container-runtime-daemon-config" . }} {{ template "containerd-systemd-setup" . -}} `, - defaultContainerdVersion, - ), + defaultContainerdVersion, + ), - "yum-containerd": heredoc.Docf(` + "yum-containerd": heredoc.Docf(` {{ if .CONFIGURE_REPOSITORIES }} sudo yum install -y yum-utils sudo yum-config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo @@ -182,10 +94,10 @@ var ( {{ template "container-runtime-daemon-config" . }} {{ template "containerd-systemd-setup" . -}} `, - defaultContainerdVersion, - ), + defaultContainerdVersion, + ), - "yum-containerd-amzn": heredoc.Docf(` + "yum-containerd-amzn": heredoc.Docf(` sudo yum versionlock delete containerd || true sudo yum install -y containerd-%s sudo yum versionlock add containerd @@ -193,29 +105,17 @@ var ( {{ template "container-runtime-daemon-config" . }} {{ template "containerd-systemd-setup" . -}} `, - defaultAmazonContainerdVersion, - ), + defaultAmazonContainerdVersion, + ), - "flatcar-containerd": heredoc.Doc(` + "flatcar-containerd": heredoc.Doc(` {{ template "container-runtime-daemon-config" . }} {{ template "flatcar-systemd-drop-in" . }} {{ template "containerd-systemd-setup" . }} `, - ), + ), - "flatcar-docker": heredoc.Doc(` - {{ template "container-runtime-daemon-config" . }} - sudo systemctl daemon-reload - sudo systemctl enable --now docker - sudo systemctl restart docker - if systemctl status kubelet 2>&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 - fi - `, - ), - - "flatcar-systemd-drop-in": heredoc.Doc(` + "flatcar-systemd-drop-in": heredoc.Doc(` sudo mkdir -p /etc/systemd/system/containerd.service.d cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - diff --git a/pkg/scripts/testdata/TestKubeadmAmazonLinux-overwrite_registry.golden b/pkg/scripts/testdata/TestKubeadmAmazonLinux-overwrite_registry.golden index 12dd188ca..18232c383 100644 --- a/pkg/scripts/testdata/TestKubeadmAmazonLinux-overwrite_registry.golden +++ b/pkg/scripts/testdata/TestKubeadmAmazonLinux-overwrite_registry.golden @@ -88,43 +88,42 @@ sudo yum install -y \ rsync -sudo yum versionlock delete docker containerd || true +sudo yum versionlock delete containerd || true +sudo yum install -y containerd-'1.6.*' +sudo yum versionlock add containerd + + +sudo mkdir -p $(dirname /etc/containerd/config.toml) +sudo touch /etc/containerd/config.toml +sudo chmod 600 /etc/containerd/config.toml +cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - diff --git a/pkg/scripts/testdata/TestKubeadmAmazonLinux-overwrite_registry_insecure.golden b/pkg/scripts/testdata/TestKubeadmAmazonLinux-overwrite_registry_insecure.golden deleted file mode 100644 index 0f8d36869..000000000 --- a/pkg/scripts/testdata/TestKubeadmAmazonLinux-overwrite_registry_insecure.golden +++ /dev/null @@ -1,189 +0,0 @@ -set -xeuo pipefail -export "PATH=$PATH:/sbin:/usr/local/bin:/opt/bin" - -sudo swapoff -a -sudo sed -i '/.*swap.*/d' /etc/fstab -sudo setenforce 0 || true -[ -f /etc/selinux/config ] && sudo sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config -sudo systemctl disable --now firewalld || true - -source /etc/kubeone/proxy-env - - -cat < /dev/null; then - sudo modprobe nf_conntrack_ipv4 -else - sudo modprobe nf_conntrack -fi -sudo mkdir -p /etc/sysctl.d -cat < /tmp/yum.conf || true -echo -n "${yum_proxy}" >> /tmp/yum.conf -sudo mv /tmp/yum.conf /etc/yum.conf - - -# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned -# repositories, otherwise, yum will fail to upgrade the packages because it's trying to -# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1). -repo_migration_needed=false - -if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then - repo_migration_needed=true -fi - -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - - - - -sudo mkdir -p /opt/bin /etc/kubernetes/pki /etc/kubernetes/manifests - -rm -rf /tmp/k8s-binaries -mkdir -p /tmp/k8s-binaries -cd /tmp/k8s-binaries -sudo mkdir -p /opt/cni/bin -curl -L "http://127.0.0.1/cni.tar.gz" | sudo tar -C /opt/cni/bin -xz -curl -L --output /tmp/k8s-binaries/node.tar.gz http://127.0.0.1/node.tar.gz -tar xvf node.tar.gz -sudo install --owner=0 --group=0 --mode=0755 /tmp/k8s-binaries/kubernetes/node/bin/kubelet /opt/bin/kubelet -sudo ln -sf /opt/bin/kubelet /usr/bin/ -rm /tmp/k8s-binaries/kubernetes/node/bin/kubelet - -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - diff --git a/pkg/scripts/testdata/TestKubeadmAmazonLinux-simple.golden b/pkg/scripts/testdata/TestKubeadmAmazonLinux-simple.golden deleted file mode 100644 index 12dd188ca..000000000 --- a/pkg/scripts/testdata/TestKubeadmAmazonLinux-simple.golden +++ /dev/null @@ -1,186 +0,0 @@ -set -xeuo pipefail -export "PATH=$PATH:/sbin:/usr/local/bin:/opt/bin" - -sudo swapoff -a -sudo sed -i '/.*swap.*/d' /etc/fstab -sudo setenforce 0 || true -[ -f /etc/selinux/config ] && sudo sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config -sudo systemctl disable --now firewalld || true - -source /etc/kubeone/proxy-env - - -cat < /dev/null; then - sudo modprobe nf_conntrack_ipv4 -else - sudo modprobe nf_conntrack -fi -sudo mkdir -p /etc/sysctl.d -cat < /tmp/yum.conf || true -echo -n "${yum_proxy}" >> /tmp/yum.conf -sudo mv /tmp/yum.conf /etc/yum.conf - - -# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned -# repositories, otherwise, yum will fail to upgrade the packages because it's trying to -# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1). -repo_migration_needed=false - -if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then - repo_migration_needed=true -fi - -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - - - - -sudo mkdir -p /opt/bin /etc/kubernetes/pki /etc/kubernetes/manifests - -rm -rf /tmp/k8s-binaries -mkdir -p /tmp/k8s-binaries -cd /tmp/k8s-binaries -sudo mkdir -p /opt/cni/bin -curl -L "http://127.0.0.1/cni.tar.gz" | sudo tar -C /opt/cni/bin -xz -curl -L --output /tmp/k8s-binaries/node.tar.gz http://127.0.0.1/node.tar.gz -tar xvf node.tar.gz -sudo install --owner=0 --group=0 --mode=0755 /tmp/k8s-binaries/kubernetes/node/bin/kubelet /opt/bin/kubelet -sudo ln -sf /opt/bin/kubelet /usr/bin/ -rm /tmp/k8s-binaries/kubernetes/node/bin/kubelet - -cat < /tmp/yum.conf || true -echo -n "${yum_proxy}" >> /tmp/yum.conf -sudo mv /tmp/yum.conf /etc/yum.conf - - -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - - - - -sudo mkdir -p /opt/bin /etc/kubernetes/pki /etc/kubernetes/manifests - -rm -rf /tmp/k8s-binaries -mkdir -p /tmp/k8s-binaries -cd /tmp/k8s-binaries -sudo mkdir -p /opt/cni/bin -curl -L "http://127.0.0.1/cni.tar.gz" | sudo tar -C /opt/cni/bin -xz -curl -L --output /tmp/k8s-binaries/node.tar.gz http://127.0.0.1/node.tar.gz -tar xvf node.tar.gz -sudo install --owner=0 --group=0 --mode=0755 /tmp/k8s-binaries/kubernetes/node/bin/kubelet /opt/bin/kubelet -sudo ln -sf /opt/bin/kubelet /usr/bin/ -rm /tmp/k8s-binaries/kubernetes/node/bin/kubelet - -cat < /dev/null; then - sudo modprobe nf_conntrack_ipv4 -else - sudo modprobe nf_conntrack -fi -sudo mkdir -p /etc/sysctl.d -cat < /tmp/yum.conf || true -echo -n "${yum_proxy}" >> /tmp/yum.conf -sudo mv /tmp/yum.conf /etc/yum.conf - - -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - - - - -sudo mkdir -p /opt/bin /etc/kubernetes/pki /etc/kubernetes/manifests - -rm -rf /tmp/k8s-binaries -mkdir -p /tmp/k8s-binaries -cd /tmp/k8s-binaries -sudo mkdir -p /opt/cni/bin -curl -L "http://127.0.0.1/cni.tar.gz" | sudo tar -C /opt/cni/bin -xz -curl -L --output /tmp/k8s-binaries/node.tar.gz http://127.0.0.1/node.tar.gz -tar xvf node.tar.gz -sudo install --owner=0 --group=0 --mode=0755 /tmp/k8s-binaries/kubernetes/node/bin/kubelet /opt/bin/kubelet -sudo ln -sf /opt/bin/kubelet /usr/bin/ -rm /tmp/k8s-binaries/kubernetes/node/bin/kubelet - -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - diff --git a/pkg/scripts/testdata/TestKubeadmAmazonLinux-with_cilium.golden b/pkg/scripts/testdata/TestKubeadmAmazonLinux-with_cilium.golden index 8ecff45de..11d1df27e 100644 --- a/pkg/scripts/testdata/TestKubeadmAmazonLinux-with_cilium.golden +++ b/pkg/scripts/testdata/TestKubeadmAmazonLinux-with_cilium.golden @@ -89,8 +89,6 @@ sudo yum install -y \ - - sudo mkdir -p /opt/bin /etc/kubernetes/pki /etc/kubernetes/manifests rm -rf /tmp/k8s-binaries diff --git a/pkg/scripts/testdata/TestKubeadmAmazonLinux-with_containerd.golden b/pkg/scripts/testdata/TestKubeadmAmazonLinux-with_containerd.golden index 592e78f54..c81861188 100644 --- a/pkg/scripts/testdata/TestKubeadmAmazonLinux-with_containerd.golden +++ b/pkg/scripts/testdata/TestKubeadmAmazonLinux-with_containerd.golden @@ -88,8 +88,6 @@ sudo yum install -y \ rsync - - sudo yum versionlock delete containerd || true sudo yum install -y containerd-'1.6.*' sudo yum versionlock add containerd diff --git a/pkg/scripts/testdata/TestKubeadmAmazonLinux-with_containerd_with_insecure_registry.golden b/pkg/scripts/testdata/TestKubeadmAmazonLinux-with_containerd_with_insecure_registry.golden index a3efd95f1..f73626a34 100644 --- a/pkg/scripts/testdata/TestKubeadmAmazonLinux-with_containerd_with_insecure_registry.golden +++ b/pkg/scripts/testdata/TestKubeadmAmazonLinux-with_containerd_with_insecure_registry.golden @@ -88,8 +88,6 @@ sudo yum install -y \ rsync - - sudo yum versionlock delete containerd || true sudo yum install -y containerd-'1.6.*' sudo yum versionlock add containerd diff --git a/pkg/scripts/testdata/TestKubeadmCentOS-cilium_cluster.golden b/pkg/scripts/testdata/TestKubeadmCentOS-cilium_cluster.golden index a3c13dcf3..4b4216de3 100644 --- a/pkg/scripts/testdata/TestKubeadmCentOS-cilium_cluster.golden +++ b/pkg/scripts/testdata/TestKubeadmCentOS-cilium_cluster.golden @@ -95,8 +95,6 @@ sudo yum install -y \ - - sudo yum install -y \ kubelet-1.26.0 \ kubeadm-1.26.0 \ diff --git a/pkg/scripts/testdata/TestKubeadmCentOS-force.golden b/pkg/scripts/testdata/TestKubeadmCentOS-force.golden deleted file mode 100644 index 616073a6f..000000000 --- a/pkg/scripts/testdata/TestKubeadmCentOS-force.golden +++ /dev/null @@ -1,155 +0,0 @@ -set -xeuo pipefail -export "PATH=$PATH:/sbin:/usr/local/bin:/opt/bin" - -sudo swapoff -a -sudo sed -i '/.*swap.*/d' /etc/fstab -sudo setenforce 0 || true -[ -f /etc/selinux/config ] && sudo sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config -sudo systemctl disable --now firewalld || true - -source /etc/kubeone/proxy-env - - -cat < /dev/null; then - sudo modprobe nf_conntrack_ipv4 -else - sudo modprobe nf_conntrack -fi -sudo mkdir -p /etc/sysctl.d -cat < /tmp/yum.conf || true -echo -n "${yum_proxy}" >> /tmp/yum.conf -sudo mv /tmp/yum.conf /etc/yum.conf - - -# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned -# repositories, otherwise, yum will fail to upgrade the packages because it's trying to -# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1). -repo_migration_needed=false - -if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then - repo_migration_needed=true -fi - -cat </dev/null - -sudo yum versionlock delete docker-ce docker-ce-cli containerd.io || true - -sudo yum install -y \ - docker-ce-'20.10.*' \ - docker-ce-cli-'20.10.*' \ - containerd.io-'1.6.*' -sudo yum versionlock add docker-ce docker-ce-cli containerd.io - -sudo mkdir -p $(dirname /etc/docker/daemon.json) -sudo touch /etc/docker/daemon.json -sudo chmod 600 /etc/docker/daemon.json -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - - - -sudo yum versionlock delete kubelet kubeadm kubectl kubernetes-cni cri-tools || true - -sudo yum install -y \ - kubelet-1.26.0 \ - kubeadm-1.26.0 \ - kubectl-1.26.0 \ - kubernetes-cni-1.2.0 \ - cri-tools-1.26.0 -sudo yum versionlock add kubelet kubeadm kubectl kubernetes-cni cri-tools - -sudo systemctl daemon-reload -sudo systemctl enable --now kubelet -sudo systemctl restart kubelet - diff --git a/pkg/scripts/testdata/TestKubeadmCentOS-nutanix_cluster.golden b/pkg/scripts/testdata/TestKubeadmCentOS-nutanix_cluster.golden index 24e482ae9..773b2969f 100644 --- a/pkg/scripts/testdata/TestKubeadmCentOS-nutanix_cluster.golden +++ b/pkg/scripts/testdata/TestKubeadmCentOS-nutanix_cluster.golden @@ -98,8 +98,6 @@ sudo systemctl enable --now iscsid - - sudo yum install -y \ kubelet-1.26.0 \ kubeadm-1.26.0 \ diff --git a/pkg/scripts/testdata/TestKubeadmCentOS-overwrite_registry.golden b/pkg/scripts/testdata/TestKubeadmCentOS-overwrite_registry.golden deleted file mode 100644 index 9dfc23e54..000000000 --- a/pkg/scripts/testdata/TestKubeadmCentOS-overwrite_registry.golden +++ /dev/null @@ -1,154 +0,0 @@ -set -xeuo pipefail -export "PATH=$PATH:/sbin:/usr/local/bin:/opt/bin" - -sudo swapoff -a -sudo sed -i '/.*swap.*/d' /etc/fstab -sudo setenforce 0 || true -[ -f /etc/selinux/config ] && sudo sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config -sudo systemctl disable --now firewalld || true - -source /etc/kubeone/proxy-env - - -cat < /dev/null; then - sudo modprobe nf_conntrack_ipv4 -else - sudo modprobe nf_conntrack -fi -sudo mkdir -p /etc/sysctl.d -cat < /tmp/yum.conf || true -echo -n "${yum_proxy}" >> /tmp/yum.conf -sudo mv /tmp/yum.conf /etc/yum.conf - - -# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned -# repositories, otherwise, yum will fail to upgrade the packages because it's trying to -# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1). -repo_migration_needed=false - -if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then - repo_migration_needed=true -fi - -cat </dev/null - -sudo yum versionlock delete docker-ce docker-ce-cli containerd.io || true - -sudo yum install -y \ - docker-ce-'20.10.*' \ - docker-ce-cli-'20.10.*' \ - containerd.io-'1.6.*' -sudo yum versionlock add docker-ce docker-ce-cli containerd.io - -sudo mkdir -p $(dirname /etc/docker/daemon.json) -sudo touch /etc/docker/daemon.json -sudo chmod 600 /etc/docker/daemon.json -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - - - - -sudo yum install -y \ - kubelet-1.26.0 \ - kubeadm-1.26.0 \ - kubectl-1.26.0 \ - kubernetes-cni-1.2.0 \ - cri-tools-1.26.0 -sudo yum versionlock add kubelet kubeadm kubectl kubernetes-cni cri-tools - -sudo systemctl daemon-reload -sudo systemctl enable --now kubelet -sudo systemctl restart kubelet - diff --git a/pkg/scripts/testdata/TestKubeadmCentOS-overwrite_registry_insecure.golden b/pkg/scripts/testdata/TestKubeadmCentOS-overwrite_registry_insecure.golden deleted file mode 100644 index 0c714840b..000000000 --- a/pkg/scripts/testdata/TestKubeadmCentOS-overwrite_registry_insecure.golden +++ /dev/null @@ -1,157 +0,0 @@ -set -xeuo pipefail -export "PATH=$PATH:/sbin:/usr/local/bin:/opt/bin" - -sudo swapoff -a -sudo sed -i '/.*swap.*/d' /etc/fstab -sudo setenforce 0 || true -[ -f /etc/selinux/config ] && sudo sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config -sudo systemctl disable --now firewalld || true - -source /etc/kubeone/proxy-env - - -cat < /dev/null; then - sudo modprobe nf_conntrack_ipv4 -else - sudo modprobe nf_conntrack -fi -sudo mkdir -p /etc/sysctl.d -cat < /tmp/yum.conf || true -echo -n "${yum_proxy}" >> /tmp/yum.conf -sudo mv /tmp/yum.conf /etc/yum.conf - - -# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned -# repositories, otherwise, yum will fail to upgrade the packages because it's trying to -# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1). -repo_migration_needed=false - -if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then - repo_migration_needed=true -fi - -cat </dev/null - -sudo yum versionlock delete docker-ce docker-ce-cli containerd.io || true - -sudo yum install -y \ - docker-ce-'20.10.*' \ - docker-ce-cli-'20.10.*' \ - containerd.io-'1.6.*' -sudo yum versionlock add docker-ce docker-ce-cli containerd.io - -sudo mkdir -p $(dirname /etc/docker/daemon.json) -sudo touch /etc/docker/daemon.json -sudo chmod 600 /etc/docker/daemon.json -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - - - - -sudo yum install -y \ - kubelet-1.26.0 \ - kubeadm-1.26.0 \ - kubectl-1.26.0 \ - kubernetes-cni-1.2.0 \ - cri-tools-1.26.0 -sudo yum versionlock add kubelet kubeadm kubectl kubernetes-cni cri-tools - -sudo systemctl daemon-reload -sudo systemctl enable --now kubelet -sudo systemctl restart kubelet - diff --git a/pkg/scripts/testdata/TestKubeadmCentOS-proxy.golden b/pkg/scripts/testdata/TestKubeadmCentOS-proxy.golden deleted file mode 100644 index 17c624856..000000000 --- a/pkg/scripts/testdata/TestKubeadmCentOS-proxy.golden +++ /dev/null @@ -1,154 +0,0 @@ -set -xeuo pipefail -export "PATH=$PATH:/sbin:/usr/local/bin:/opt/bin" - -sudo swapoff -a -sudo sed -i '/.*swap.*/d' /etc/fstab -sudo setenforce 0 || true -[ -f /etc/selinux/config ] && sudo sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config -sudo systemctl disable --now firewalld || true - -source /etc/kubeone/proxy-env - - -cat < /dev/null; then - sudo modprobe nf_conntrack_ipv4 -else - sudo modprobe nf_conntrack -fi -sudo mkdir -p /etc/sysctl.d -cat < /tmp/yum.conf || true -echo -n "${yum_proxy}" >> /tmp/yum.conf -sudo mv /tmp/yum.conf /etc/yum.conf - - -# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned -# repositories, otherwise, yum will fail to upgrade the packages because it's trying to -# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1). -repo_migration_needed=false - -if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then - repo_migration_needed=true -fi - -cat </dev/null - -sudo yum versionlock delete docker-ce docker-ce-cli containerd.io || true - -sudo yum install -y \ - docker-ce-'20.10.*' \ - docker-ce-cli-'20.10.*' \ - containerd.io-'1.6.*' -sudo yum versionlock add docker-ce docker-ce-cli containerd.io - -sudo mkdir -p $(dirname /etc/docker/daemon.json) -sudo touch /etc/docker/daemon.json -sudo chmod 600 /etc/docker/daemon.json -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - - - - -sudo yum install -y \ - kubelet-1.26.0 \ - kubeadm-1.26.0 \ - kubectl-1.26.0 \ - kubernetes-cni-1.2.0 \ - cri-tools-1.26.0 -sudo yum versionlock add kubelet kubeadm kubectl kubernetes-cni cri-tools - -sudo systemctl daemon-reload -sudo systemctl enable --now kubelet -sudo systemctl restart kubelet - diff --git a/pkg/scripts/testdata/TestKubeadmCentOS-simple.golden b/pkg/scripts/testdata/TestKubeadmCentOS-simple.golden deleted file mode 100644 index 9dfc23e54..000000000 --- a/pkg/scripts/testdata/TestKubeadmCentOS-simple.golden +++ /dev/null @@ -1,154 +0,0 @@ -set -xeuo pipefail -export "PATH=$PATH:/sbin:/usr/local/bin:/opt/bin" - -sudo swapoff -a -sudo sed -i '/.*swap.*/d' /etc/fstab -sudo setenforce 0 || true -[ -f /etc/selinux/config ] && sudo sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config -sudo systemctl disable --now firewalld || true - -source /etc/kubeone/proxy-env - - -cat < /dev/null; then - sudo modprobe nf_conntrack_ipv4 -else - sudo modprobe nf_conntrack -fi -sudo mkdir -p /etc/sysctl.d -cat < /tmp/yum.conf || true -echo -n "${yum_proxy}" >> /tmp/yum.conf -sudo mv /tmp/yum.conf /etc/yum.conf - - -# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned -# repositories, otherwise, yum will fail to upgrade the packages because it's trying to -# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1). -repo_migration_needed=false - -if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then - repo_migration_needed=true -fi - -cat </dev/null - -sudo yum versionlock delete docker-ce docker-ce-cli containerd.io || true - -sudo yum install -y \ - docker-ce-'20.10.*' \ - docker-ce-cli-'20.10.*' \ - containerd.io-'1.6.*' -sudo yum versionlock add docker-ce docker-ce-cli containerd.io - -sudo mkdir -p $(dirname /etc/docker/daemon.json) -sudo touch /etc/docker/daemon.json -sudo chmod 600 /etc/docker/daemon.json -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - - - - -sudo yum install -y \ - kubelet-1.26.0 \ - kubeadm-1.26.0 \ - kubectl-1.26.0 \ - kubernetes-cni-1.2.0 \ - cri-tools-1.26.0 -sudo yum versionlock add kubelet kubeadm kubectl kubernetes-cni cri-tools - -sudo systemctl daemon-reload -sudo systemctl enable --now kubelet -sudo systemctl restart kubelet - diff --git a/pkg/scripts/testdata/TestKubeadmCentOS-v1.16.1.golden b/pkg/scripts/testdata/TestKubeadmCentOS-v1.16.1.golden deleted file mode 100644 index 617e9be95..000000000 --- a/pkg/scripts/testdata/TestKubeadmCentOS-v1.16.1.golden +++ /dev/null @@ -1,135 +0,0 @@ -set -xeuo pipefail -export "PATH=$PATH:/sbin:/usr/local/bin:/opt/bin" - -sudo swapoff -a -sudo sed -i '/.*swap.*/d' /etc/fstab -sudo setenforce 0 || true -[ -f /etc/selinux/config ] && sudo sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config -sudo systemctl disable --now firewalld || true - -source /etc/kubeone/proxy-env - - -cat < /tmp/yum.conf || true -echo -n "${yum_proxy}" >> /tmp/yum.conf -sudo mv /tmp/yum.conf /etc/yum.conf - - -cat </dev/null - -sudo yum versionlock delete docker-ce docker-ce-cli containerd.io || true - -sudo yum install -y \ - docker-ce-'20.10.*' \ - docker-ce-cli-'20.10.*' \ - containerd.io-'1.5.*' -sudo yum versionlock add docker-ce docker-ce-cli containerd.io - -sudo mkdir -p $(dirname /etc/docker/daemon.json) -sudo touch /etc/docker/daemon.json -sudo chmod 600 /etc/docker/daemon.json -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - - - - -sudo yum install -y \ - kubelet-1.16.1 \ - kubeadm-1.16.1 \ - kubectl-1.16.1 \ - kubernetes-cni-0.8.7 -sudo yum versionlock add kubelet kubeadm kubectl kubernetes-cni - -sudo systemctl daemon-reload -sudo systemctl enable --now kubelet -sudo systemctl restart kubelet - diff --git a/pkg/scripts/testdata/TestKubeadmCentOS-with_containerd.golden b/pkg/scripts/testdata/TestKubeadmCentOS-with_containerd.golden index 13e6e7d04..de6834afa 100644 --- a/pkg/scripts/testdata/TestKubeadmCentOS-with_containerd.golden +++ b/pkg/scripts/testdata/TestKubeadmCentOS-with_containerd.golden @@ -95,8 +95,6 @@ sudo yum install -y \ - - sudo yum install -y yum-utils sudo yum-config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo sudo yum-config-manager --save --setopt=docker-ce-stable.module_hotfixes=true diff --git a/pkg/scripts/testdata/TestKubeadmCentOS-with_containerd_with_insecure_registry.golden b/pkg/scripts/testdata/TestKubeadmCentOS-with_containerd_with_insecure_registry.golden index 46ad34c55..5530ac946 100644 --- a/pkg/scripts/testdata/TestKubeadmCentOS-with_containerd_with_insecure_registry.golden +++ b/pkg/scripts/testdata/TestKubeadmCentOS-with_containerd_with_insecure_registry.golden @@ -95,8 +95,6 @@ sudo yum install -y \ - - sudo yum install -y yum-utils sudo yum-config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo sudo yum-config-manager --save --setopt=docker-ce-stable.module_hotfixes=true diff --git a/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden b/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden index dccee3833..c42a3dae5 100644 --- a/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden +++ b/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden @@ -71,8 +71,6 @@ cri_ver="1.26.0-*" - - sudo DEBIAN_FRONTEND=noninteractive apt-get install \ --option "Dpkg::Options::=--force-confold" \ --no-install-recommends \ diff --git a/pkg/scripts/testdata/TestKubeadmDebian-nutanix_cluster.golden b/pkg/scripts/testdata/TestKubeadmDebian-nutanix_cluster.golden index 3dd6f940a..aa18c04d5 100644 --- a/pkg/scripts/testdata/TestKubeadmDebian-nutanix_cluster.golden +++ b/pkg/scripts/testdata/TestKubeadmDebian-nutanix_cluster.golden @@ -74,8 +74,6 @@ cri_ver="1.26.0-*" - - sudo DEBIAN_FRONTEND=noninteractive apt-get install \ --option "Dpkg::Options::=--force-confold" \ --no-install-recommends \ diff --git a/pkg/scripts/testdata/TestKubeadmDebian-overwrite_registry.golden b/pkg/scripts/testdata/TestKubeadmDebian-overwrite_registry.golden deleted file mode 100644 index cb4d93543..000000000 --- a/pkg/scripts/testdata/TestKubeadmDebian-overwrite_registry.golden +++ /dev/null @@ -1,142 +0,0 @@ -set -xeuo pipefail -export "PATH=$PATH:/sbin:/usr/local/bin:/opt/bin" - -sudo swapoff -a -sudo sed -i '/.*swap.*/d' /etc/fstab -sudo systemctl disable --now ufw || true - -source /etc/kubeone/proxy-env - - -cat < /dev/null; then - sudo modprobe nf_conntrack_ipv4 -else - sudo modprobe nf_conntrack -fi -sudo mkdir -p /etc/sysctl.d -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - - - - -sudo DEBIAN_FRONTEND=noninteractive apt-get install \ - --option "Dpkg::Options::=--force-confold" \ - --no-install-recommends \ - -y \ - kubelet=${kube_ver} \ - kubeadm=${kube_ver} \ - kubectl=${kube_ver} \ - kubernetes-cni=${cni_ver} \ - cri-tools=${cri_ver} - -sudo apt-mark hold kubelet kubeadm kubectl kubernetes-cni cri-tools - -sudo systemctl daemon-reload -sudo systemctl enable --now kubelet -sudo systemctl restart kubelet diff --git a/pkg/scripts/testdata/TestKubeadmDebian-overwrite_registry_insecure.golden b/pkg/scripts/testdata/TestKubeadmDebian-overwrite_registry_insecure.golden deleted file mode 100644 index be3960538..000000000 --- a/pkg/scripts/testdata/TestKubeadmDebian-overwrite_registry_insecure.golden +++ /dev/null @@ -1,145 +0,0 @@ -set -xeuo pipefail -export "PATH=$PATH:/sbin:/usr/local/bin:/opt/bin" - -sudo swapoff -a -sudo sed -i '/.*swap.*/d' /etc/fstab -sudo systemctl disable --now ufw || true - -source /etc/kubeone/proxy-env - - -cat < /dev/null; then - sudo modprobe nf_conntrack_ipv4 -else - sudo modprobe nf_conntrack -fi -sudo mkdir -p /etc/sysctl.d -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - - - - -sudo DEBIAN_FRONTEND=noninteractive apt-get install \ - --option "Dpkg::Options::=--force-confold" \ - --no-install-recommends \ - -y \ - kubelet=${kube_ver} \ - kubeadm=${kube_ver} \ - kubectl=${kube_ver} \ - kubernetes-cni=${cni_ver} \ - cri-tools=${cri_ver} - -sudo apt-mark hold kubelet kubeadm kubectl kubernetes-cni cri-tools - -sudo systemctl daemon-reload -sudo systemctl enable --now kubelet -sudo systemctl restart kubelet diff --git a/pkg/scripts/testdata/TestKubeadmDebian-simple.golden b/pkg/scripts/testdata/TestKubeadmDebian-simple.golden deleted file mode 100644 index cb4d93543..000000000 --- a/pkg/scripts/testdata/TestKubeadmDebian-simple.golden +++ /dev/null @@ -1,142 +0,0 @@ -set -xeuo pipefail -export "PATH=$PATH:/sbin:/usr/local/bin:/opt/bin" - -sudo swapoff -a -sudo sed -i '/.*swap.*/d' /etc/fstab -sudo systemctl disable --now ufw || true - -source /etc/kubeone/proxy-env - - -cat < /dev/null; then - sudo modprobe nf_conntrack_ipv4 -else - sudo modprobe nf_conntrack -fi -sudo mkdir -p /etc/sysctl.d -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - - - - -sudo DEBIAN_FRONTEND=noninteractive apt-get install \ - --option "Dpkg::Options::=--force-confold" \ - --no-install-recommends \ - -y \ - kubelet=${kube_ver} \ - kubeadm=${kube_ver} \ - kubectl=${kube_ver} \ - kubernetes-cni=${cni_ver} \ - cri-tools=${cri_ver} - -sudo apt-mark hold kubelet kubeadm kubectl kubernetes-cni cri-tools - -sudo systemctl daemon-reload -sudo systemctl enable --now kubelet -sudo systemctl restart kubelet diff --git a/pkg/scripts/testdata/TestKubeadmDebian-with_containerd.golden b/pkg/scripts/testdata/TestKubeadmDebian-with_containerd.golden index 9b2289edf..27acd053c 100644 --- a/pkg/scripts/testdata/TestKubeadmDebian-with_containerd.golden +++ b/pkg/scripts/testdata/TestKubeadmDebian-with_containerd.golden @@ -71,8 +71,6 @@ cri_ver="1.26.0-*" - - sudo apt-get update sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common lsb-release curl -fsSL https://download.docker.com/linux/$(lsb_release -si | tr '[:upper:]' '[:lower:]')/gpg | diff --git a/pkg/scripts/testdata/TestKubeadmDebian-with_containerd_with_insecure_registry.golden b/pkg/scripts/testdata/TestKubeadmDebian-with_containerd_with_insecure_registry.golden index 92514fd8c..36b029319 100644 --- a/pkg/scripts/testdata/TestKubeadmDebian-with_containerd_with_insecure_registry.golden +++ b/pkg/scripts/testdata/TestKubeadmDebian-with_containerd_with_insecure_registry.golden @@ -71,8 +71,6 @@ cri_ver="1.26.0-*" - - sudo apt-get update sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common lsb-release curl -fsSL https://download.docker.com/linux/$(lsb_release -si | tr '[:upper:]' '[:lower:]')/gpg | diff --git a/pkg/scripts/testdata/TestKubeadmFlatcar-force.golden b/pkg/scripts/testdata/TestKubeadmFlatcar-force.golden index 446e8be0c..ed5638986 100644 --- a/pkg/scripts/testdata/TestKubeadmFlatcar-force.golden +++ b/pkg/scripts/testdata/TestKubeadmFlatcar-force.golden @@ -66,34 +66,46 @@ curl -L https://github.com/kubernetes-sigs/cri-tools/releases/download/${CRI_TOO -sudo mkdir -p $(dirname /etc/docker/daemon.json) -sudo touch /etc/docker/daemon.json -sudo chmod 600 /etc/docker/daemon.json -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi +sudo mkdir -p /etc/systemd/system/containerd.service.d +cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi +sudo mkdir -p /etc/systemd/system/containerd.service.d +cat < /dev/null; then - sudo modprobe nf_conntrack_ipv4 -else - sudo modprobe nf_conntrack -fi -sudo mkdir -p /etc/sysctl.d -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - - - - -cd /opt/bin -k8s_rel_baseurl=https://dl.k8s.io -for binary in kubeadm kubelet kubectl; do - curl -L --output /tmp/$binary \ - $k8s_rel_baseurl/${RELEASE}/bin/linux/${HOST_ARCH}/$binary - sudo install --owner=0 --group=0 --mode=0755 /tmp/$binary /opt/bin/$binary - rm /tmp/$binary -done - -cat < /dev/null; then - sudo modprobe nf_conntrack_ipv4 -else - sudo modprobe nf_conntrack -fi -sudo mkdir -p /etc/sysctl.d -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - - - - -cd /opt/bin -k8s_rel_baseurl=https://dl.k8s.io -for binary in kubeadm kubelet kubectl; do - curl -L --output /tmp/$binary \ - $k8s_rel_baseurl/${RELEASE}/bin/linux/${HOST_ARCH}/$binary - sudo install --owner=0 --group=0 --mode=0755 /tmp/$binary /opt/bin/$binary - rm /tmp/$binary -done - -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - diff --git a/pkg/scripts/testdata/TestUpgradeKubeadmAndCNICentOS.golden b/pkg/scripts/testdata/TestUpgradeKubeadmAndCNICentOS.golden index f98aa87a8..08760a4e7 100644 --- a/pkg/scripts/testdata/TestUpgradeKubeadmAndCNICentOS.golden +++ b/pkg/scripts/testdata/TestUpgradeKubeadmAndCNICentOS.golden @@ -97,46 +97,45 @@ sudo yum install -y \ sudo yum install -y yum-utils sudo yum-config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo -sudo yum-config-manager --save --setopt=docker-ce-stable.module_hotfixes=true >/dev/null +sudo yum-config-manager --save --setopt=docker-ce-stable.module_hotfixes=true -sudo yum versionlock delete docker-ce docker-ce-cli containerd.io || true -sudo yum install -y \ - docker-ce-'20.10.*' \ - docker-ce-cli-'20.10.*' \ - containerd.io-'1.6.*' -sudo yum versionlock add docker-ce docker-ce-cli containerd.io - -sudo mkdir -p $(dirname /etc/docker/daemon.json) -sudo touch /etc/docker/daemon.json -sudo chmod 600 /etc/docker/daemon.json -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - sudo yum versionlock delete kubelet kubeadm kubectl kubernetes-cni cri-tools || true diff --git a/pkg/scripts/testdata/TestUpgradeKubeadmAndCNIDebian.golden b/pkg/scripts/testdata/TestUpgradeKubeadmAndCNIDebian.golden index 7ea516c74..0a89e8faf 100644 --- a/pkg/scripts/testdata/TestUpgradeKubeadmAndCNIDebian.golden +++ b/pkg/scripts/testdata/TestUpgradeKubeadmAndCNIDebian.golden @@ -72,57 +72,53 @@ sudo apt-mark unhold kubelet kubeadm kubectl kubernetes-cni cri-tools -sudo install -m 0755 -d /etc/apt/keyrings -curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg -# Docker provides two different apt repos for ubuntu, bionic and focal. The focal repo currently -# contains only Docker 19.03.14, which is not validated for all Kubernetes version. -# Therefore, we use bionic repo which has all Docker versions. -echo "deb [signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu bionic stable" | - sudo tee /etc/apt/sources.list.d/docker.list sudo apt-get update +sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common lsb-release +curl -fsSL https://download.docker.com/linux/$(lsb_release -si | tr '[:upper:]' '[:lower:]')/gpg | + sudo apt-key add - +sudo add-apt-repository "deb https://download.docker.com/linux/$(lsb_release -si | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" -sudo apt-mark unhold docker-ce docker-ce-cli containerd.io || true - +sudo apt-mark unhold containerd.io || true sudo DEBIAN_FRONTEND=noninteractive apt-get install \ --option "Dpkg::Options::=--force-confold" \ --no-install-recommends \ -y \ - docker-ce=5:'20.10.*' \ - docker-ce-cli=5:'20.10.*' \ containerd.io='1.6.*' -sudo apt-mark hold docker-ce docker-ce-cli containerd.io - -sudo mkdir -p $(dirname /etc/docker/daemon.json) -sudo touch /etc/docker/daemon.json -sudo chmod 600 /etc/docker/daemon.json -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - diff --git a/pkg/scripts/testdata/TestUpgradeKubeletAndKubectlAmazonLinux.golden b/pkg/scripts/testdata/TestUpgradeKubeletAndKubectlAmazonLinux.golden index 6163832d5..cd8e776cf 100644 --- a/pkg/scripts/testdata/TestUpgradeKubeletAndKubectlAmazonLinux.golden +++ b/pkg/scripts/testdata/TestUpgradeKubeletAndKubectlAmazonLinux.golden @@ -88,43 +88,42 @@ sudo yum install -y \ rsync -sudo yum versionlock delete docker containerd || true +sudo yum versionlock delete containerd || true +sudo yum install -y containerd-'1.6.*' +sudo yum versionlock add containerd + + +sudo mkdir -p $(dirname /etc/containerd/config.toml) +sudo touch /etc/containerd/config.toml +sudo chmod 600 /etc/containerd/config.toml +cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - diff --git a/pkg/scripts/testdata/TestUpgradeKubeletAndKubectlCentOS.golden b/pkg/scripts/testdata/TestUpgradeKubeletAndKubectlCentOS.golden index c1ed59051..a02d104b3 100644 --- a/pkg/scripts/testdata/TestUpgradeKubeletAndKubectlCentOS.golden +++ b/pkg/scripts/testdata/TestUpgradeKubeletAndKubectlCentOS.golden @@ -97,46 +97,45 @@ sudo yum install -y \ sudo yum install -y yum-utils sudo yum-config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo -sudo yum-config-manager --save --setopt=docker-ce-stable.module_hotfixes=true >/dev/null +sudo yum-config-manager --save --setopt=docker-ce-stable.module_hotfixes=true -sudo yum versionlock delete docker-ce docker-ce-cli containerd.io || true -sudo yum install -y \ - docker-ce-'20.10.*' \ - docker-ce-cli-'20.10.*' \ - containerd.io-'1.6.*' -sudo yum versionlock add docker-ce docker-ce-cli containerd.io - -sudo mkdir -p $(dirname /etc/docker/daemon.json) -sudo touch /etc/docker/daemon.json -sudo chmod 600 /etc/docker/daemon.json -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - sudo yum versionlock delete kubelet kubeadm kubectl kubernetes-cni cri-tools || true diff --git a/pkg/scripts/testdata/TestUpgradeKubeletAndKubectlDebian.golden b/pkg/scripts/testdata/TestUpgradeKubeletAndKubectlDebian.golden index c5431f204..a02922d4f 100644 --- a/pkg/scripts/testdata/TestUpgradeKubeletAndKubectlDebian.golden +++ b/pkg/scripts/testdata/TestUpgradeKubeletAndKubectlDebian.golden @@ -72,57 +72,53 @@ sudo apt-mark unhold kubelet kubeadm kubectl kubernetes-cni cri-tools -sudo install -m 0755 -d /etc/apt/keyrings -curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg -# Docker provides two different apt repos for ubuntu, bionic and focal. The focal repo currently -# contains only Docker 19.03.14, which is not validated for all Kubernetes version. -# Therefore, we use bionic repo which has all Docker versions. -echo "deb [signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu bionic stable" | - sudo tee /etc/apt/sources.list.d/docker.list sudo apt-get update +sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common lsb-release +curl -fsSL https://download.docker.com/linux/$(lsb_release -si | tr '[:upper:]' '[:lower:]')/gpg | + sudo apt-key add - +sudo add-apt-repository "deb https://download.docker.com/linux/$(lsb_release -si | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" -sudo apt-mark unhold docker-ce docker-ce-cli containerd.io || true - +sudo apt-mark unhold containerd.io || true sudo DEBIAN_FRONTEND=noninteractive apt-get install \ --option "Dpkg::Options::=--force-confold" \ --no-install-recommends \ -y \ - docker-ce=5:'20.10.*' \ - docker-ce-cli=5:'20.10.*' \ containerd.io='1.6.*' -sudo apt-mark hold docker-ce docker-ce-cli containerd.io - -sudo mkdir -p $(dirname /etc/docker/daemon.json) -sudo touch /etc/docker/daemon.json -sudo chmod 600 /etc/docker/daemon.json -cat <&1 > /dev/null; then - sudo systemctl restart kubelet - sleep 10 -fi - - diff --git a/pkg/state/cluster.go b/pkg/state/cluster.go index ec1175f06..c33269518 100644 --- a/pkg/state/cluster.go +++ b/pkg/state/cluster.go @@ -57,7 +57,6 @@ type CCMStatus struct { type Host struct { Config *kubeoneapi.HostConfig - ContainerRuntimeDocker ComponentStatus ContainerRuntimeContainerd ComponentStatus Kubelet ComponentStatus @@ -282,7 +281,7 @@ func (h *Host) Initialized() bool { // IsProvisioned checks are CRI and Kubelet provisioned on a host func (h *Host) IsProvisioned() bool { - return (h.ContainerRuntimeDocker.IsProvisioned() || h.ContainerRuntimeContainerd.IsProvisioned()) && h.Kubelet.IsProvisioned() + return (h.ContainerRuntimeContainerd.IsProvisioned()) && h.Kubelet.IsProvisioned() } // ControlPlaneHealthy checks is a control-plane host part of the cluster and are CRI, Kubelet, and API server healthy @@ -296,17 +295,7 @@ func (h *Host) WorkerHealthy() bool { } func (h *Host) healthy() bool { - var crStatus bool - - if h.ContainerRuntimeDocker.IsProvisioned() { - // docker + containerd are installed - crStatus = h.ContainerRuntimeDocker.Healthy() && h.ContainerRuntimeContainerd.Healthy() - } else { - // only containerd is installed - crStatus = h.ContainerRuntimeContainerd.Healthy() - } - - return h.IsInCluster && crStatus && h.Kubelet.Healthy() + return h.IsInCluster && h.ContainerRuntimeContainerd.Healthy() && h.Kubelet.Healthy() } /* diff --git a/pkg/tasks/probes.go b/pkg/tasks/probes.go index 15b01fa66..f9eb205d5 100644 --- a/pkg/tasks/probes.go +++ b/pkg/tasks/probes.go @@ -374,31 +374,6 @@ func runProbes(s *state.State) error { s.LiveCluster.CCMClusterName = clusterName s.LiveCluster.Lock.Unlock() - switch { - case s.Cluster.ContainerRuntime.Containerd != nil: - return nil - case s.Cluster.ContainerRuntime.Docker != nil: - return nil - } - - gteKube124Condition, _ := semver.NewConstraint(">= 1.24") - - switch { - case gteKube124Condition.Check(s.LiveCluster.ExpectedVersion): - s.Cluster.ContainerRuntime.Containerd = &kubeoneapi.ContainerRuntimeContainerd{} - - if s.LiveCluster.IsProvisioned() { - for _, host := range s.LiveCluster.ControlPlane { - if host.ContainerRuntimeDocker.IsProvisioned() { - s.Cluster.ContainerRuntime.Docker = &kubeoneapi.ContainerRuntimeDocker{} - s.Cluster.ContainerRuntime.Containerd = nil - } - } - } - default: - s.Cluster.ContainerRuntime.Docker = &kubeoneapi.ContainerRuntimeDocker{} - } - return nil } @@ -459,11 +434,6 @@ func investigateHost(s *state.State, node *kubeoneapi.HostConfig, conn executor. return err } - foundHost.ContainerRuntimeDocker, err = systemdUnitInfo("docker", conn, containerRuntimeOpts...) - if err != nil { - return err - } - foundHost.Kubelet, err = systemdUnitInfo("kubelet", conn, withComponentVersion(kubeletVersionCmdGenerator)) if err != nil { return err @@ -770,7 +740,9 @@ func detectEncryptionProvidersEnabled(s *state.State) (ees encryptionEnabledStat err = s.DynamicClient.List(s.Context, &pods, &dynclient.ListOptions{ Namespace: "kube-system", LabelSelector: labels.SelectorFromSet(map[string]string{ - "component": "kube-apiserver"})}) + "component": "kube-apiserver", + }), + }) if err != nil { return ees, fail.KubeClient(err, "listing kube-apiserver pods") } From 54378b9d1acdeefa7fcb17216f5e17ac2598942f Mon Sep 17 00:00:00 2001 From: Artiom Diomin Date: Mon, 15 Jan 2024 15:54:44 +0200 Subject: [PATCH 2/8] Delete docker testdata --- test/e2e/testdata/docker_calico.yaml | 18 -------- test/e2e/testdata/docker_cilium.yaml | 18 -------- test/e2e/testdata/docker_simple.yaml | 13 ------ test/e2e/testdata/docker_simple_external.yaml | 16 ------- test/e2e/testdata/docker_weave.yaml | 17 ------- .../legacy_machine_controller_docker.yaml | 16 ------- ...cy_machine_controller_docker_external.yaml | 19 -------- test/e2e/tests_definitions.go | 44 ------------------- 8 files changed, 161 deletions(-) delete mode 100644 test/e2e/testdata/docker_calico.yaml delete mode 100644 test/e2e/testdata/docker_cilium.yaml delete mode 100644 test/e2e/testdata/docker_simple.yaml delete mode 100644 test/e2e/testdata/docker_simple_external.yaml delete mode 100644 test/e2e/testdata/docker_weave.yaml delete mode 100644 test/e2e/testdata/legacy_machine_controller_docker.yaml delete mode 100644 test/e2e/testdata/legacy_machine_controller_docker_external.yaml diff --git a/test/e2e/testdata/docker_calico.yaml b/test/e2e/testdata/docker_calico.yaml deleted file mode 100644 index 4cd4b744c..000000000 --- a/test/e2e/testdata/docker_calico.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kubeone.k8c.io/v1beta2 -kind: KubeOneCluster - -versions: - kubernetes: "{{ required ".VERSION is required" .VERSION }}" - -containerRuntime: - docker: {} - -clusterNetwork: - cni: - external: {} - -addons: - enable: true - addons: - - name: default-storage-class - - name: calico-vxlan diff --git a/test/e2e/testdata/docker_cilium.yaml b/test/e2e/testdata/docker_cilium.yaml deleted file mode 100644 index 23ebd5187..000000000 --- a/test/e2e/testdata/docker_cilium.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kubeone.k8c.io/v1beta2 -kind: KubeOneCluster - -versions: - kubernetes: "{{ required ".VERSION is required" .VERSION }}" - -containerRuntime: - docker: {} - -clusterNetwork: - cni: - cilium: - enableHubble: true - -addons: - enable: true - addons: - - name: default-storage-class diff --git a/test/e2e/testdata/docker_simple.yaml b/test/e2e/testdata/docker_simple.yaml deleted file mode 100644 index 495e00fe5..000000000 --- a/test/e2e/testdata/docker_simple.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: kubeone.k8c.io/v1beta2 -kind: KubeOneCluster - -versions: - kubernetes: "{{ required ".VERSION is required" .VERSION }}" - -containerRuntime: - docker: {} - -addons: - enable: true - addons: - - name: default-storage-class diff --git a/test/e2e/testdata/docker_simple_external.yaml b/test/e2e/testdata/docker_simple_external.yaml deleted file mode 100644 index 74ab07ae8..000000000 --- a/test/e2e/testdata/docker_simple_external.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kubeone.k8c.io/v1beta2 -kind: KubeOneCluster - -versions: - kubernetes: "{{ required ".VERSION is required" .VERSION }}" - -containerRuntime: - docker: {} - -addons: - enable: true - addons: - - name: default-storage-class - -cloudProvider: - external: true diff --git a/test/e2e/testdata/docker_weave.yaml b/test/e2e/testdata/docker_weave.yaml deleted file mode 100644 index d0090aac2..000000000 --- a/test/e2e/testdata/docker_weave.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: kubeone.k8c.io/v1beta2 -kind: KubeOneCluster - -versions: - kubernetes: "{{ required ".VERSION is required" .VERSION }}" - -containerRuntime: - docker: {} - -clusterNetwork: - cni: - weaveNet: {} - -addons: - enable: true - addons: - - name: default-storage-class diff --git a/test/e2e/testdata/legacy_machine_controller_docker.yaml b/test/e2e/testdata/legacy_machine_controller_docker.yaml deleted file mode 100644 index 0559ee673..000000000 --- a/test/e2e/testdata/legacy_machine_controller_docker.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kubeone.k8c.io/v1beta2 -kind: KubeOneCluster - -versions: - kubernetes: "{{ required ".VERSION is required" .VERSION }}" - -containerRuntime: - docker: {} - -operatingSystemManager: - deploy: false - -addons: - enable: true - addons: - - name: default-storage-class diff --git a/test/e2e/testdata/legacy_machine_controller_docker_external.yaml b/test/e2e/testdata/legacy_machine_controller_docker_external.yaml deleted file mode 100644 index 84e6023c8..000000000 --- a/test/e2e/testdata/legacy_machine_controller_docker_external.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kubeone.k8c.io/v1beta2 -kind: KubeOneCluster - -versions: - kubernetes: "{{ required ".VERSION is required" .VERSION }}" - -containerRuntime: - docker: {} - -operatingSystemManager: - deploy: false - -cloudProvider: - external: true - -addons: - enable: true - addons: - - name: default-storage-class diff --git a/test/e2e/tests_definitions.go b/test/e2e/tests_definitions.go index 3c4cb1b19..06b127947 100644 --- a/test/e2e/tests_definitions.go +++ b/test/e2e/tests_definitions.go @@ -1378,20 +1378,6 @@ var ( } Scenarios = map[string]Scenario{ - // docker - "install_docker": &scenarioInstall{ - Name: "install_docker", - ManifestTemplatePath: "testdata/docker_simple.yaml", - }, - "upgrade_docker": &scenarioUpgrade{ - Name: "upgrade_docker", - ManifestTemplatePath: "testdata/docker_simple.yaml", - }, - "conformance_docker": &scenarioConformance{ - Name: "conformance_docker", - ManifestTemplatePath: "testdata/docker_simple.yaml", - }, - // containerd "install_containerd": &scenarioInstall{ Name: "install_containerd", @@ -1406,20 +1392,6 @@ var ( ManifestTemplatePath: "testdata/containerd_simple.yaml", }, - // docker external - "install_docker_external": &scenarioInstall{ - Name: "install_docker_external", - ManifestTemplatePath: "testdata/docker_simple_external.yaml", - }, - "upgrade_docker_external": &scenarioUpgrade{ - Name: "upgrade_docker_external", - ManifestTemplatePath: "testdata/docker_simple_external.yaml", - }, - "conformance_docker_external": &scenarioConformance{ - Name: "conformance_docker_external", - ManifestTemplatePath: "testdata/docker_simple_external.yaml", - }, - // external containerd "install_containerd_external": &scenarioInstall{ Name: "install_containerd_external", @@ -1443,18 +1415,10 @@ var ( Name: "calico_containerd_external", ManifestTemplatePath: "testdata/containerd_calico_external.yaml", }, - "calico_docker": &scenarioInstall{ - Name: "calico_docker", - ManifestTemplatePath: "testdata/docker_calico.yaml", - }, "weave_containerd": &scenarioInstall{ Name: "weave_containerd", ManifestTemplatePath: "testdata/containerd_weave.yaml", }, - "weave_docker": &scenarioInstall{ - Name: "weave_docker", - ManifestTemplatePath: "testdata/docker_weave.yaml", - }, "cilium_containerd": &scenarioInstall{ Name: "cilium_containerd", ManifestTemplatePath: "testdata/containerd_cilium.yaml", @@ -1471,10 +1435,6 @@ var ( Name: "upgrade_cilium_containerd_external", ManifestTemplatePath: "testdata/containerd_cilium_external.yaml", }, - "cilium_docker": &scenarioInstall{ - Name: "cilium_docker", - ManifestTemplatePath: "testdata/docker_cilium.yaml", - }, "kube_proxy_ipvs_external": &scenarioInstall{ Name: "kube_proxy_ipvs_external", ManifestTemplatePath: "testdata/kube_proxy_ipvs_external.yaml", @@ -1483,10 +1443,6 @@ var ( Name: "legacy_machine_controller_containerd", ManifestTemplatePath: "testdata/legacy_machine_controller_containerd.yaml", }, - "legacy_machine_controller_docker": &scenarioInstall{ - Name: "legacy_machine_controller_docker", - ManifestTemplatePath: "testdata/legacy_machine_controller_docker.yaml", - }, "legacy_machine_controller_containerd_external": &scenarioInstall{ Name: "legacy_machine_controller_containerd_external", ManifestTemplatePath: "testdata/legacy_machine_controller_containerd_external.yaml", From c5cd01ac41a61f409dca88d16bf869705f301627 Mon Sep 17 00:00:00 2001 From: Artiom Diomin Date: Mon, 15 Jan 2024 15:59:03 +0200 Subject: [PATCH 3/8] Fix linter Signed-off-by: Artiom Diomin --- pkg/apis/kubeone/helpers.go | 103 +++++++++++++++--------------------- pkg/containerruntime/map.go | 11 +--- 2 files changed, 44 insertions(+), 70 deletions(-) diff --git a/pkg/apis/kubeone/helpers.go b/pkg/apis/kubeone/helpers.go index b49c2cf87..5ed95ca2c 100644 --- a/pkg/apis/kubeone/helpers.go +++ b/pkg/apis/kubeone/helpers.go @@ -129,73 +129,66 @@ func (h *HostConfig) SetLeader(leader bool) { func (crc ContainerRuntimeConfig) MachineControllerFlags() []string { var mcFlags []string - switch { - case crc.Containerd != nil: - // example output: - // -node-containerd-registry-mirrors=docker.io=custom.tld - // -node-containerd-registry-mirrors=docker.io=https://secure-custom.tld - // -node-containerd-registry-mirrors=registry.k8s.io=http://somewhere - // -node-insecure-registries=docker.io,registry.k8s.io - var ( - registryNames []string - insecureSet = map[string]struct{}{} - registryCredentialsSecretFlag bool - ) - - for registry := range crc.Containerd.Registries { - registryNames = append(registryNames, registry) - } - // because iterating over map is randomized, we need this to have a "stable" output list - sort.Strings(registryNames) + // example output: + // -node-containerd-registry-mirrors=docker.io=custom.tld + // -node-containerd-registry-mirrors=docker.io=https://secure-custom.tld + // -node-containerd-registry-mirrors=registry.k8s.io=http://somewhere + // -node-insecure-registries=docker.io,registry.k8s.io + var ( + registryNames []string + insecureSet = map[string]struct{}{} + registryCredentialsSecretFlag bool + ) - for _, registryName := range registryNames { - containerdRegistry := crc.Containerd.Registries[registryName] - if containerdRegistry.TLSConfig != nil && containerdRegistry.TLSConfig.InsecureSkipVerify { - insecureSet[registryName] = struct{}{} - } + for registry := range crc.Containerd.Registries { + registryNames = append(registryNames, registry) + } - for _, mirror := range containerdRegistry.Mirrors { - mcFlags = append(mcFlags, - fmt.Sprintf("-node-containerd-registry-mirrors=%s=%s", registryName, mirror), - ) - } + // because iterating over map is randomized, we need this to have a "stable" output list + sort.Strings(registryNames) - if containerdRegistry.Auth != nil { - registryCredentialsSecretFlag = true - } + for _, registryName := range registryNames { + containerdRegistry := crc.Containerd.Registries[registryName] + if containerdRegistry.TLSConfig != nil && containerdRegistry.TLSConfig.InsecureSkipVerify { + insecureSet[registryName] = struct{}{} } - if registryCredentialsSecretFlag { + for _, mirror := range containerdRegistry.Mirrors { mcFlags = append(mcFlags, - fmt.Sprintf("-node-registry-credentials-secret=%s", credentialSecretName), + fmt.Sprintf("-node-containerd-registry-mirrors=%s=%s", registryName, mirror), ) } - if len(insecureSet) > 0 { - insecureNames := []string{} + if containerdRegistry.Auth != nil { + registryCredentialsSecretFlag = true + } + } + + if registryCredentialsSecretFlag { + mcFlags = append(mcFlags, + fmt.Sprintf("-node-registry-credentials-secret=%s", credentialSecretName), + ) + } - for insecureName := range insecureSet { - insecureNames = append(insecureNames, insecureName) - } + if len(insecureSet) > 0 { + insecureNames := []string{} - sort.Strings(insecureNames) - mcFlags = append(mcFlags, - fmt.Sprintf("-node-insecure-registries=%s", strings.Join(insecureNames, ",")), - ) + for insecureName := range insecureSet { + insecureNames = append(insecureNames, insecureName) } + + sort.Strings(insecureNames) + mcFlags = append(mcFlags, + fmt.Sprintf("-node-insecure-registries=%s", strings.Join(insecureNames, ",")), + ) } return mcFlags } func (crc ContainerRuntimeConfig) String() string { - switch { - case crc.Containerd != nil: - return "containerd" - } - - return "unknown" + return "containerd" } func (crc *ContainerRuntimeConfig) UnmarshalText(text []byte) error { @@ -210,21 +203,11 @@ func (crc *ContainerRuntimeConfig) UnmarshalText(text []byte) error { } func (crc ContainerRuntimeConfig) ConfigPath() string { - switch { - case crc.Containerd != nil: - return "/etc/containerd/config.toml" - } - - return "" + return "/etc/containerd/config.toml" } func (crc ContainerRuntimeConfig) CRISocket() string { - switch { - case crc.Containerd != nil: - return "/run/containerd/containerd.sock" - } - - return "" + return "/run/containerd/containerd.sock" } // SandboxImage is used to determine the pause image version that should be used, diff --git a/pkg/containerruntime/map.go b/pkg/containerruntime/map.go index 94fad16b6..dbd7c1da1 100644 --- a/pkg/containerruntime/map.go +++ b/pkg/containerruntime/map.go @@ -19,16 +19,7 @@ package containerruntime import kubeoneapi "k8c.io/kubeone/pkg/apis/kubeone" func UpdateDataMap(cluster *kubeoneapi.KubeOneCluster, inputMap map[string]interface{}) error { - var ( - crConfig string - err error - ) - - switch { - case cluster.ContainerRuntime.Containerd != nil: - crConfig, err = marshalContainerdConfig(cluster) - } - + crConfig, err := marshalContainerdConfig(cluster) if err != nil { return err } From a624f0240afc8ca1d5087b704bc4d22dbb9262b8 Mon Sep 17 00:00:00 2001 From: Artiom Diomin Date: Tue, 16 Jan 2024 16:17:57 +0200 Subject: [PATCH 4/8] default to containerd --- pkg/apis/kubeone/v1beta2/defaults.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pkg/apis/kubeone/v1beta2/defaults.go b/pkg/apis/kubeone/v1beta2/defaults.go index 421497418..46c90b37b 100644 --- a/pkg/apis/kubeone/v1beta2/defaults.go +++ b/pkg/apis/kubeone/v1beta2/defaults.go @@ -156,14 +156,7 @@ func SetDefaults_Versions(obj *KubeOneCluster) { } func SetDefaults_ContainerRuntime(obj *KubeOneCluster) { - switch { - case obj.ContainerRuntime.Docker != nil: - return - case obj.ContainerRuntime.Containerd != nil: - return - default: - obj.ContainerRuntime.Containerd = &ContainerRuntimeContainerd{} - } + obj.ContainerRuntime.Containerd = &ContainerRuntimeContainerd{} } func SetDefaults_ClusterNetwork(obj *KubeOneCluster) { From b13736f883ac7a58d6bcc07c269fdae8e0f6a1a5 Mon Sep 17 00:00:00 2001 From: Artiom Diomin Date: Wed, 17 Jan 2024 17:06:37 +0200 Subject: [PATCH 5/8] Add missing conversions Signed-off-by: Artiom Diomin --- pkg/apis/kubeone/v1beta1/conversion.go | 4 ++-- pkg/apis/kubeone/v1beta2/conversion.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/apis/kubeone/v1beta1/conversion.go b/pkg/apis/kubeone/v1beta1/conversion.go index 98b740d4a..ee8a6a62d 100644 --- a/pkg/apis/kubeone/v1beta1/conversion.go +++ b/pkg/apis/kubeone/v1beta1/conversion.go @@ -101,6 +101,6 @@ func Convert_kubeone_Addon_To_v1beta1_Addon(in *kubeoneapi.Addon, out *Addon, s return autoConvert_kubeone_Addon_To_v1beta1_Addon(in, out, s) } -func Convert_v1beta1_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(*ContainerRuntimeConfig, *kubeoneapi.ContainerRuntimeConfig, conversion.Scope) error { - return nil +func Convert_v1beta1_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(in *ContainerRuntimeConfig, out *kubeoneapi.ContainerRuntimeConfig, scope conversion.Scope) error { + return autoConvert_v1beta1_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(in, out, scope) } diff --git a/pkg/apis/kubeone/v1beta2/conversion.go b/pkg/apis/kubeone/v1beta2/conversion.go index 9d353dcaf..70ff8ed60 100644 --- a/pkg/apis/kubeone/v1beta2/conversion.go +++ b/pkg/apis/kubeone/v1beta2/conversion.go @@ -27,6 +27,6 @@ func Convert_kubeone_KubeOneCluster_To_v1beta2_KubeOneCluster(in *kubeoneapi.Kub return autoConvert_kubeone_KubeOneCluster_To_v1beta2_KubeOneCluster(in, out, scope) } -func Convert_v1beta2_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(*ContainerRuntimeConfig, *kubeoneapi.ContainerRuntimeConfig, conversion.Scope) error { - return nil +func Convert_v1beta2_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(in *ContainerRuntimeConfig, out *kubeoneapi.ContainerRuntimeConfig, scope conversion.Scope) error { + return autoConvert_v1beta2_ContainerRuntimeConfig_To_kubeone_ContainerRuntimeConfig(in, out, scope) } From 021d5931621e8b769377b9baf9df9ca637af7a86 Mon Sep 17 00:00:00 2001 From: Artiom Diomin Date: Wed, 17 Jan 2024 18:59:59 +0200 Subject: [PATCH 6/8] Fix unit tests Signed-off-by: Artiom Diomin --- pkg/scripts/os_test.go | 44 +++++++--------- .../TestKubeadmAmazonLinux-with_cilium.golden | 38 ++++++++++++++ .../TestKubeadmCentOS-cilium_cluster.golden | 44 ++++++++++++++++ .../TestKubeadmCentOS-nutanix_cluster.golden | 44 ++++++++++++++++ .../TestKubeadmDebian-cilium_cluster.golden | 50 +++++++++++++++++++ .../TestKubeadmDebian-nutanix_cluster.golden | 50 +++++++++++++++++++ .../TestKubeadmFlatcar-with_cilium.golden | 44 ++++++++++++++++ 7 files changed, 287 insertions(+), 27 deletions(-) diff --git a/pkg/scripts/os_test.go b/pkg/scripts/os_test.go index a1e678443..aeef80c5b 100644 --- a/pkg/scripts/os_test.go +++ b/pkg/scripts/os_test.go @@ -26,10 +26,6 @@ import ( type genClusterOpts func(*kubeoneapi.KubeOneCluster) -func withContainerd(cls *kubeoneapi.KubeOneCluster) { - cls.ContainerRuntime.Containerd = &kubeoneapi.ContainerRuntimeContainerd{} -} - func withKubeVersion(ver string) genClusterOpts { return func(cls *kubeoneapi.KubeOneCluster) { cls.Versions.Kubernetes = ver @@ -94,6 +90,9 @@ func genCluster(opts ...genClusterOpts) kubeoneapi.KubeOneCluster { Versions: kubeoneapi.VersionConfig{ Kubernetes: "1.26.0", }, + ContainerRuntime: kubeoneapi.ContainerRuntimeConfig{ + Containerd: &kubeoneapi.ContainerRuntimeContainerd{}, + }, SystemPackages: &kubeoneapi.SystemPackages{ ConfigureRepositories: true, }, @@ -129,13 +128,13 @@ func TestKubeadmDebian(t *testing.T) { { name: "with containerd", args: args{ - cluster: genCluster(withContainerd), + cluster: genCluster(), }, }, { name: "with containerd with insecure registry", args: args{ - cluster: genCluster(withContainerd, withInsecureRegistry("127.0.0.1:5000")), + cluster: genCluster(withInsecureRegistry("127.0.0.1:5000")), }, }, { @@ -197,7 +196,6 @@ func TestMigrateToContainerd(t *testing.T) { t.Parallel() cls := genCluster( withInsecureRegistry(tt.insecureRegistry), - withContainerd, ) got, err := MigrateToContainerd(&cls, &kubeoneapi.HostConfig{OperatingSystem: tt.osName}) @@ -227,13 +225,13 @@ func TestKubeadmCentOS(t *testing.T) { { name: "with containerd", args: args{ - cluster: genCluster(withContainerd), + cluster: genCluster(), }, }, { name: "with containerd with insecure registry", args: args{ - cluster: genCluster(withContainerd, withInsecureRegistry("127.0.0.1:5000")), + cluster: genCluster(withInsecureRegistry("127.0.0.1:5000")), }, }, { @@ -282,7 +280,6 @@ func TestKubeadmAmazonLinux(t *testing.T) { name: "proxy", args: args{ cluster: genCluster( - withContainerd, withProxy("http://my-proxy.tld"), withDefaultAssetConfiguration, ), @@ -292,7 +289,6 @@ func TestKubeadmAmazonLinux(t *testing.T) { name: "force", args: args{ cluster: genCluster( - withContainerd, withDefaultAssetConfiguration, ), force: true, @@ -302,7 +298,6 @@ func TestKubeadmAmazonLinux(t *testing.T) { name: "v1.26.0", args: args{ cluster: genCluster( - withContainerd, withKubeVersion("1.26.0"), withDefaultAssetConfiguration, ), @@ -312,7 +307,6 @@ func TestKubeadmAmazonLinux(t *testing.T) { name: "overwrite registry", args: args{ cluster: genCluster( - withContainerd, withRegistry("127.0.0.1:5000"), withDefaultAssetConfiguration, ), @@ -321,13 +315,13 @@ func TestKubeadmAmazonLinux(t *testing.T) { { name: "with containerd", args: args{ - cluster: genCluster(withContainerd), + cluster: genCluster(), }, }, { name: "with containerd with insecure registry", args: args{ - cluster: genCluster(withContainerd, withInsecureRegistry("127.0.0.1:5000")), + cluster: genCluster(withInsecureRegistry("127.0.0.1:5000")), }, }, { @@ -368,14 +362,13 @@ func TestKubeadmFlatcar(t *testing.T) { { name: "force", args: args{ - cluster: genCluster(withContainerd), + cluster: genCluster(), }, }, { name: "overwrite registry", args: args{ cluster: genCluster( - withContainerd, withRegistry("127.0.0.1:5000"), ), }, @@ -383,14 +376,13 @@ func TestKubeadmFlatcar(t *testing.T) { { name: "with containerd", args: args{ - cluster: genCluster(withContainerd), + cluster: genCluster(), }, }, { name: "with containerd with insecure registry", args: args{ cluster: genCluster( - withContainerd, withInsecureRegistry("127.0.0.1:5000"), ), }, @@ -474,7 +466,7 @@ func TestRemoveBinariesFlatcar(t *testing.T) { func TestUpgradeKubeadmAndCNIDebian(t *testing.T) { t.Parallel() - cls := genCluster(withContainerd) + cls := genCluster() got, err := UpgradeKubeadmAndCNIDebian(&cls) if err != nil { t.Errorf("UpgradeKubeadmAndCNIDebian() error = %v", err) @@ -488,7 +480,7 @@ func TestUpgradeKubeadmAndCNIDebian(t *testing.T) { func TestUpgradeKubeadmAndCNICentOS(t *testing.T) { t.Parallel() - cls := genCluster(withContainerd) + cls := genCluster() got, err := UpgradeKubeadmAndCNICentOS(&cls) if err != nil { t.Errorf("UpgradeKubeadmAndCNICentOS() error = %v", err) @@ -502,7 +494,7 @@ func TestUpgradeKubeadmAndCNICentOS(t *testing.T) { func TestUpgradeKubeadmAndCNIAmazonLinux(t *testing.T) { t.Parallel() - cls := genCluster(withContainerd, withDefaultAssetConfiguration) + cls := genCluster(withDefaultAssetConfiguration) got, err := UpgradeKubeadmAndCNIAmazonLinux(&cls) if err != nil { t.Errorf("UpgradeKubeadmAndCNIAmazonLinux() error = %v", err) @@ -518,7 +510,6 @@ func TestUpgradeKubeadmAndCNIFlatcar(t *testing.T) { c := genCluster( withKubeVersion("1.26.0"), - withContainerd, withInsecureRegistry("127.0.0.1:5000"), ) got, err := UpgradeKubeadmAndCNIFlatcar(&c) @@ -534,7 +525,7 @@ func TestUpgradeKubeadmAndCNIFlatcar(t *testing.T) { func TestUpgradeKubeletAndKubectlDebian(t *testing.T) { t.Parallel() - cls := genCluster(withContainerd) + cls := genCluster() got, err := UpgradeKubeletAndKubectlDebian(&cls) if err != nil { t.Errorf("UpgradeKubeletAndKubectlDebian() error = %v", err) @@ -548,7 +539,7 @@ func TestUpgradeKubeletAndKubectlDebian(t *testing.T) { func TestUpgradeKubeletAndKubectlCentOS(t *testing.T) { t.Parallel() - cls := genCluster(withContainerd) + cls := genCluster() got, err := UpgradeKubeletAndKubectlCentOS(&cls) if err != nil { t.Errorf("UpgradeKubeletAndKubectlCentOS() error = %v", err) @@ -562,7 +553,7 @@ func TestUpgradeKubeletAndKubectlCentOS(t *testing.T) { func TestUpgradeKubeletAndKubectlAmazonLinux(t *testing.T) { t.Parallel() - cls := genCluster(withContainerd, withDefaultAssetConfiguration) + cls := genCluster(withDefaultAssetConfiguration) got, err := UpgradeKubeletAndKubectlAmazonLinux(&cls) if err != nil { t.Errorf("UpgradeKubeletAndKubectlAmazonLinux() error = %v", err) @@ -578,7 +569,6 @@ func TestUpgradeKubeletAndKubectlFlatcar(t *testing.T) { c := genCluster( withKubeVersion("1.26.0"), - withContainerd, withInsecureRegistry("127.0.0.1:5000"), ) got, err := UpgradeKubeletAndKubectlFlatcar(&c) diff --git a/pkg/scripts/testdata/TestKubeadmAmazonLinux-with_cilium.golden b/pkg/scripts/testdata/TestKubeadmAmazonLinux-with_cilium.golden index 11d1df27e..c81861188 100644 --- a/pkg/scripts/testdata/TestKubeadmAmazonLinux-with_cilium.golden +++ b/pkg/scripts/testdata/TestKubeadmAmazonLinux-with_cilium.golden @@ -88,6 +88,44 @@ sudo yum install -y \ rsync +sudo yum versionlock delete containerd || true +sudo yum install -y containerd-'1.6.*' +sudo yum versionlock add containerd + + +sudo mkdir -p $(dirname /etc/containerd/config.toml) +sudo touch /etc/containerd/config.toml +sudo chmod 600 /etc/containerd/config.toml +cat < Date: Mon, 22 Jan 2024 11:11:07 +0200 Subject: [PATCH 7/8] Post-review fixes Signed-off-by: Artiom Diomin --- pkg/apis/kubeone/helpers_test.go | 59 +++++++++++++++++++++++ pkg/apis/kubeone/validation/validation.go | 22 +++++++++ pkg/state/cluster.go | 2 +- 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/pkg/apis/kubeone/helpers_test.go b/pkg/apis/kubeone/helpers_test.go index b254feb94..4ce6e162d 100644 --- a/pkg/apis/kubeone/helpers_test.go +++ b/pkg/apis/kubeone/helpers_test.go @@ -75,6 +75,65 @@ func TestFeatureGatesString(t *testing.T) { } } +func TestContainerRuntimeConfig_MachineControllerFlags(t *testing.T) { + type fields struct { + Containerd *ContainerRuntimeContainerd + } + tests := []struct { + name string + fields fields + want []string + }{ + { + name: "containerd empty", + fields: fields{ + Containerd: &ContainerRuntimeContainerd{}, + }, + }, + { + name: "containerd with mirrors", + fields: fields{ + Containerd: &ContainerRuntimeContainerd{ + Registries: map[string]ContainerdRegistry{ + "docker.io": { + Mirrors: []string{ + "http://registry1", + "https://registry2", + "registry3", + }, + }, + "registry.k8s.io": { + Mirrors: []string{ + "https://insecure.registry", + }, + TLSConfig: &ContainerdTLSConfig{ + InsecureSkipVerify: true, + }, + }, + }, + }, + }, + want: []string{ + "-node-containerd-registry-mirrors=docker.io=http://registry1", + "-node-containerd-registry-mirrors=docker.io=https://registry2", + "-node-containerd-registry-mirrors=docker.io=registry3", + "-node-containerd-registry-mirrors=registry.k8s.io=https://insecure.registry", + "-node-insecure-registries=registry.k8s.io", + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + crc := ContainerRuntimeConfig{Containerd: tt.fields.Containerd} + + if got := crc.MachineControllerFlags(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("ContainerRuntimeConfig.MachineControllerFlags() = \n%v, \nwant\n%v", got, tt.want) + } + }) + } +} + func TestMapStringStringToString(t *testing.T) { tests := []struct { name string diff --git a/pkg/apis/kubeone/validation/validation.go b/pkg/apis/kubeone/validation/validation.go index 1c3f6e0bc..460419c8b 100644 --- a/pkg/apis/kubeone/validation/validation.go +++ b/pkg/apis/kubeone/validation/validation.go @@ -22,6 +22,7 @@ import ( "fmt" "net" "os" + "reflect" "strings" "github.com/Masterminds/semver/v3" @@ -61,6 +62,7 @@ func ValidateKubeOneCluster(c kubeoneapi.KubeOneCluster) field.ErrorList { allErrs = append(allErrs, ValidateCloudProviderSpec(c.CloudProvider, c.ClusterNetwork, field.NewPath("provider"))...) allErrs = append(allErrs, ValidateVersionConfig(c.Versions, field.NewPath("versions"))...) allErrs = append(allErrs, ValidateKubernetesSupport(c, field.NewPath(""))...) + allErrs = append(allErrs, ValidateContainerRuntimeConfig(c.ContainerRuntime, c.Versions, field.NewPath("containerRuntime"))...) allErrs = append(allErrs, ValidateClusterNetworkConfig(c.ClusterNetwork, c.CloudProvider, field.NewPath("clusterNetwork"))...) allErrs = append(allErrs, ValidateStaticWorkersConfig(c.StaticWorkers, c.Versions, c.ClusterNetwork, field.NewPath("staticWorkers"))...) @@ -336,6 +338,26 @@ func ValidateKubernetesSupport(c kubeoneapi.KubeOneCluster, fldPath *field.Path) return allErrs } +func ValidateContainerRuntimeConfig(cr kubeoneapi.ContainerRuntimeConfig, versions kubeoneapi.VersionConfig, fldPath *field.Path) field.ErrorList { + allErrs := field.ErrorList{} + + allCRs := []interface{}{ + cr.Containerd, + } + + var found bool + for _, x := range allCRs { + if !reflect.ValueOf(x).IsNil() { + if found { + allErrs = append(allErrs, field.Invalid(fldPath, x, "only 1 container runtime can be activated")) + } + found = true + } + } + + return allErrs +} + // ValidateClusterNetworkConfig validates the ClusterNetworkConfig structure func ValidateClusterNetworkConfig(c kubeoneapi.ClusterNetworkConfig, prov kubeoneapi.CloudProviderSpec, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} diff --git a/pkg/state/cluster.go b/pkg/state/cluster.go index c33269518..fca73eb65 100644 --- a/pkg/state/cluster.go +++ b/pkg/state/cluster.go @@ -281,7 +281,7 @@ func (h *Host) Initialized() bool { // IsProvisioned checks are CRI and Kubelet provisioned on a host func (h *Host) IsProvisioned() bool { - return (h.ContainerRuntimeContainerd.IsProvisioned()) && h.Kubelet.IsProvisioned() + return h.ContainerRuntimeContainerd.IsProvisioned() && h.Kubelet.IsProvisioned() } // ControlPlaneHealthy checks is a control-plane host part of the cluster and are CRI, Kubelet, and API server healthy From 3e0e2fc96e1216c9070f3cc4a61ba7c512a9d85d Mon Sep 17 00:00:00 2001 From: Artiom Diomin Date: Mon, 22 Jan 2024 11:16:31 +0200 Subject: [PATCH 8/8] Fix linter Signed-off-by: Artiom Diomin --- pkg/apis/kubeone/validation/validation.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/apis/kubeone/validation/validation.go b/pkg/apis/kubeone/validation/validation.go index 460419c8b..4cc59ed86 100644 --- a/pkg/apis/kubeone/validation/validation.go +++ b/pkg/apis/kubeone/validation/validation.go @@ -338,7 +338,7 @@ func ValidateKubernetesSupport(c kubeoneapi.KubeOneCluster, fldPath *field.Path) return allErrs } -func ValidateContainerRuntimeConfig(cr kubeoneapi.ContainerRuntimeConfig, versions kubeoneapi.VersionConfig, fldPath *field.Path) field.ErrorList { +func ValidateContainerRuntimeConfig(cr kubeoneapi.ContainerRuntimeConfig, _ kubeoneapi.VersionConfig, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} allCRs := []interface{}{