From aeabb9946030964942d614607724d72b015f4a39 Mon Sep 17 00:00:00 2001 From: killianmuldoon Date: Mon, 24 Apr 2023 12:30:15 +0100 Subject: [PATCH] Stop serving v1alpha3 API types Signed-off-by: killianmuldoon --- Makefile | 6 +- api/v1alpha3/cluster_types.go | 1 + api/v1alpha3/machine_types.go | 1 + api/v1alpha3/machinedeployment_types.go | 1 + api/v1alpha3/machinehealthcheck_types.go | 1 + api/v1alpha3/machineset_types.go | 1 + api/v1alpha3/webhook_test.go | 123 ------------- .../api/v1alpha3/kubeadmconfig_types.go | 1 + .../v1alpha3/kubeadmconfigtemplate_types.go | 1 + .../kubeadm/api/v1alpha3/webhook_test.go | 171 ------------------ ...strap.cluster.x-k8s.io_kubeadmconfigs.yaml | 2 +- ...uster.x-k8s.io_kubeadmconfigtemplates.yaml | 2 +- .../client/cluster/crd_migration.go | 15 +- .../client/cluster/crd_migration_test.go | 89 +++++++-- ...r.x-k8s.io_clusterresourcesetbindings.yaml | 2 +- ....cluster.x-k8s.io_clusterresourcesets.yaml | 2 +- .../crd/bases/cluster.x-k8s.io_clusters.yaml | 2 +- .../cluster.x-k8s.io_machinedeployments.yaml | 2 +- .../cluster.x-k8s.io_machinehealthchecks.yaml | 2 +- .../bases/cluster.x-k8s.io_machinepools.yaml | 2 +- .../crd/bases/cluster.x-k8s.io_machines.yaml | 2 +- .../bases/cluster.x-k8s.io_machinesets.yaml | 2 +- .../v1alpha3/kubeadm_control_plane_types.go | 1 + .../kubeadm/api/v1alpha3/webhook_test.go | 93 ---------- ...cluster.x-k8s.io_kubeadmcontrolplanes.yaml | 2 +- docs/book/src/clusterctl/commands/upgrade.md | 3 +- .../providers/migrations/v1.4-to-v1.5.md | 4 +- docs/book/src/reference/jobs.md | 2 - docs/release/release-tasks.md | 15 +- .../api/v1alpha3/clusterresourceset_types.go | 1 + .../clusterresourcesetbinding_types.go | 1 + exp/addons/api/v1alpha3/webhook_test.go | 107 ----------- exp/api/v1alpha3/machinepool_types.go | 1 + exp/api/v1alpha3/webhook_test.go | 89 --------- test/e2e/clusterctl_upgrade_test.go | 34 ---- test/e2e/config/docker.yaml | 37 ---- test/e2e/data/infrastructure-docker/README.md | 6 +- .../v0.3/bases/cluster-with-kcp.yaml | 82 --------- .../infrastructure-docker/v0.3/bases/crs.yaml | 24 --- .../infrastructure-docker/v0.3/bases/md.yaml | 58 ------ .../v0.3/cluster-template/kustomization.yaml | 5 - test/e2e/data/shared/v0.3/metadata.yaml | 9 - test/framework/clusterctl/client.go | 1 + .../api/v1alpha3/dockercluster_types.go | 1 + .../api/v1alpha3/dockermachine_types.go | 1 + .../v1alpha3/dockermachinetemplate_types.go | 1 + ...cture.cluster.x-k8s.io_dockerclusters.yaml | 2 +- ...e.cluster.x-k8s.io_dockermachinepools.yaml | 2 +- ...cture.cluster.x-k8s.io_dockermachines.yaml | 2 +- ...uster.x-k8s.io_dockermachinetemplates.yaml | 2 +- .../api/v1alpha3/dockermachinepool_types.go | 1 + 51 files changed, 128 insertions(+), 890 deletions(-) delete mode 100644 api/v1alpha3/webhook_test.go delete mode 100644 bootstrap/kubeadm/api/v1alpha3/webhook_test.go delete mode 100644 controlplane/kubeadm/api/v1alpha3/webhook_test.go delete mode 100644 exp/addons/api/v1alpha3/webhook_test.go delete mode 100644 exp/api/v1alpha3/webhook_test.go delete mode 100644 test/e2e/data/infrastructure-docker/v0.3/bases/cluster-with-kcp.yaml delete mode 100644 test/e2e/data/infrastructure-docker/v0.3/bases/crs.yaml delete mode 100644 test/e2e/data/infrastructure-docker/v0.3/bases/md.yaml delete mode 100644 test/e2e/data/infrastructure-docker/v0.3/cluster-template/kustomization.yaml delete mode 100644 test/e2e/data/shared/v0.3/metadata.yaml diff --git a/Makefile b/Makefile index 73a6e8726245..a0fe1022ec1f 100644 --- a/Makefile +++ b/Makefile @@ -472,14 +472,10 @@ generate-modules: ## Run go mod tidy to ensure modules are up to date cd $(TEST_DIR); go mod tidy .PHONY: generate-e2e-templates -generate-e2e-templates: $(KUSTOMIZE) $(addprefix generate-e2e-templates-, v0.3 v0.4 v1.0 v1.3 v1.4 main) ## Generate cluster templates for all versions +generate-e2e-templates: $(KUSTOMIZE) $(addprefix generate-e2e-templates-, v0.4 v1.0 v1.3 v1.4 main) ## Generate cluster templates for all versions DOCKER_TEMPLATES := test/e2e/data/infrastructure-docker -.PHONY: generate-e2e-templates-v0.3 -generate-e2e-templates-v0.3: $(KUSTOMIZE) - $(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v0.3/cluster-template --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v0.3/cluster-template.yaml - .PHONY: generate-e2e-templates-v0.4 generate-e2e-templates-v0.4: $(KUSTOMIZE) $(KUSTOMIZE) build $(DOCKER_TEMPLATES)/v0.4/cluster-template --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/v0.4/cluster-template.yaml diff --git a/api/v1alpha3/cluster_types.go b/api/v1alpha3/cluster_types.go index 66dd8458a9e6..2421a2796242 100644 --- a/api/v1alpha3/cluster_types.go +++ b/api/v1alpha3/cluster_types.go @@ -200,6 +200,7 @@ func (v APIEndpoint) String() string { // ANCHOR_END: APIEndpoint // +kubebuilder:object:root=true +// +kubebuilder:unservedversion // +kubebuilder:deprecatedversion // +kubebuilder:resource:path=clusters,shortName=cl,scope=Namespaced,categories=cluster-api // +kubebuilder:subresource:status diff --git a/api/v1alpha3/machine_types.go b/api/v1alpha3/machine_types.go index 9b4fa2a135f8..69b0e1b3053a 100644 --- a/api/v1alpha3/machine_types.go +++ b/api/v1alpha3/machine_types.go @@ -237,6 +237,7 @@ type Bootstrap struct { // ANCHOR_END: Bootstrap // +kubebuilder:object:root=true +// +kubebuilder:unservedversion // +kubebuilder:deprecatedversion // +kubebuilder:resource:path=machines,shortName=ma,scope=Namespaced,categories=cluster-api // +kubebuilder:subresource:status diff --git a/api/v1alpha3/machinedeployment_types.go b/api/v1alpha3/machinedeployment_types.go index dfc039623120..4aa959c8d6b0 100644 --- a/api/v1alpha3/machinedeployment_types.go +++ b/api/v1alpha3/machinedeployment_types.go @@ -241,6 +241,7 @@ func (md *MachineDeploymentStatus) GetTypedPhase() MachineDeploymentPhase { } // +kubebuilder:object:root=true +// +kubebuilder:unservedversion // +kubebuilder:deprecatedversion // +kubebuilder:resource:path=machinedeployments,shortName=md,scope=Namespaced,categories=cluster-api // +kubebuilder:subresource:status diff --git a/api/v1alpha3/machinehealthcheck_types.go b/api/v1alpha3/machinehealthcheck_types.go index d7dc862a294e..00aba45ab68e 100644 --- a/api/v1alpha3/machinehealthcheck_types.go +++ b/api/v1alpha3/machinehealthcheck_types.go @@ -114,6 +114,7 @@ type MachineHealthCheckStatus struct { // ANCHOR_END: MachineHealthCheckStatus // +kubebuilder:object:root=true +// +kubebuilder:unservedversion // +kubebuilder:deprecatedversion // +kubebuilder:resource:path=machinehealthchecks,shortName=mhc;mhcs,scope=Namespaced,categories=cluster-api // +kubebuilder:subresource:status diff --git a/api/v1alpha3/machineset_types.go b/api/v1alpha3/machineset_types.go index e1c1f2ccfd06..6ce31ca0ec95 100644 --- a/api/v1alpha3/machineset_types.go +++ b/api/v1alpha3/machineset_types.go @@ -185,6 +185,7 @@ func (m *MachineSet) Validate() field.ErrorList { } // +kubebuilder:object:root=true +// +kubebuilder:unservedversion // +kubebuilder:deprecatedversion // +kubebuilder:resource:path=machinesets,shortName=ms,scope=Namespaced,categories=cluster-api // +kubebuilder:subresource:status diff --git a/api/v1alpha3/webhook_test.go b/api/v1alpha3/webhook_test.go deleted file mode 100644 index 11b229c6c925..000000000000 --- a/api/v1alpha3/webhook_test.go +++ /dev/null @@ -1,123 +0,0 @@ -/* -Copyright 2020 The Kubernetes 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 v1alpha3 - -import ( - "fmt" - "testing" - - . "github.com/onsi/gomega" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" - "sigs.k8s.io/controller-runtime/pkg/client" - - "sigs.k8s.io/cluster-api/util" -) - -func TestClusterConversion(t *testing.T) { - g := NewWithT(t) - ns, err := env.CreateNamespace(ctx, fmt.Sprintf("conversion-webhook-%s", util.RandomString(5))) - g.Expect(err).ToNot(HaveOccurred()) - clusterName := fmt.Sprintf("test-cluster-%s", util.RandomString(5)) - cluster := &Cluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: clusterName, - Namespace: ns.Name, - }, - } - - g.Expect(env.Create(ctx, cluster)).To(Succeed()) - defer func(do ...client.Object) { - g.Expect(env.Cleanup(ctx, do...)).To(Succeed()) - }(ns, cluster) -} - -func TestMachineSetConversion(t *testing.T) { - g := NewWithT(t) - ns, err := env.CreateNamespace(ctx, fmt.Sprintf("conversion-webhook-%s", util.RandomString(5))) - g.Expect(err).ToNot(HaveOccurred()) - - clusterName := fmt.Sprintf("test-cluster-%s", util.RandomString(5)) - machineSetName := fmt.Sprintf("test-machineset-%s", util.RandomString(5)) - machineSet := &MachineSet{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: ns.Name, - Name: machineSetName, - }, - Spec: MachineSetSpec{ - ClusterName: clusterName, - Template: newFakeMachineTemplate(ns.Name, clusterName), - MinReadySeconds: 10, - Replicas: pointer.Int32(1), - DeletePolicy: "Random", - }, - } - - g.Expect(env.Create(ctx, machineSet)).To(Succeed()) - defer func(do ...client.Object) { - g.Expect(env.Cleanup(ctx, do...)).To(Succeed()) - }(ns, machineSet) -} - -func TestMachineDeploymentConversion(t *testing.T) { - g := NewWithT(t) - ns, err := env.CreateNamespace(ctx, fmt.Sprintf("conversion-webhook-%s", util.RandomString(5))) - g.Expect(err).ToNot(HaveOccurred()) - - clusterName := fmt.Sprintf("test-cluster-%s", util.RandomString(5)) - machineDeploymentName := fmt.Sprintf("test-machinedeployment-%s", util.RandomString(5)) - machineDeployment := &MachineDeployment{ - ObjectMeta: metav1.ObjectMeta{ - Name: machineDeploymentName, - Namespace: ns.Name, - }, - Spec: MachineDeploymentSpec{ - ClusterName: clusterName, - Template: newFakeMachineTemplate(ns.Name, clusterName), - Replicas: pointer.Int32(0), - }, - } - - g.Expect(env.Create(ctx, machineDeployment)).To(Succeed()) - defer func(do ...client.Object) { - g.Expect(env.Cleanup(ctx, do...)).To(Succeed()) - }(ns, machineDeployment) -} - -func newFakeMachineTemplate(namespace, clusterName string) MachineTemplateSpec { - return MachineTemplateSpec{ - Spec: MachineSpec{ - ClusterName: clusterName, - Bootstrap: Bootstrap{ - ConfigRef: &corev1.ObjectReference{ - APIVersion: "bootstrap.cluster.x-k8s.io/v1alpha3", - Kind: "KubeadmConfigTemplate", - Name: fmt.Sprintf("%s-md-0", clusterName), - Namespace: namespace, - }, - }, - InfrastructureRef: corev1.ObjectReference{ - APIVersion: "infrastructure.cluster.x-k8s.io/v1alpha3", - Kind: "FakeMachineTemplate", - Name: fmt.Sprintf("%s-md-0", clusterName), - Namespace: namespace, - }, - Version: pointer.String("v1.20.2"), - }, - } -} diff --git a/bootstrap/kubeadm/api/v1alpha3/kubeadmconfig_types.go b/bootstrap/kubeadm/api/v1alpha3/kubeadmconfig_types.go index 843ca08edd47..ffca6a5a5c5b 100644 --- a/bootstrap/kubeadm/api/v1alpha3/kubeadmconfig_types.go +++ b/bootstrap/kubeadm/api/v1alpha3/kubeadmconfig_types.go @@ -132,6 +132,7 @@ type KubeadmConfigStatus struct { } // +kubebuilder:object:root=true +// +kubebuilder:unservedversion // +kubebuilder:deprecatedversion // +kubebuilder:resource:path=kubeadmconfigs,scope=Namespaced,categories=cluster-api // +kubebuilder:subresource:status diff --git a/bootstrap/kubeadm/api/v1alpha3/kubeadmconfigtemplate_types.go b/bootstrap/kubeadm/api/v1alpha3/kubeadmconfigtemplate_types.go index 0901198edd8a..7acf083db2c0 100644 --- a/bootstrap/kubeadm/api/v1alpha3/kubeadmconfigtemplate_types.go +++ b/bootstrap/kubeadm/api/v1alpha3/kubeadmconfigtemplate_types.go @@ -31,6 +31,7 @@ type KubeadmConfigTemplateResource struct { } // +kubebuilder:object:root=true +// +kubebuilder:unservedversion // +kubebuilder:deprecatedversion // +kubebuilder:resource:path=kubeadmconfigtemplates,scope=Namespaced,categories=cluster-api diff --git a/bootstrap/kubeadm/api/v1alpha3/webhook_test.go b/bootstrap/kubeadm/api/v1alpha3/webhook_test.go deleted file mode 100644 index 62eba4b589b9..000000000000 --- a/bootstrap/kubeadm/api/v1alpha3/webhook_test.go +++ /dev/null @@ -1,171 +0,0 @@ -/* -Copyright 2020 The Kubernetes 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 v1alpha3 - -import ( - "fmt" - "testing" - - . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" - "sigs.k8s.io/controller-runtime/pkg/client" - - "sigs.k8s.io/cluster-api/bootstrap/kubeadm/types/upstreamv1beta1" - "sigs.k8s.io/cluster-api/util" -) - -func TestKubeadmConfigConversion(t *testing.T) { - g := NewWithT(t) - ns, err := env.CreateNamespace(ctx, fmt.Sprintf("conversion-webhook-%s", util.RandomString(5))) - g.Expect(err).ToNot(HaveOccurred()) - kubeadmConfigName := fmt.Sprintf("test-kubeadmconfig-%s", util.RandomString(5)) - kubeadmConfig := &KubeadmConfig{ - ObjectMeta: metav1.ObjectMeta{ - Name: kubeadmConfigName, - Namespace: ns.Name, - }, - Spec: fakeKubeadmConfigSpec, - } - - g.Expect(env.Create(ctx, kubeadmConfig)).To(Succeed()) - defer func(do ...client.Object) { - g.Expect(env.Cleanup(ctx, do...)).To(Succeed()) - }(ns, kubeadmConfig) -} - -func TestKubeadmConfigTemplateConversion(t *testing.T) { - g := NewWithT(t) - ns, err := env.CreateNamespace(ctx, fmt.Sprintf("conversion-webhook-%s", util.RandomString(5))) - g.Expect(err).ToNot(HaveOccurred()) - kubeadmConfigTemplateName := fmt.Sprintf("test-kubeadmconfigtemplate-%s", util.RandomString(5)) - kubeadmConfigTemplate := &KubeadmConfigTemplate{ - ObjectMeta: metav1.ObjectMeta{ - Name: kubeadmConfigTemplateName, - Namespace: ns.Name, - }, - Spec: KubeadmConfigTemplateSpec{ - Template: KubeadmConfigTemplateResource{ - Spec: fakeKubeadmConfigSpec, - }, - }, - } - - g.Expect(env.Create(ctx, kubeadmConfigTemplate)).To(Succeed()) - defer func(do ...client.Object) { - g.Expect(env.Cleanup(ctx, do...)).To(Succeed()) - }(ns, kubeadmConfigTemplate) -} - -var fakeKubeadmConfigSpec = KubeadmConfigSpec{ - ClusterConfiguration: &upstreamv1beta1.ClusterConfiguration{ - KubernetesVersion: "v1.20.2", - APIServer: upstreamv1beta1.APIServer{ - ControlPlaneComponent: upstreamv1beta1.ControlPlaneComponent{ - ExtraArgs: map[string]string{ - "foo": "bar", - }, - ExtraVolumes: []upstreamv1beta1.HostPathMount{ - { - Name: "mount-path", - HostPath: "/foo", - MountPath: "/foo", - ReadOnly: false, - }, - }, - }, - }, - }, - InitConfiguration: &upstreamv1beta1.InitConfiguration{ - NodeRegistration: upstreamv1beta1.NodeRegistrationOptions{ - Name: "foo", - CRISocket: "/var/run/containerd/containerd.sock", - }, - }, - JoinConfiguration: &upstreamv1beta1.JoinConfiguration{ - NodeRegistration: upstreamv1beta1.NodeRegistrationOptions{ - Name: "foo", - CRISocket: "/var/run/containerd/containerd.sock", - }, - }, - Files: []File{ - { - Path: "/foo", - Owner: "root:root", - Permissions: "0644", - Content: "foo", - }, - { - Path: "/foobar", - Owner: "root:root", - Permissions: "0644", - ContentFrom: &FileSource{ - Secret: SecretFileSource{ - Name: "foo", - Key: "bar", - }, - }, - }, - }, - DiskSetup: &DiskSetup{ - Partitions: []Partition{ - { - Device: "/dev/disk/scsi1/lun0", - Layout: true, - Overwrite: pointer.Bool(false), - TableType: pointer.String("gpt"), - }, - }, - Filesystems: []Filesystem{ - { - Device: "/dev/disk/scsi2/lun0", - Filesystem: "ext4", - Label: "disk", - Partition: pointer.String("auto"), - Overwrite: pointer.Bool(true), - ReplaceFS: pointer.String("ntfs"), - ExtraOpts: []string{"-E"}, - }, - }, - }, - Mounts: []MountPoints{ - { - "LABEL=disk", - "/var/lib/disk", - }, - }, - PreKubeadmCommands: []string{`echo "foo"`}, - PostKubeadmCommands: []string{`echo "bar"`}, - Users: []User{ - { - Name: "foo", - Groups: pointer.String("foo"), - HomeDir: pointer.String("/home/foo"), - Inactive: pointer.Bool(false), - Shell: pointer.String("/bin/bash"), - Passwd: pointer.String("password"), - SSHAuthorizedKeys: []string{"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQD24GRNlhO+rgrseyWYrGwP0PACO/9JAsKV06W63yQ=="}, - }, - }, - NTP: &NTP{ - Servers: []string{"ntp.server.local"}, - Enabled: pointer.Bool(true), - }, - Format: Format("cloud-config"), - Verbosity: pointer.Int32(3), - UseExperimentalRetryJoin: true, -} diff --git a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml index 0a64093c35e8..a24d72abcd7f 100644 --- a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml +++ b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml @@ -1002,7 +1002,7 @@ spec: type: boolean type: object type: object - served: true + served: false storage: false subresources: status: {} diff --git a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml index 1472e591e914..e8b897862b9d 100644 --- a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml +++ b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml @@ -992,7 +992,7 @@ spec: - template type: object type: object - served: true + served: false storage: false - additionalPrinterColumns: - description: Time duration since creation of KubeadmConfigTemplate diff --git a/cmd/clusterctl/client/cluster/crd_migration.go b/cmd/clusterctl/client/cluster/crd_migration.go index b13bfc789d8a..c7fee727d4b2 100644 --- a/cmd/clusterctl/client/cluster/crd_migration.go +++ b/cmd/clusterctl/client/cluster/crd_migration.go @@ -71,15 +71,19 @@ func (m *crdMigrator) Run(ctx context.Context, objs []unstructured.Unstructured) } // run migrates CRs of a new CRD. -// This is necessary when the new CRD drops a version which -// was previously used as a storage version. +// This is necessary when the new CRD drops or stops serving +// a version which was previously used as a storage version. func (m *crdMigrator) run(ctx context.Context, newCRD *apiextensionsv1.CustomResourceDefinition) (bool, error) { log := logf.Log // Gets the list of version supported by the new CRD newVersions := sets.Set[string]{} + servedVersions := sets.Set[string]{} for _, version := range newCRD.Spec.Versions { newVersions.Insert(version.Name) + if version.Served { + servedVersions.Insert(version.Name) + } } // Get the current CRD. @@ -106,10 +110,9 @@ func (m *crdMigrator) run(ctx context.Context, newCRD *apiextensionsv1.CustomRes } currentStatusStoredVersions := sets.Set[string]{}.Insert(currentCRD.Status.StoredVersions...) - // If the new CRD still contains all current stored versions, nothing to do // as no previous storage version will be dropped. - if newVersions.HasAll(currentStatusStoredVersions.UnsortedList()...) { + if servedVersions.HasAll(currentStatusStoredVersions.UnsortedList()...) { log.V(2).Info("CRD migration check passed", "name", newCRD.Name) return false, nil } @@ -121,8 +124,8 @@ func (m *crdMigrator) run(ctx context.Context, newCRD *apiextensionsv1.CustomRes // This way we can make sure that all CR objects are now stored in the current storage version. // Alternatively, we would have to figure out which objects are stored in which version but this information is not // exposed by the apiserver. - storedVersionsToDelete := currentStatusStoredVersions.Difference(newVersions) - storedVersionsToPreserve := currentStatusStoredVersions.Intersection(newVersions) + storedVersionsToDelete := currentStatusStoredVersions.Difference(servedVersions) + storedVersionsToPreserve := currentStatusStoredVersions.Intersection(servedVersions) log.Info("CR migration required", "kind", newCRD.Spec.Names.Kind, "storedVersionsToDelete", strings.Join(sets.List(storedVersionsToDelete), ","), "storedVersionsToPreserve", strings.Join(sets.List(storedVersionsToPreserve), ",")) if err := m.migrateResourcesForCRD(ctx, currentCRD, currentStorageVersion); err != nil { diff --git a/cmd/clusterctl/client/cluster/crd_migration_test.go b/cmd/clusterctl/client/cluster/crd_migration_test.go index 35b7980e93ad..8edc510852d4 100644 --- a/cmd/clusterctl/client/cluster/crd_migration_test.go +++ b/cmd/clusterctl/client/cluster/crd_migration_test.go @@ -52,7 +52,7 @@ func Test_CRDMigrator(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo"}, Spec: apiextensionsv1.CustomResourceDefinitionSpec{ Versions: []apiextensionsv1.CustomResourceDefinitionVersion{ - {Name: "v1alpha1"}, // No storage version as storage is not set. + {Name: "v1alpha1", Served: true}, // No storage version as storage is not set. }, }, Status: apiextensionsv1.CustomResourceDefinitionStatus{StoredVersions: []string{"v1alpha1"}}, @@ -61,7 +61,7 @@ func Test_CRDMigrator(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo"}, Spec: apiextensionsv1.CustomResourceDefinitionSpec{ Versions: []apiextensionsv1.CustomResourceDefinitionVersion{ - {Name: "v1alpha1"}, + {Name: "v1alpha1", Served: true}, }, }, }, @@ -74,7 +74,7 @@ func Test_CRDMigrator(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo"}, Spec: apiextensionsv1.CustomResourceDefinitionSpec{ Versions: []apiextensionsv1.CustomResourceDefinitionVersion{ - {Name: "v1alpha1", Storage: true}, + {Name: "v1alpha1", Storage: true, Served: true}, }, }, Status: apiextensionsv1.CustomResourceDefinitionStatus{StoredVersions: []string{"v1alpha1"}}, @@ -83,7 +83,7 @@ func Test_CRDMigrator(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo"}, Spec: apiextensionsv1.CustomResourceDefinitionSpec{ Versions: []apiextensionsv1.CustomResourceDefinitionVersion{ - {Name: "v1alpha1", Storage: true}, + {Name: "v1alpha1", Storage: true, Served: true}, }, }, }, @@ -95,7 +95,7 @@ func Test_CRDMigrator(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo"}, Spec: apiextensionsv1.CustomResourceDefinitionSpec{ Versions: []apiextensionsv1.CustomResourceDefinitionVersion{ - {Name: "v1alpha1", Storage: true}, + {Name: "v1alpha1", Storage: true, Served: true}, }, }, Status: apiextensionsv1.CustomResourceDefinitionStatus{StoredVersions: []string{"v1alpha1"}}, @@ -104,8 +104,8 @@ func Test_CRDMigrator(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo"}, Spec: apiextensionsv1.CustomResourceDefinitionSpec{ Versions: []apiextensionsv1.CustomResourceDefinitionVersion{ - {Name: "v1beta1", Storage: true}, // v1beta1 is being added - {Name: "v1alpha1"}, // v1alpha1 still exists + {Name: "v1beta1", Storage: true, Served: true}, // v1beta1 is being added + {Name: "v1alpha1", Served: true}, // v1alpha1 still exists }, }, }, @@ -117,7 +117,7 @@ func Test_CRDMigrator(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo"}, Spec: apiextensionsv1.CustomResourceDefinitionSpec{ Versions: []apiextensionsv1.CustomResourceDefinitionVersion{ - {Name: "v1alpha1", Storage: true}, + {Name: "v1alpha1", Storage: true, Served: true}, }, }, Status: apiextensionsv1.CustomResourceDefinitionStatus{StoredVersions: []string{"v1alpha1"}}, @@ -126,14 +126,14 @@ func Test_CRDMigrator(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo"}, Spec: apiextensionsv1.CustomResourceDefinitionSpec{ Versions: []apiextensionsv1.CustomResourceDefinitionVersion{ - {Name: "v1", Storage: true}, // CRD is jumping to v1, but dropping current storage version without allowing migration. + {Name: "v1", Storage: true, Served: true}, // CRD is jumping to v1, but dropping current storage version without allowing migration. }, }, }, wantErr: true, }, { - name: "Migrate", + name: "Migrate CRs if their storage version is removed from the CRD", CRs: []unstructured.Unstructured{ { Object: map[string]interface{}{ @@ -172,8 +172,8 @@ func Test_CRDMigrator(t *testing.T) { Group: "foo", Names: apiextensionsv1.CustomResourceDefinitionNames{Kind: "Foo", ListKind: "FooList"}, Versions: []apiextensionsv1.CustomResourceDefinitionVersion{ - {Name: "v1beta1", Storage: true}, - {Name: "v1alpha1"}, + {Name: "v1beta1", Storage: true, Served: true}, + {Name: "v1alpha1", Served: true}, }, }, Status: apiextensionsv1.CustomResourceDefinitionStatus{StoredVersions: []string{"v1beta1", "v1alpha1"}}, @@ -184,8 +184,8 @@ func Test_CRDMigrator(t *testing.T) { Group: "foo", Names: apiextensionsv1.CustomResourceDefinitionNames{Kind: "Foo", ListKind: "FooList"}, Versions: []apiextensionsv1.CustomResourceDefinitionVersion{ - {Name: "v1", Storage: true}, // v1 is being added - {Name: "v1beta1"}, // v1beta1 still there (required for migration) + {Name: "v1", Storage: true, Served: true}, // v1 is being added + {Name: "v1beta1", Served: true}, // v1beta1 still there (required for migration) // v1alpha1 is being dropped }, }, @@ -193,6 +193,67 @@ func Test_CRDMigrator(t *testing.T) { wantStoredVersions: []string{"v1beta1"}, // v1alpha1 should be dropped from current CRD's stored versions wantIsMigrated: true, }, + { + name: "Migrate the CR if their storage version is no longer served by the CRD", + CRs: []unstructured.Unstructured{ + { + Object: map[string]interface{}{ + "apiVersion": "foo/v1beta1", + "kind": "Foo", + "metadata": map[string]interface{}{ + "name": "cr1", + "namespace": metav1.NamespaceDefault, + }, + }, + }, + { + Object: map[string]interface{}{ + "apiVersion": "foo/v1beta1", + "kind": "Foo", + "metadata": map[string]interface{}{ + "name": "cr2", + "namespace": metav1.NamespaceDefault, + }, + }, + }, + { + Object: map[string]interface{}{ + "apiVersion": "foo/v1beta1", + "kind": "Foo", + "metadata": map[string]interface{}{ + "name": "cr3", + "namespace": metav1.NamespaceDefault, + }, + }, + }, + }, + currentCRD: &apiextensionsv1.CustomResourceDefinition{ + ObjectMeta: metav1.ObjectMeta{Name: "foo"}, + Spec: apiextensionsv1.CustomResourceDefinitionSpec{ + Group: "foo", + Names: apiextensionsv1.CustomResourceDefinitionNames{Kind: "Foo", ListKind: "FooList"}, + Versions: []apiextensionsv1.CustomResourceDefinitionVersion{ + {Name: "v1beta1", Storage: true, Served: true}, + {Name: "v1alpha1", Served: true}, + }, + }, + Status: apiextensionsv1.CustomResourceDefinitionStatus{StoredVersions: []string{"v1beta1", "v1alpha1"}}, + }, + newCRD: &apiextensionsv1.CustomResourceDefinition{ + ObjectMeta: metav1.ObjectMeta{Name: "foo"}, + Spec: apiextensionsv1.CustomResourceDefinitionSpec{ + Group: "foo", + Names: apiextensionsv1.CustomResourceDefinitionNames{Kind: "Foo", ListKind: "FooList"}, + Versions: []apiextensionsv1.CustomResourceDefinitionVersion{ + {Name: "v1", Storage: true, Served: true}, // v1 is being added + {Name: "v1beta1", Served: true}, // v1beta1 still there (required for migration) + {Name: "v1alpha1", Served: false}, // v1alpha1 is no longer being served (required for migration) + }, + }, + }, + wantStoredVersions: []string{"v1beta1"}, // v1alpha1 should be dropped from current CRD's stored versions + wantIsMigrated: true, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesetbindings.yaml b/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesetbindings.yaml index 2b4241f534f2..fac9eba3acc0 100644 --- a/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesetbindings.yaml +++ b/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesetbindings.yaml @@ -97,7 +97,7 @@ spec: type: array type: object type: object - served: true + served: false storage: false subresources: status: {} diff --git a/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesets.yaml b/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesets.yaml index 11add2c8a5e7..f00315537a2c 100644 --- a/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesets.yaml +++ b/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesets.yaml @@ -170,7 +170,7 @@ spec: type: integer type: object type: object - served: true + served: false storage: false subresources: status: {} diff --git a/config/crd/bases/cluster.x-k8s.io_clusters.yaml b/config/crd/bases/cluster.x-k8s.io_clusters.yaml index bb8c73483479..d10cf9d1fcb0 100644 --- a/config/crd/bases/cluster.x-k8s.io_clusters.yaml +++ b/config/crd/bases/cluster.x-k8s.io_clusters.yaml @@ -272,7 +272,7 @@ spec: type: string type: object type: object - served: true + served: false storage: false subresources: status: {} diff --git a/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml b/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml index 6dab8d3b8f31..f7c6175f5e17 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml @@ -503,7 +503,7 @@ spec: type: integer type: object type: object - served: true + served: false storage: false subresources: scale: diff --git a/config/crd/bases/cluster.x-k8s.io_machinehealthchecks.yaml b/config/crd/bases/cluster.x-k8s.io_machinehealthchecks.yaml index 6b55fc981b0c..69f9d0cb76c7 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinehealthchecks.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinehealthchecks.yaml @@ -268,7 +268,7 @@ spec: type: array type: object type: object - served: true + served: false storage: false subresources: status: {} diff --git a/config/crd/bases/cluster.x-k8s.io_machinepools.yaml b/config/crd/bases/cluster.x-k8s.io_machinepools.yaml index efb7d8901320..706383bbb9fa 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinepools.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinepools.yaml @@ -559,7 +559,7 @@ spec: type: integer type: object type: object - served: true + served: false storage: false subresources: scale: diff --git a/config/crd/bases/cluster.x-k8s.io_machines.yaml b/config/crd/bases/cluster.x-k8s.io_machines.yaml index bea9415cf480..9553a78fc2ca 100644 --- a/config/crd/bases/cluster.x-k8s.io_machines.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machines.yaml @@ -354,7 +354,7 @@ spec: type: string type: object type: object - served: true + served: false storage: false subresources: status: {} diff --git a/config/crd/bases/cluster.x-k8s.io_machinesets.yaml b/config/crd/bases/cluster.x-k8s.io_machinesets.yaml index 11d9c3b8b099..a20f353095c7 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinesets.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinesets.yaml @@ -449,7 +449,7 @@ spec: type: string type: object type: object - served: true + served: false storage: false subresources: scale: diff --git a/controlplane/kubeadm/api/v1alpha3/kubeadm_control_plane_types.go b/controlplane/kubeadm/api/v1alpha3/kubeadm_control_plane_types.go index d278a7542a5b..bb86e7296afc 100644 --- a/controlplane/kubeadm/api/v1alpha3/kubeadm_control_plane_types.go +++ b/controlplane/kubeadm/api/v1alpha3/kubeadm_control_plane_types.go @@ -184,6 +184,7 @@ type KubeadmControlPlaneStatus struct { } // +kubebuilder:object:root=true +// +kubebuilder:unservedversion // +kubebuilder:deprecatedversion // +kubebuilder:resource:path=kubeadmcontrolplanes,shortName=kcp,scope=Namespaced,categories=cluster-api // +kubebuilder:subresource:status diff --git a/controlplane/kubeadm/api/v1alpha3/webhook_test.go b/controlplane/kubeadm/api/v1alpha3/webhook_test.go deleted file mode 100644 index ceee2b38ebe2..000000000000 --- a/controlplane/kubeadm/api/v1alpha3/webhook_test.go +++ /dev/null @@ -1,93 +0,0 @@ -/* -Copyright 2020 The Kubernetes 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 v1alpha3 - -import ( - "fmt" - "testing" - - . "github.com/onsi/gomega" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" - "sigs.k8s.io/controller-runtime/pkg/client" - - bootstrapv1alpha3 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha3" - "sigs.k8s.io/cluster-api/bootstrap/kubeadm/types/upstreamv1beta1" - "sigs.k8s.io/cluster-api/util" -) - -func TestKubeadmControlPlaneConversion(t *testing.T) { - g := NewWithT(t) - - ns, err := env.CreateNamespace(ctx, fmt.Sprintf("conversion-webhook-%s", util.RandomString(5))) - g.Expect(err).ToNot(HaveOccurred()) - infraMachineTemplateName := fmt.Sprintf("test-machinetemplate-%s", util.RandomString(5)) - controlPlaneName := fmt.Sprintf("test-controlpane-%s", util.RandomString(5)) - controlPlane := &KubeadmControlPlane{ - ObjectMeta: metav1.ObjectMeta{ - Name: controlPlaneName, - Namespace: ns.Name, - }, - Spec: KubeadmControlPlaneSpec{ - Replicas: pointer.Int32(3), - Version: "v1.20.2", - InfrastructureTemplate: corev1.ObjectReference{ - APIVersion: "infrastructure.cluster.x-k8s.io/v1alpha3", - Kind: "TestMachineTemplate", - Namespace: ns.Name, - Name: infraMachineTemplateName, - }, - KubeadmConfigSpec: bootstrapv1alpha3.KubeadmConfigSpec{ - ClusterConfiguration: &upstreamv1beta1.ClusterConfiguration{ - APIServer: upstreamv1beta1.APIServer{ - ControlPlaneComponent: upstreamv1beta1.ControlPlaneComponent{ - ExtraArgs: map[string]string{ - "foo": "bar", - }, - ExtraVolumes: []upstreamv1beta1.HostPathMount{ - { - Name: "mount-path", - HostPath: "/foo", - MountPath: "/foo", - ReadOnly: false, - }, - }, - }, - }, - }, - InitConfiguration: &upstreamv1beta1.InitConfiguration{ - NodeRegistration: upstreamv1beta1.NodeRegistrationOptions{ - Name: "foo", - CRISocket: "unix:///var/run/containerd/containerd.sock", - }, - }, - JoinConfiguration: &upstreamv1beta1.JoinConfiguration{ - NodeRegistration: upstreamv1beta1.NodeRegistrationOptions{ - Name: "foo", - CRISocket: "unix:///var/run/containerd/containerd.sock", - }, - }, - }, - }, - } - - g.Expect(env.Create(ctx, controlPlane)).To(Succeed()) - defer func(do ...client.Object) { - g.Expect(env.Cleanup(ctx, do...)).To(Succeed()) - }(ns, controlPlane) -} diff --git a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml index 422049b4a5c3..f9ac22eb3dd9 100644 --- a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml +++ b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml @@ -1184,7 +1184,7 @@ spec: type: integer type: object type: object - served: true + served: false storage: false subresources: scale: diff --git a/docs/book/src/clusterctl/commands/upgrade.md b/docs/book/src/clusterctl/commands/upgrade.md index 53b9d9f6b238..25faa26c2f05 100644 --- a/docs/book/src/clusterctl/commands/upgrade.md +++ b/docs/book/src/clusterctl/commands/upgrade.md @@ -83,11 +83,10 @@ Cluster API only tests a subset of possible clusterctl upgrade paths as otherwis Untested upgrade paths are not blocked by clusterctl and should work in general, they are just not tested. Users intending to use an upgrade path not tested by us should do their own validation to ensure the operation works correctly. -The following is an example of the tested upgrade paths while v1.4 is being developed: +The following is an example of the tested upgrade paths while v1.5 is being developed: | From | To | Note | |------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| v0.3 | latest | v0.3 is the latest supported minor release with the v1alpha3 contract (v0.3 is EOL since 2022-02-23). This test will be removed once the v1alpha3 apiVersion has been entirely removed. | | v0.4 | latest | v0.4 is the latest supported minor release with the v1alpha4 contract (v0.4 is EOL since 2022-04-06). This test will be removed once the v1alpha4 apiVersion has been entirely removed. | | v1.0 | latest | v1.0 is the first release with the v1beta1 contract. | | v1.2 | latest | v1.2 is a currently supported release. This test will be removed when v1.4 is released and a new test for v1.4 is added. | diff --git a/docs/book/src/developer/providers/migrations/v1.4-to-v1.5.md b/docs/book/src/developer/providers/migrations/v1.4-to-v1.5.md index 522c0d7cb473..2848b9aeeffa 100644 --- a/docs/book/src/developer/providers/migrations/v1.4-to-v1.5.md +++ b/docs/book/src/developer/providers/migrations/v1.4-to-v1.5.md @@ -17,11 +17,11 @@ maintainers of providers and consumers of our Go API. ### Deprecation -- +- API version`v1alpha4` is deprecated and CAPI will stop serving this version in v1.6. ### Removals -- +- API version `v1alpha3` is not served in v1.5 (users can enable it manually in case they are lagging behind with deprecation cycles). Important: `v1alpha3` will be completely removed in 1.6. ### API Changes diff --git a/docs/book/src/reference/jobs.md b/docs/book/src/reference/jobs.md index 909de79fe21d..31b9ca33d32b 100644 --- a/docs/book/src/reference/jobs.md +++ b/docs/book/src/reference/jobs.md @@ -116,8 +116,6 @@ Prow Periodics: [periodic-cluster-api-test-main]: https://testgrid.k8s.io/sig-cluster-lifecycle-cluster-api#capi-test-main [periodic-cluster-api-test-mink8s-main]: https://testgrid.k8s.io/sig-cluster-lifecycle-cluster-api#capi-test-mink8s-main [periodic-cluster-api-e2e-main]: https://testgrid.k8s.io/sig-cluster-lifecycle-cluster-api#capi-e2e-main -[periodic-cluster-api-e2e-upgrade-v0-3-to-main]: https://testgrid.k8s.io/sig-cluster-lifecycle-cluster-api#capi-e2e-upgrade-v0-3-to-main -[periodic-cluster-api-e2e-upgrade-v1-0-to-main]: https://testgrid.k8s.io/sig-cluster-lifecycle-cluster-api#capi-e2e-upgrade-v1-0-to-main [periodic-cluster-api-e2e-mink8s-main]: https://testgrid.k8s.io/sig-cluster-lifecycle-cluster-api#capi-e2e-mink8s-main [periodic-cluster-api-e2e-workload-upgrade-1-22-1-23-main]: https://testgrid.k8s.io/sig-cluster-lifecycle-cluster-api#capi-e2e-main-1-22-1-23 [periodic-cluster-api-e2e-workload-upgrade-1-23-1-24-main]: https://testgrid.k8s.io/sig-cluster-lifecycle-cluster-api#capi-e2e-main-1-23-1-24 diff --git a/docs/release/release-tasks.md b/docs/release/release-tasks.md index 4de3433e842a..61bb9ef13f0f 100644 --- a/docs/release/release-tasks.md +++ b/docs/release/release-tasks.md @@ -93,26 +93,25 @@ is used for e.g. local development and e2e tests. We also modify tests so that t This comes down to changing occurrences of the old version to the new version, e.g. `v1.3` to `v1.4`: 1. Setup E2E tests for the new release: - 1. Goal is that we have clusterctl upgrade tests for the latest stable versions of each contract / for each supported branch. For `v1.4` this means: - * v1alpha3: `v0.3` + 1. Goal is that we have clusterctl upgrade tests for the latest stable versions of each contract / for each supported branch. For `v1.5` this means: * v1alpha4: `v0.4` - * v1beta1: `v1.0`, `v1.2`, `v1.3` (will change with each new release) + * v1beta1: `v1.0`, `v1.3`, `v1.4` (will change with each new release) 2. Update providers in `docker.yaml`: - 1. Add a new `v1.3.0` entry. + 1. Add a new `v1.4.0` entry. 2. Remove providers that are not used anymore in clusterctl upgrade tests. - 3. Change `v1.3.99` to `v1.4.99`. + 3. Change `v1.4.99` to `v1.5.99`. 3. Adjust `metadata.yaml`'s: - 1. Create a new `v1.3` `metadata.yaml` (`test/e2e/data/shared/v1.3/metadata.yaml`) by copying + 1. Create a new `v1.4` `metadata.yaml` (`test/e2e/data/shared/v1.4/metadata.yaml`) by copying `test/e2e/data/shared/main/metadata.yaml` 2. Add the new release to the main `metadata.yaml` (`test/e2e/data/shared/main/metadata.yaml`). 3. Remove old `metadata.yaml`'s that are not used anymore in clusterctl upgrade tests. 4. Adjust cluster templates in `test/e2e/data/infrastructure-docker`: - 1. Create a new `v1.3` folder. It should be created based on the `main` folder and only contain the templates + 1. Create a new `v1.4` folder. It should be created based on the `main` folder and only contain the templates we use in the clusterctl upgrade tests (as of today `cluster-template` and `cluster-template-topology`). 2. Remove old folders that are not used anymore in clusterctl upgrade tests. 5. Modify the test specs in `test/e2e/clusterctl_upgrade_test.go` (according to the versions we want to test described above). Please note that both `InitWithKubernetesVersion` and `WorkloadKubernetesVersion` should be the highest mgmt cluster version supported by the respective Cluster API version. -2. Update `create-local-repository.py` and `tools/tilt-prepare/main.go`: `v1.3.99` => `v1.4.99`. +2. Update `create-local-repository.py` and `tools/tilt-prepare/main.go`: `v1.4.99` => `v1.5.99`. 3. Make sure all tests are green (also run `pull-cluster-api-e2e-full-main` and `pull-cluster-api-e2e-workload-upgrade-1-23-latest-main`). Prior art: diff --git a/exp/addons/api/v1alpha3/clusterresourceset_types.go b/exp/addons/api/v1alpha3/clusterresourceset_types.go index f415640e7fa5..3e15d5fd3452 100644 --- a/exp/addons/api/v1alpha3/clusterresourceset_types.go +++ b/exp/addons/api/v1alpha3/clusterresourceset_types.go @@ -111,6 +111,7 @@ func (m *ClusterResourceSet) SetConditions(conditions clusterv1alpha3.Conditions } // +kubebuilder:object:root=true +// +kubebuilder:unservedversion // +kubebuilder:deprecatedversion // +kubebuilder:resource:path=clusterresourcesets,scope=Namespaced,categories=cluster-api // +kubebuilder:subresource:status diff --git a/exp/addons/api/v1alpha3/clusterresourcesetbinding_types.go b/exp/addons/api/v1alpha3/clusterresourcesetbinding_types.go index 5be41d5f2634..101c2cf11893 100644 --- a/exp/addons/api/v1alpha3/clusterresourcesetbinding_types.go +++ b/exp/addons/api/v1alpha3/clusterresourcesetbinding_types.go @@ -101,6 +101,7 @@ func (c *ClusterResourceSetBinding) DeleteBinding(clusterResourceSet *ClusterRes } // +kubebuilder:object:root=true +// +kubebuilder:unservedversion // +kubebuilder:deprecatedversion // +kubebuilder:resource:path=clusterresourcesetbindings,scope=Namespaced,categories=cluster-api // +kubebuilder:subresource:status diff --git a/exp/addons/api/v1alpha3/webhook_test.go b/exp/addons/api/v1alpha3/webhook_test.go deleted file mode 100644 index a2e26f7799a6..000000000000 --- a/exp/addons/api/v1alpha3/webhook_test.go +++ /dev/null @@ -1,107 +0,0 @@ -/* -Copyright 2020 The Kubernetes 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 v1alpha3 - -import ( - "fmt" - "testing" - "time" - - . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/controller-runtime/pkg/client" - - "sigs.k8s.io/cluster-api/util" -) - -func TestClusterResourceSetConversion(t *testing.T) { - g := NewWithT(t) - ns, err := env.CreateNamespace(ctx, fmt.Sprintf("conversion-webhook-%s", util.RandomString(5))) - g.Expect(err).ToNot(HaveOccurred()) - clusterName := fmt.Sprintf("test-cluster-%s", util.RandomString(5)) - crsName := fmt.Sprintf("test-clusterresourceset-%s", util.RandomString(5)) - crs := &ClusterResourceSet{ - ObjectMeta: metav1.ObjectMeta{ - Name: crsName, - Namespace: ns.Name, - }, - Spec: ClusterResourceSetSpec{ - Strategy: "ApplyOnce", - ClusterSelector: metav1.LabelSelector{ - MatchLabels: map[string]string{ - "cni": fmt.Sprintf("%s-crs-cni", clusterName), - }, - }, - Resources: []ResourceRef{ - { - Name: fmt.Sprintf("%s-crs-cni", clusterName), - Kind: "ConfigMap", - }, - }, - }, - } - - g.Expect(env.Create(ctx, crs)).To(Succeed()) - defer func(do ...client.Object) { - g.Expect(env.Cleanup(ctx, do...)).To(Succeed()) - }(ns, crs) -} - -func TestClusterResourceSetBindingConversion(t *testing.T) { - g := NewWithT(t) - ns, err := env.CreateNamespace(ctx, fmt.Sprintf("conversion-webhook-%s", util.RandomString(5))) - g.Expect(err).ToNot(HaveOccurred()) - crsbindingName := fmt.Sprintf("test-clusterresourcesetbinding-%s", util.RandomString(5)) - crsbinding := &ClusterResourceSetBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: crsbindingName, - Namespace: ns.Name, - }, - Spec: ClusterResourceSetBindingSpec{ - Bindings: []*ResourceSetBinding{ - { - ClusterResourceSetName: "test-clusterresourceset", - Resources: []ResourceBinding{ - { - ResourceRef: ResourceRef{ - Name: "ApplySucceeded", - Kind: "Secret", - }, - Applied: true, - Hash: "xyz", - LastAppliedTime: &metav1.Time{Time: time.Now().UTC()}, - }, - { - ResourceRef: ResourceRef{ - Name: "applyFailed", - Kind: "Secret", - }, - Applied: false, - Hash: "", - LastAppliedTime: &metav1.Time{Time: time.Now().UTC()}, - }, - }, - }, - }, - }, - } - - g.Expect(env.Create(ctx, crsbinding)).To(Succeed()) - defer func(do ...client.Object) { - g.Expect(env.Cleanup(ctx, do...)).To(Succeed()) - }(ns, crsbinding) -} diff --git a/exp/api/v1alpha3/machinepool_types.go b/exp/api/v1alpha3/machinepool_types.go index 18a3c0addf32..11f0bd0a5478 100644 --- a/exp/api/v1alpha3/machinepool_types.go +++ b/exp/api/v1alpha3/machinepool_types.go @@ -204,6 +204,7 @@ func (m *MachinePoolStatus) GetTypedPhase() MachinePoolPhase { } // +kubebuilder:object:root=true +// +kubebuilder:unservedversion // +kubebuilder:deprecatedversion // +kubebuilder:resource:path=machinepools,shortName=mp,scope=Namespaced,categories=cluster-api // +kubebuilder:subresource:status diff --git a/exp/api/v1alpha3/webhook_test.go b/exp/api/v1alpha3/webhook_test.go deleted file mode 100644 index d57f29f9a6df..000000000000 --- a/exp/api/v1alpha3/webhook_test.go +++ /dev/null @@ -1,89 +0,0 @@ -/* -Copyright 2020 The Kubernetes 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 v1alpha3 - -import ( - "fmt" - "testing" - - . "github.com/onsi/gomega" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - utilfeature "k8s.io/component-base/featuregate/testing" - "k8s.io/utils/pointer" - "sigs.k8s.io/controller-runtime/pkg/client" - - clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3" - "sigs.k8s.io/cluster-api/feature" - "sigs.k8s.io/cluster-api/util" -) - -func TestMachinePoolConversion(t *testing.T) { - // NOTE: MachinePool feature flag is disabled by default, thus preventing to create or update MachinePool. - // Enabling the feature flag temporarily for this test. - defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.MachinePool, true)() - g := NewWithT(t) - ns, err := env.CreateNamespace(ctx, fmt.Sprintf("conversion-webhook-%s", util.RandomString(5))) - g.Expect(err).ToNot(HaveOccurred()) - clusterName := fmt.Sprintf("test-cluster-%s", util.RandomString(5)) - machinePoolName := fmt.Sprintf("test-machinepool-%s", util.RandomString(5)) - machinePool := &MachinePool{ - ObjectMeta: metav1.ObjectMeta{ - Name: machinePoolName, - Namespace: ns.Name, - }, - Spec: MachinePoolSpec{ - ClusterName: clusterName, - Replicas: pointer.Int32(3), - Template: newFakeMachineTemplate(ns.Name, clusterName), - Strategy: &clusterv1alpha3.MachineDeploymentStrategy{ - Type: clusterv1alpha3.RollingUpdateMachineDeploymentStrategyType, - }, - MinReadySeconds: pointer.Int32(60), - ProviderIDList: []string{"cloud:////1111", "cloud:////1112", "cloud:////1113"}, - FailureDomains: []string{"1", "3"}, - }, - } - - g.Expect(env.Create(ctx, machinePool)).To(Succeed()) - defer func(do ...client.Object) { - g.Expect(env.Cleanup(ctx, do...)).To(Succeed()) - }(ns, machinePool) -} - -func newFakeMachineTemplate(namespace, clusterName string) clusterv1alpha3.MachineTemplateSpec { - return clusterv1alpha3.MachineTemplateSpec{ - Spec: clusterv1alpha3.MachineSpec{ - ClusterName: clusterName, - Bootstrap: clusterv1alpha3.Bootstrap{ - ConfigRef: &corev1.ObjectReference{ - APIVersion: "bootstrap.cluster.x-k8s.io/v1alpha3", - Kind: "KubeadmConfigTemplate", - Name: fmt.Sprintf("%s-md-0", clusterName), - Namespace: namespace, - }, - }, - InfrastructureRef: corev1.ObjectReference{ - APIVersion: "exp.infrastructure.cluster.x-k8s.io/v1alpha3", - Kind: "FakeMachinePool", - Name: fmt.Sprintf("%s-md-0", clusterName), - Namespace: namespace, - }, - Version: pointer.String("v1.20.2"), - }, - } -} diff --git a/test/e2e/clusterctl_upgrade_test.go b/test/e2e/clusterctl_upgrade_test.go index d4f7f441c7e8..47127cea0f23 100644 --- a/test/e2e/clusterctl_upgrade_test.go +++ b/test/e2e/clusterctl_upgrade_test.go @@ -25,40 +25,6 @@ import ( "sigs.k8s.io/cluster-api/test/framework" ) -var _ = Describe("When testing clusterctl upgrades (v0.3=>current)", func() { - ClusterctlUpgradeSpec(ctx, func() ClusterctlUpgradeSpecInput { - return ClusterctlUpgradeSpecInput{ - E2EConfig: e2eConfig, - ClusterctlConfigPath: clusterctlConfigPath, - BootstrapClusterProxy: bootstrapClusterProxy, - ArtifactFolder: artifactFolder, - SkipCleanup: skipCleanup, - InitWithBinary: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.3.25/clusterctl-{OS}-{ARCH}", - InitWithProvidersContract: "v1alpha3", - // CAPI v0.3.x does not work on Kubernetes >= v1.22. - InitWithKubernetesVersion: "v1.21.14", - WorkloadKubernetesVersion: "v1.22.17", - // CAPI does not work with Kubernetes < v1.22 if ClusterClass is enabled, so we have to disable it. - UpgradeClusterctlVariables: map[string]string{ - "CLUSTER_TOPOLOGY": "false", - }, - MgmtFlavor: "topology", - WorkloadFlavor: "", - // This check ensures that ownerReference apiVersions are updated for all types after the upgrade. - PostUpgrade: func(proxy framework.ClusterProxy, namespace, clusterName string) { - framework.ValidateOwnerReferencesOnUpdate(proxy, namespace, - framework.CoreOwnerReferenceAssertion, - framework.ExpOwnerReferenceAssertions, - framework.DockerInfraOwnerReferenceAssertions, - framework.KubeadmBootstrapOwnerReferenceAssertions, - framework.KubeadmControlPlaneOwnerReferenceAssertions, - framework.KubernetesReferenceAssertions, - ) - }, - } - }) -}) - var _ = Describe("When testing clusterctl upgrades (v0.4=>current)", func() { ClusterctlUpgradeSpec(ctx, func() ClusterctlUpgradeSpecInput { return ClusterctlUpgradeSpecInput{ diff --git a/test/e2e/config/docker.yaml b/test/e2e/config/docker.yaml index 3e8f792dbfc6..69ba03bdc0b8 100644 --- a/test/e2e/config/docker.yaml +++ b/test/e2e/config/docker.yaml @@ -33,15 +33,6 @@ providers: - name: cluster-api type: CoreProvider versions: - - name: v0.3.25 # latest published release in the v1alpha3 series; this is used for v1alpha3 --> v1beta1 clusterctl upgrades test only. - value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.3.25/core-components.yaml" - type: "url" - contract: v1alpha3 - replacements: - - old: --metrics-addr=127.0.0.1:8080 - new: --metrics-addr=:8080 - files: - - sourcePath: "../data/shared/v0.3/metadata.yaml" - name: v0.4.8 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only. value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.8/core-components.yaml" type: "url" @@ -89,15 +80,6 @@ providers: - name: kubeadm type: BootstrapProvider versions: - - name: v0.3.25 # latest published release in the v1alpha3 series; this is used for v1alpha3 --> v1beta1 clusterctl upgrades test only. - value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.3.25/bootstrap-components.yaml" - type: "url" - contract: v1alpha3 - replacements: - - old: --metrics-addr=127.0.0.1:8080 - new: --metrics-addr=:8080 - files: - - sourcePath: "../data/shared/v0.3/metadata.yaml" - name: v0.4.8 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only. value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.8/bootstrap-components.yaml" type: "url" @@ -145,15 +127,6 @@ providers: - name: kubeadm type: ControlPlaneProvider versions: - - name: v0.3.25 # latest published release in the v1alpha3 series; this is used for v1alpha3 --> v1beta1 clusterctl upgrades test only. - value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.3.25/control-plane-components.yaml" - type: "url" - contract: v1alpha3 - replacements: - - old: --metrics-addr=127.0.0.1:8080 - new: --metrics-addr=:8080 - files: - - sourcePath: "../data/shared/v0.3/metadata.yaml" - name: v0.4.8 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only. value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.8/control-plane-components.yaml" type: "url" @@ -201,16 +174,6 @@ providers: - name: docker type: InfrastructureProvider versions: - - name: v0.3.25 # latest published release in the v1alpha3 series; this is used for v1alpha3 --> v1beta1 clusterctl upgrades test only. - value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.3.25/infrastructure-components-development.yaml" - type: "url" - contract: v1alpha3 - replacements: - - old: --metrics-addr=127.0.0.1:8080 - new: --metrics-addr=:8080 - files: - - sourcePath: "../data/shared/v0.3/metadata.yaml" - - sourcePath: "../data/infrastructure-docker/v0.3/cluster-template.yaml" - name: v0.4.8 # latest published release in the v1alpha4 series; this is used for v1alpha4 --> v1beta1 clusterctl upgrades test only. value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.8/infrastructure-components-development.yaml" type: "url" diff --git a/test/e2e/data/infrastructure-docker/README.md b/test/e2e/data/infrastructure-docker/README.md index 3ac5d04ec546..1ae99f0ee5e2 100644 --- a/test/e2e/data/infrastructure-docker/README.md +++ b/test/e2e/data/infrastructure-docker/README.md @@ -7,10 +7,8 @@ Sub-folders for the old versions of Cluster API should contain only templates us In those tests we first deploy an old version of Cluster API, create a workload cluster and then upgrade Cluster API to the version from the current branch (and check that the workload cluster still works). -As of today we have clusterctl upgrade tests for the latest stable versions of each contract / for each supported branch, i.e.: -* v1alpha3: v0.3 -* v1alpha4: v0.4 -* v1beta1: v1.0, v1.2, v1.3 (will change with each new release) +As of today we have clusterctl upgrade tests for the latest stable versions of each supported branch and an additional +test for v1alpha4 / v0.4 which will be removed when that version is no longer served. We cannot use the same cluster templates for all Cluster API versions as not each Cluster API version supports the same API fields. For example `KubeadmControlPlane.spec.rolloutBefore.certificatesExpiryDays` was introduced diff --git a/test/e2e/data/infrastructure-docker/v0.3/bases/cluster-with-kcp.yaml b/test/e2e/data/infrastructure-docker/v0.3/bases/cluster-with-kcp.yaml deleted file mode 100644 index 0e0dfb203837..000000000000 --- a/test/e2e/data/infrastructure-docker/v0.3/bases/cluster-with-kcp.yaml +++ /dev/null @@ -1,82 +0,0 @@ ---- -# DockerCluster object referenced by the Cluster object -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3 -kind: DockerCluster -metadata: - name: '${CLUSTER_NAME}' ---- -# Cluster object with -# - Reference to the KubeadmControlPlane object -# - the label cni=${CLUSTER_NAME}-crs-0, so the cluster can be selected by the ClusterResourceSet. -apiVersion: cluster.x-k8s.io/v1alpha3 -kind: Cluster -metadata: - name: '${CLUSTER_NAME}' - labels: - cni: "${CLUSTER_NAME}-crs-0" -spec: - clusterNetwork: - services: - cidrBlocks: ['${DOCKER_SERVICE_CIDRS}'] - pods: - cidrBlocks: ['${DOCKER_POD_CIDRS}'] - serviceDomain: '${DOCKER_SERVICE_DOMAIN}' - infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3 - kind: DockerCluster - name: '${CLUSTER_NAME}' - controlPlaneRef: - kind: KubeadmControlPlane - apiVersion: controlplane.cluster.x-k8s.io/v1alpha3 - name: "${CLUSTER_NAME}-control-plane" ---- -# DockerMachineTemplate object referenced by the KubeadmControlPlane object -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3 -kind: DockerMachineTemplate -metadata: - name: "${CLUSTER_NAME}-control-plane" -spec: - template: - spec: - extraMounts: - - containerPath: "/var/run/docker.sock" - hostPath: "/var/run/docker.sock" ---- -# KubeadmControlPlane referenced by the Cluster object with -# - the label kcp-adoption.step2, because it should be created in the second step of the kcp-adoption test. -kind: KubeadmControlPlane -apiVersion: controlplane.cluster.x-k8s.io/v1alpha3 -metadata: - name: "${CLUSTER_NAME}-control-plane" - labels: - kcp-adoption.step2: "" -spec: - replicas: ${CONTROL_PLANE_MACHINE_COUNT} - infrastructureTemplate: - kind: DockerMachineTemplate - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3 - name: "${CLUSTER_NAME}-control-plane" - kubeadmConfigSpec: - clusterConfiguration: - controllerManager: - extraArgs: {enable-hostpath-provisioner: 'true'} - apiServer: - # host.docker.internal is required by kubetest when running on MacOS because of the way ports are proxied. - certSANs: [localhost, 127.0.0.1, 0.0.0.0, host.docker.internal] - initConfiguration: - nodeRegistration: - criSocket: unix:///var/run/containerd/containerd.sock - kubeletExtraArgs: - # We have to pin the cgroupDriver to cgroupfs for Kubernetes < v1.24 because kind does not support systemd for those versions, but kubeadm >= 1.21 defaults to systemd. - # This cluster is used in tests where the Kubernetes version is < 1.24 - cgroup-driver: cgroupfs - eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%' - joinConfiguration: - nodeRegistration: - criSocket: unix:///var/run/containerd/containerd.sock - kubeletExtraArgs: - # We have to pin the cgroupDriver to cgroupfs for Kubernetes < v1.24 because kind does not support systemd for those versions, but kubeadm >= 1.21 defaults to systemd. - # This cluster is used in tests where the Kubernetes version is < 1.24 - cgroup-driver: cgroupfs - eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%' - version: "${KUBERNETES_VERSION}" diff --git a/test/e2e/data/infrastructure-docker/v0.3/bases/crs.yaml b/test/e2e/data/infrastructure-docker/v0.3/bases/crs.yaml deleted file mode 100644 index d88867d1ddb1..000000000000 --- a/test/e2e/data/infrastructure-docker/v0.3/bases/crs.yaml +++ /dev/null @@ -1,24 +0,0 @@ ---- -# ConfigMap object referenced by the ClusterResourceSet object and with -# the CNI resource defined in the test config file -apiVersion: v1 -kind: ConfigMap -metadata: - name: "cni-${CLUSTER_NAME}-crs-0" -data: ${CNI_RESOURCES} -binaryData: ---- -# ClusterResourceSet object with -# a selector that targets all the Cluster with label cni=${CLUSTER_NAME}-crs-0 -apiVersion: addons.cluster.x-k8s.io/v1alpha3 -kind: ClusterResourceSet -metadata: - name: "${CLUSTER_NAME}-crs-0" -spec: - strategy: ApplyOnce - clusterSelector: - matchLabels: - cni: "${CLUSTER_NAME}-crs-0" - resources: - - name: "cni-${CLUSTER_NAME}-crs-0" - kind: ConfigMap diff --git a/test/e2e/data/infrastructure-docker/v0.3/bases/md.yaml b/test/e2e/data/infrastructure-docker/v0.3/bases/md.yaml deleted file mode 100644 index 88453ca32686..000000000000 --- a/test/e2e/data/infrastructure-docker/v0.3/bases/md.yaml +++ /dev/null @@ -1,58 +0,0 @@ ---- -# DockerMachineTemplate referenced by the MachineDeployment and with -# - extraMounts for the docker sock, thus allowing self-hosting test -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3 -kind: DockerMachineTemplate -metadata: - name: "${CLUSTER_NAME}-md-0" -spec: - template: - spec: - extraMounts: - - containerPath: "/var/run/docker.sock" - hostPath: "/var/run/docker.sock" ---- -# KubeadmConfigTemplate referenced by the MachineDeployment -apiVersion: bootstrap.cluster.x-k8s.io/v1alpha3 -kind: KubeadmConfigTemplate -metadata: - name: "${CLUSTER_NAME}-md-0" -spec: - template: - spec: - joinConfiguration: - nodeRegistration: - criSocket: unix:///var/run/containerd/containerd.sock - kubeletExtraArgs: - # We have to pin the cgroupDriver to cgroupfs for Kubernetes < v1.24 because kind does not support systemd for those versions, but kubeadm >= 1.21 defaults to systemd. - # This cluster is used in tests where the Kubernetes version is < 1.24 - cgroup-driver: cgroupfs - eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%' ---- -# MachineDeployment object with -# - the label nodepool=pool1 that applies to all the machines, so those machine can be targeted by the MachineHealthCheck object -apiVersion: cluster.x-k8s.io/v1alpha3 -kind: MachineDeployment -metadata: - name: "${CLUSTER_NAME}-md-0" -spec: - clusterName: "${CLUSTER_NAME}" - replicas: ${WORKER_MACHINE_COUNT} - selector: - matchLabels: - template: - metadata: - labels: - "nodepool": "pool1" - spec: - clusterName: "${CLUSTER_NAME}" - version: "${KUBERNETES_VERSION}" - bootstrap: - configRef: - name: "${CLUSTER_NAME}-md-0" - apiVersion: bootstrap.cluster.x-k8s.io/v1alpha3 - kind: KubeadmConfigTemplate - infrastructureRef: - name: "${CLUSTER_NAME}-md-0" - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3 - kind: DockerMachineTemplate diff --git a/test/e2e/data/infrastructure-docker/v0.3/cluster-template/kustomization.yaml b/test/e2e/data/infrastructure-docker/v0.3/cluster-template/kustomization.yaml deleted file mode 100644 index adb5919cec6f..000000000000 --- a/test/e2e/data/infrastructure-docker/v0.3/cluster-template/kustomization.yaml +++ /dev/null @@ -1,5 +0,0 @@ -bases: -- ../bases/cluster-with-kcp.yaml -- ../bases/md.yaml -- ../bases/crs.yaml - diff --git a/test/e2e/data/shared/v0.3/metadata.yaml b/test/e2e/data/shared/v0.3/metadata.yaml deleted file mode 100644 index f3b4c3ef66bc..000000000000 --- a/test/e2e/data/shared/v0.3/metadata.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3 -kind: Metadata -releaseSeries: - - major: 0 - minor: 3 - contract: v1alpha3 - - major: 0 - minor: 2 - contract: v1alpha2 \ No newline at end of file diff --git a/test/framework/clusterctl/client.go b/test/framework/clusterctl/client.go index 67cdbbf39203..2fd4993dee37 100644 --- a/test/framework/clusterctl/client.go +++ b/test/framework/clusterctl/client.go @@ -310,6 +310,7 @@ func ConfigCluster(ctx context.Context, input ConfigClusterInput) []byte { // ConfigClusterWithBinary uses clusterctl binary to run config cluster or generate cluster. // NOTE: This func detects the clusterctl version and uses config cluster or generate cluster // accordingly. We can drop the detection when we don't have to support clusterctl v0.3.x anymore. +// TODO: (killianmuldoon) remove this detection. func ConfigClusterWithBinary(_ context.Context, clusterctlBinaryPath string, input ConfigClusterInput) []byte { log.Logf("Detect clusterctl version via: clusterctl version") diff --git a/test/infrastructure/docker/api/v1alpha3/dockercluster_types.go b/test/infrastructure/docker/api/v1alpha3/dockercluster_types.go index dc9b95237b37..beeb717c0f6e 100644 --- a/test/infrastructure/docker/api/v1alpha3/dockercluster_types.go +++ b/test/infrastructure/docker/api/v1alpha3/dockercluster_types.go @@ -71,6 +71,7 @@ type APIEndpoint struct { // +kubebuilder:resource:path=dockerclusters,scope=Namespaced,categories=cluster-api // +kubebuilder:subresource:status // +kubebuilder:object:root=true +// +kubebuilder:unservedversion // +kubebuilder:deprecatedversion // DockerCluster is the Schema for the dockerclusters API. diff --git a/test/infrastructure/docker/api/v1alpha3/dockermachine_types.go b/test/infrastructure/docker/api/v1alpha3/dockermachine_types.go index 753b06f70540..521b58eb4f34 100644 --- a/test/infrastructure/docker/api/v1alpha3/dockermachine_types.go +++ b/test/infrastructure/docker/api/v1alpha3/dockermachine_types.go @@ -93,6 +93,7 @@ type DockerMachineStatus struct { // +kubebuilder:resource:path=dockermachines,scope=Namespaced,categories=cluster-api // +kubebuilder:object:root=true +// +kubebuilder:unservedversion // +kubebuilder:deprecatedversion // +kubebuilder:subresource:status diff --git a/test/infrastructure/docker/api/v1alpha3/dockermachinetemplate_types.go b/test/infrastructure/docker/api/v1alpha3/dockermachinetemplate_types.go index 4109c4429eb5..a10fc62b74f8 100644 --- a/test/infrastructure/docker/api/v1alpha3/dockermachinetemplate_types.go +++ b/test/infrastructure/docker/api/v1alpha3/dockermachinetemplate_types.go @@ -26,6 +26,7 @@ type DockerMachineTemplateSpec struct { } // +kubebuilder:object:root=true +// +kubebuilder:unservedversion // +kubebuilder:deprecatedversion // +kubebuilder:resource:path=dockermachinetemplates,scope=Namespaced,categories=cluster-api diff --git a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockerclusters.yaml b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockerclusters.yaml index 856be849dec6..a2b88acf0c29 100644 --- a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockerclusters.yaml +++ b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockerclusters.yaml @@ -152,7 +152,7 @@ spec: - ready type: object type: object - served: true + served: false storage: false subresources: status: {} diff --git a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinepools.yaml b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinepools.yaml index 0bfb655915e0..c8b0e92675c3 100644 --- a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinepools.yaml +++ b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinepools.yaml @@ -193,7 +193,7 @@ spec: type: integer type: object type: object - served: true + served: false storage: false subresources: status: {} diff --git a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachines.yaml b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachines.yaml index bda9a2be41ab..5dc540fed23a 100644 --- a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachines.yaml +++ b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachines.yaml @@ -155,7 +155,7 @@ spec: type: boolean type: object type: object - served: true + served: false storage: false subresources: status: {} diff --git a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinetemplates.yaml b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinetemplates.yaml index 7a209751d581..bf9afa14a380 100644 --- a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinetemplates.yaml +++ b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinetemplates.yaml @@ -96,7 +96,7 @@ spec: - template type: object type: object - served: true + served: false storage: false - additionalPrinterColumns: - description: Time duration since creation of DockerMachineTemplate diff --git a/test/infrastructure/docker/exp/api/v1alpha3/dockermachinepool_types.go b/test/infrastructure/docker/exp/api/v1alpha3/dockermachinepool_types.go index e04ca0766727..068f0dc3ce6b 100644 --- a/test/infrastructure/docker/exp/api/v1alpha3/dockermachinepool_types.go +++ b/test/infrastructure/docker/exp/api/v1alpha3/dockermachinepool_types.go @@ -113,6 +113,7 @@ type DockerMachinePoolInstanceStatus struct { // +kubebuilder:resource:path=dockermachinepools,scope=Namespaced,categories=cluster-api // +kubebuilder:object:root=true +// +kubebuilder:unservedversion // +kubebuilder:deprecatedversion // +kubebuilder:subresource:status