diff --git a/api/v1beta1/cluster_types.go b/api/v1beta1/cluster_types.go index 1b05c471edbf..fa62a1cd4117 100644 --- a/api/v1beta1/cluster_types.go +++ b/api/v1beta1/cluster_types.go @@ -101,11 +101,10 @@ type Topology struct { // ControlPlaneTopology specifies the parameters for the control plane nodes in the cluster. type ControlPlaneTopology struct { - // Metadata is the metadata applied to the machines of the ControlPlane. + // Metadata is the metadata applied to the ControlPlane and the Machines of the ControlPlane + // if the ControlPlaneTemplate referenced by the ClusterClass is machine based. If not, it + // is applied only to the ControlPlane. // At runtime this metadata is merged with the corresponding metadata from the ClusterClass. - // - // This field is supported if and only if the control plane provider template - // referenced in the ClusterClass is Machine based. // +optional Metadata ObjectMeta `json:"metadata,omitempty"` @@ -149,7 +148,7 @@ type WorkersTopology struct { // MachineDeploymentTopology specifies the different parameters for a set of worker nodes in the topology. // This set of nodes is managed by a MachineDeployment object whose lifecycle is managed by the Cluster controller. type MachineDeploymentTopology struct { - // Metadata is the metadata applied to the machines of the MachineDeployment. + // Metadata is the metadata applied to the MachineDeployment and the machines of the MachineDeployment. // At runtime this metadata is merged with the corresponding metadata from the ClusterClass. // +optional Metadata ObjectMeta `json:"metadata,omitempty"` diff --git a/api/v1beta1/clusterclass_types.go b/api/v1beta1/clusterclass_types.go index 26b4bf6b0bb8..f5ab05c77754 100644 --- a/api/v1beta1/clusterclass_types.go +++ b/api/v1beta1/clusterclass_types.go @@ -75,7 +75,9 @@ type ClusterClassSpec struct { // ControlPlaneClass defines the class for the control plane. type ControlPlaneClass struct { - // Metadata is the metadata applied to the machines of the ControlPlane. + // Metadata is the metadata applied to the ControlPlane and the Machines of the ControlPlane + // if the ControlPlaneTemplate referenced is machine based. If not, it is applied only to the + // ControlPlane. // At runtime this metadata is merged with the corresponding metadata from the topology. // // This field is supported if and only if the control plane provider template @@ -188,7 +190,7 @@ type MachineDeploymentClass struct { // MachineDeploymentClassTemplate defines how a MachineDeployment generated from a MachineDeploymentClass // should look like. type MachineDeploymentClassTemplate struct { - // Metadata is the metadata applied to the machines of the MachineDeployment. + // Metadata is the metadata applied to the MachineDeployment and the machines of the MachineDeployment. // At runtime this metadata is merged with the corresponding metadata from the topology. // +optional Metadata ObjectMeta `json:"metadata,omitempty"` diff --git a/api/v1beta1/zz_generated.openapi.go b/api/v1beta1/zz_generated.openapi.go index 44f04c11198f..66bdbfb762b7 100644 --- a/api/v1beta1/zz_generated.openapi.go +++ b/api/v1beta1/zz_generated.openapi.go @@ -815,7 +815,7 @@ func schema_sigsk8sio_cluster_api_api_v1beta1_ControlPlaneClass(ref common.Refer Properties: map[string]spec.Schema{ "metadata": { SchemaProps: spec.SchemaProps{ - Description: "Metadata is the metadata applied to the machines of the ControlPlane. At runtime this metadata is merged with the corresponding metadata from the topology.\n\nThis field is supported if and only if the control plane provider template referenced is Machine based.", + Description: "Metadata is the metadata applied to the ControlPlane and the Machines of the ControlPlane if the ControlPlaneTemplate referenced is machine based. If not, it is applied only to the ControlPlane. At runtime this metadata is merged with the corresponding metadata from the topology.\n\nThis field is supported if and only if the control plane provider template referenced is Machine based.", Default: map[string]interface{}{}, Ref: ref("sigs.k8s.io/cluster-api/api/v1beta1.ObjectMeta"), }, @@ -874,7 +874,7 @@ func schema_sigsk8sio_cluster_api_api_v1beta1_ControlPlaneTopology(ref common.Re Properties: map[string]spec.Schema{ "metadata": { SchemaProps: spec.SchemaProps{ - Description: "Metadata is the metadata applied to the machines of the ControlPlane. At runtime this metadata is merged with the corresponding metadata from the ClusterClass.\n\nThis field is supported if and only if the control plane provider template referenced in the ClusterClass is Machine based.", + Description: "Metadata is the metadata applied to the ControlPlane and the Machines of the ControlPlane if the ControlPlaneTemplate referenced by the ClusterClass is machine based. If not, it is applied only to the ControlPlane. At runtime this metadata is merged with the corresponding metadata from the ClusterClass.", Default: map[string]interface{}{}, Ref: ref("sigs.k8s.io/cluster-api/api/v1beta1.ObjectMeta"), }, @@ -1481,7 +1481,7 @@ func schema_sigsk8sio_cluster_api_api_v1beta1_MachineDeploymentClassTemplate(ref Properties: map[string]spec.Schema{ "metadata": { SchemaProps: spec.SchemaProps{ - Description: "Metadata is the metadata applied to the machines of the MachineDeployment. At runtime this metadata is merged with the corresponding metadata from the topology.", + Description: "Metadata is the metadata applied to the MachineDeployment and the machines of the MachineDeployment. At runtime this metadata is merged with the corresponding metadata from the topology.", Default: map[string]interface{}{}, Ref: ref("sigs.k8s.io/cluster-api/api/v1beta1.ObjectMeta"), }, @@ -1764,7 +1764,7 @@ func schema_sigsk8sio_cluster_api_api_v1beta1_MachineDeploymentTopology(ref comm Properties: map[string]spec.Schema{ "metadata": { SchemaProps: spec.SchemaProps{ - Description: "Metadata is the metadata applied to the machines of the MachineDeployment. At runtime this metadata is merged with the corresponding metadata from the ClusterClass.", + Description: "Metadata is the metadata applied to the MachineDeployment and the machines of the MachineDeployment. At runtime this metadata is merged with the corresponding metadata from the ClusterClass.", Default: map[string]interface{}{}, Ref: ref("sigs.k8s.io/cluster-api/api/v1beta1.ObjectMeta"), }, diff --git a/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml b/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml index 3dd293e2d4b7..e73daa58fb89 100644 --- a/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml +++ b/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml @@ -560,11 +560,13 @@ spec: - ref type: object metadata: - description: "Metadata is the metadata applied to the machines - of the ControlPlane. At runtime this metadata is merged with - the corresponding metadata from the topology. \n This field - is supported if and only if the control plane provider template - referenced is Machine based." + description: "Metadata is the metadata applied to the ControlPlane + and the Machines of the ControlPlane if the ControlPlaneTemplate + referenced is machine based. If not, it is applied only to the + ControlPlane. At runtime this metadata is merged with the corresponding + metadata from the topology. \n This field is supported if and + only if the control plane provider template referenced is Machine + based." properties: annotations: additionalProperties: @@ -1357,9 +1359,9 @@ spec: type: object metadata: description: Metadata is the metadata applied to the - machines of the MachineDeployment. At runtime this - metadata is merged with the corresponding metadata - from the topology. + MachineDeployment and the machines of the MachineDeployment. + At runtime this metadata is merged with the corresponding + metadata from the topology. properties: annotations: additionalProperties: diff --git a/config/crd/bases/cluster.x-k8s.io_clusters.yaml b/config/crd/bases/cluster.x-k8s.io_clusters.yaml index d08afa6ccae7..227e10093e5a 100644 --- a/config/crd/bases/cluster.x-k8s.io_clusters.yaml +++ b/config/crd/bases/cluster.x-k8s.io_clusters.yaml @@ -951,12 +951,12 @@ spec: type: string type: object metadata: - description: "Metadata is the metadata applied to the machines - of the ControlPlane. At runtime this metadata is merged - with the corresponding metadata from the ClusterClass. \n - This field is supported if and only if the control plane - provider template referenced in the ClusterClass is Machine - based." + description: Metadata is the metadata applied to the ControlPlane + and the Machines of the ControlPlane if the ControlPlaneTemplate + referenced by the ClusterClass is machine based. If not, + it is applied only to the ControlPlane. At runtime this + metadata is merged with the corresponding metadata from + the ClusterClass. properties: annotations: additionalProperties: @@ -1189,9 +1189,9 @@ spec: type: object metadata: description: Metadata is the metadata applied to the - machines of the MachineDeployment. At runtime this - metadata is merged with the corresponding metadata - from the ClusterClass. + MachineDeployment and the machines of the MachineDeployment. + At runtime this metadata is merged with the corresponding + metadata from the ClusterClass. properties: annotations: additionalProperties: diff --git a/internal/controllers/topology/cluster/desired_state.go b/internal/controllers/topology/cluster/desired_state.go index 874d57dc4a3b..b65f85cc0875 100644 --- a/internal/controllers/topology/cluster/desired_state.go +++ b/internal/controllers/topology/cluster/desired_state.go @@ -179,12 +179,29 @@ func (r *Reconciler) computeControlPlane(ctx context.Context, s *scope.Scope, in cluster := s.Current.Cluster currentRef := cluster.Spec.ControlPlaneRef + // Compute the labels and annotations to be applied to ControlPlane metadata and ControlPlane machines. + // We merge the labels and annotations from topology and ClusterClass. + // We also add the cluster-name and the topology owned labels, so they are propagated down. + topologyMetadata := s.Blueprint.Topology.ControlPlane.Metadata + clusterClassMetadata := s.Blueprint.ClusterClass.Spec.ControlPlane.Metadata + + controlPlaneLabels := mergeMap(topologyMetadata.Labels, clusterClassMetadata.Labels) + if controlPlaneLabels == nil { + controlPlaneLabels = map[string]string{} + } + controlPlaneLabels[clusterv1.ClusterNameLabel] = cluster.Name + controlPlaneLabels[clusterv1.ClusterTopologyOwnedLabel] = "" + + controlPlaneAnnotations := mergeMap(topologyMetadata.Annotations, clusterClassMetadata.Annotations) + controlPlane, err := templateToObject(templateToInput{ template: template, templateClonedFromRef: templateClonedFromRef, cluster: cluster, namePrefix: fmt.Sprintf("%s-", cluster.Name), currentObjectRef: currentRef, + labels: controlPlaneLabels, + annotations: controlPlaneAnnotations, // Note: It is not possible to add an ownerRef to Cluster at this stage, otherwise the provisioning // of the ControlPlane starts no matter of the object being actually referenced by the Cluster itself. }) @@ -224,22 +241,11 @@ func (r *Reconciler) computeControlPlane(ctx context.Context, s *scope.Scope, in return nil, errors.Wrap(err, "failed to spec.machineTemplate.infrastructureRef in the ControlPlane object") } - // Compute the labels and annotations to be applied to ControlPlane machines. - // We merge the labels and annotations from topology and ClusterClass. - // We also add the cluster-name and the topology owned labels, so they are propagated down to Machines. - topologyMetadata := s.Blueprint.Topology.ControlPlane.Metadata - clusterClassMetadata := s.Blueprint.ClusterClass.Spec.ControlPlane.Metadata - - machineLabels := mergeMap(topologyMetadata.Labels, clusterClassMetadata.Labels) - if machineLabels == nil { - machineLabels = map[string]string{} - } - machineLabels[clusterv1.ClusterNameLabel] = cluster.Name - machineLabels[clusterv1.ClusterTopologyOwnedLabel] = "" + // Apply the ControlPlane labels and annotations to the ControlPlane machines as well. if err := contract.ControlPlane().MachineTemplate().Metadata().Set(controlPlane, &clusterv1.ObjectMeta{ - Labels: machineLabels, - Annotations: mergeMap(topologyMetadata.Annotations, clusterClassMetadata.Annotations), + Labels: controlPlaneLabels, + Annotations: controlPlaneAnnotations, }); err != nil { return nil, errors.Wrap(err, "failed to set spec.machineTemplate.metadata in the ControlPlane object") } @@ -659,10 +665,6 @@ func computeMachineDeployment(_ context.Context, s *scope.Scope, desiredControlP MinReadySeconds: minReadySeconds, Strategy: strategy, Template: clusterv1.MachineTemplateSpec{ - ObjectMeta: clusterv1.ObjectMeta{ - Labels: mergeMap(machineDeploymentTopology.Metadata.Labels, machineDeploymentBlueprint.Metadata.Labels), - Annotations: mergeMap(machineDeploymentTopology.Metadata.Annotations, machineDeploymentBlueprint.Metadata.Annotations), - }, Spec: clusterv1.MachineSpec{ ClusterName: s.Current.Cluster.Name, Version: pointer.String(version), @@ -683,14 +685,27 @@ func computeMachineDeployment(_ context.Context, s *scope.Scope, desiredControlP desiredMachineDeploymentObj.SetName(currentMachineDeployment.Object.Name) } + // Apply annotations + machineDeploymentAnnotations := mergeMap(machineDeploymentTopology.Metadata.Annotations, machineDeploymentBlueprint.Metadata.Annotations) + desiredMachineDeploymentObj.SetAnnotations(machineDeploymentAnnotations) + desiredMachineDeploymentObj.Spec.Template.Annotations = machineDeploymentAnnotations + // Apply Labels // NOTE: On top of all the labels applied to managed objects we are applying the ClusterTopologyMachineDeploymentLabel // keeping track of the MachineDeployment name from the Topology; this will be used to identify the object in next reconcile loops. - labels := map[string]string{} - labels[clusterv1.ClusterNameLabel] = s.Current.Cluster.Name - labels[clusterv1.ClusterTopologyOwnedLabel] = "" - labels[clusterv1.ClusterTopologyMachineDeploymentNameLabel] = machineDeploymentTopology.Name - desiredMachineDeploymentObj.SetLabels(labels) + machineDeploymentLabels := mergeMap(machineDeploymentTopology.Metadata.Labels, machineDeploymentBlueprint.Metadata.Labels) + if machineDeploymentLabels == nil { + machineDeploymentLabels = map[string]string{} + } + machineDeploymentLabels[clusterv1.ClusterNameLabel] = s.Current.Cluster.Name + machineDeploymentLabels[clusterv1.ClusterTopologyOwnedLabel] = "" + machineDeploymentLabels[clusterv1.ClusterTopologyMachineDeploymentNameLabel] = machineDeploymentTopology.Name + desiredMachineDeploymentObj.SetLabels(machineDeploymentLabels) + + // Also set the labels in .spec.template.labels so that they are propagated to + // MachineSet.labels and MachineSet.spec.template.labels and thus to Machine.labels. + // Note: the labels in MachineSet are used to properly cleanup templates when the MachineSet is deleted. + desiredMachineDeploymentObj.Spec.Template.Labels = machineDeploymentLabels // Set the selector with the subset of labels identifying controlled machines. // NOTE: this prevents the web hook to add cluster.x-k8s.io/deployment-name label, that is @@ -700,16 +715,6 @@ func computeMachineDeployment(_ context.Context, s *scope.Scope, desiredControlP desiredMachineDeploymentObj.Spec.Selector.MatchLabels[clusterv1.ClusterTopologyOwnedLabel] = "" desiredMachineDeploymentObj.Spec.Selector.MatchLabels[clusterv1.ClusterTopologyMachineDeploymentNameLabel] = machineDeploymentTopology.Name - // Also set the labels in .spec.template.labels so that they are propagated to - // MachineSet.labels and MachineSet.spec.template.labels and thus to Machine.labels. - // Note: the labels in MachineSet are used to properly cleanup templates when the MachineSet is deleted. - if desiredMachineDeploymentObj.Spec.Template.Labels == nil { - desiredMachineDeploymentObj.Spec.Template.Labels = map[string]string{} - } - desiredMachineDeploymentObj.Spec.Template.Labels[clusterv1.ClusterNameLabel] = s.Current.Cluster.Name - desiredMachineDeploymentObj.Spec.Template.Labels[clusterv1.ClusterTopologyOwnedLabel] = "" - desiredMachineDeploymentObj.Spec.Template.Labels[clusterv1.ClusterTopologyMachineDeploymentNameLabel] = machineDeploymentTopology.Name - // Set the desired replicas. desiredMachineDeploymentObj.Spec.Replicas = machineDeploymentTopology.Replicas @@ -838,6 +843,8 @@ type templateToInput struct { cluster *clusterv1.Cluster namePrefix string currentObjectRef *corev1.ObjectReference + labels map[string]string + annotations map[string]string // OwnerRef is an optional OwnerReference to attach to the cloned object. ownerRef *metav1.OwnerReference } @@ -849,6 +856,9 @@ func templateToObject(in templateToInput) (*unstructured.Unstructured, error) { // NOTE: The cluster label is added at creation time so this object could be read by the ClusterTopology // controller immediately after creation, even before other controllers are going to add the label (if missing). labels := map[string]string{} + for k, v := range in.labels { + labels[k] = v + } labels[clusterv1.ClusterNameLabel] = in.cluster.Name labels[clusterv1.ClusterTopologyOwnedLabel] = "" @@ -860,6 +870,7 @@ func templateToObject(in templateToInput) (*unstructured.Unstructured, error) { TemplateRef: in.templateClonedFromRef, Namespace: in.cluster.Namespace, Labels: labels, + Annotations: in.annotations, ClusterName: in.cluster.Name, OwnerRef: in.ownerRef, }) @@ -901,6 +912,9 @@ func templateToTemplate(in templateToInput) *unstructured.Unstructured { if labels == nil { labels = map[string]string{} } + for k, v := range in.labels { + labels[k] = v + } labels[clusterv1.ClusterNameLabel] = in.cluster.Name labels[clusterv1.ClusterTopologyOwnedLabel] = "" template.SetLabels(labels) @@ -911,6 +925,9 @@ func templateToTemplate(in templateToInput) *unstructured.Unstructured { if annotations == nil { annotations = map[string]string{} } + for k, v := range in.annotations { + annotations[k] = v + } annotations[clusterv1.TemplateClonedFromNameAnnotation] = in.templateClonedFromRef.Name annotations[clusterv1.TemplateClonedFromGroupKindAnnotation] = in.templateClonedFromRef.GroupVersionKind().GroupKind().String() delete(annotations, corev1.LastAppliedConfigAnnotation) diff --git a/internal/controllers/topology/cluster/desired_state_test.go b/internal/controllers/topology/cluster/desired_state_test.go index bee52479d171..8ff7bf21c836 100644 --- a/internal/controllers/topology/cluster/desired_state_test.go +++ b/internal/controllers/topology/cluster/desired_state_test.go @@ -317,6 +317,8 @@ func TestComputeControlPlane(t *testing.T) { template: blueprint.ControlPlane.Template, currentRef: nil, obj: obj, + labels: mergeMap(blueprint.Topology.ControlPlane.Metadata.Labels, blueprint.ClusterClass.Spec.ControlPlane.Metadata.Labels), + annotations: mergeMap(blueprint.Topology.ControlPlane.Metadata.Annotations, blueprint.ClusterClass.Spec.ControlPlane.Metadata.Annotations), }) assertNestedField(g, obj, version, contract.ControlPlane().Version().Path()...) @@ -406,6 +408,8 @@ func TestComputeControlPlane(t *testing.T) { template: blueprint.ControlPlane.Template, currentRef: nil, obj: obj, + labels: mergeMap(blueprint.Topology.ControlPlane.Metadata.Labels, blueprint.ClusterClass.Spec.ControlPlane.Metadata.Labels), + annotations: mergeMap(blueprint.Topology.ControlPlane.Metadata.Annotations, blueprint.ClusterClass.Spec.ControlPlane.Metadata.Annotations), }) assertNestedField(g, obj, version, contract.ControlPlane().Version().Path()...) @@ -449,6 +453,8 @@ func TestComputeControlPlane(t *testing.T) { template: blueprint.ControlPlane.Template, currentRef: nil, obj: obj, + labels: mergeMap(blueprint.Topology.ControlPlane.Metadata.Labels, blueprint.ClusterClass.Spec.ControlPlane.Metadata.Labels), + annotations: mergeMap(blueprint.Topology.ControlPlane.Metadata.Annotations, blueprint.ClusterClass.Spec.ControlPlane.Metadata.Annotations), }) gotMetadata, err := contract.ControlPlane().MachineTemplate().Metadata().Get(obj) g.Expect(err).ToNot(HaveOccurred()) @@ -501,6 +507,8 @@ func TestComputeControlPlane(t *testing.T) { template: blueprint.ControlPlane.Template, currentRef: scope.Current.Cluster.Spec.ControlPlaneRef, obj: obj, + labels: mergeMap(blueprint.Topology.ControlPlane.Metadata.Labels, blueprint.ClusterClass.Spec.ControlPlane.Metadata.Labels), + annotations: mergeMap(blueprint.Topology.ControlPlane.Metadata.Annotations, blueprint.ClusterClass.Spec.ControlPlane.Metadata.Annotations), }) }) t.Run("Should choose the correct version for control plane", func(t *testing.T) { @@ -1449,6 +1457,9 @@ func TestComputeMachineDeployment(t *testing.T) { g.Expect(actualMd.Labels).To(HaveKeyWithValue(clusterv1.ClusterTopologyMachineDeploymentNameLabel, "big-pool-of-machines")) g.Expect(actualMd.Labels).To(HaveKey(clusterv1.ClusterTopologyOwnedLabel)) + for k, v := range mergeMap(mdTopology.Metadata.Labels, md1.Template.Metadata.Labels) { + g.Expect(actualMd.Labels).To(HaveKeyWithValue(k, v)) + } g.Expect(actualMd.Spec.Selector.MatchLabels).To(HaveKey(clusterv1.ClusterTopologyOwnedLabel)) g.Expect(actualMd.Spec.Selector.MatchLabels).To(HaveKeyWithValue(clusterv1.ClusterTopologyMachineDeploymentNameLabel, "big-pool-of-machines")) @@ -1529,6 +1540,9 @@ func TestComputeMachineDeployment(t *testing.T) { g.Expect(actualMd.Labels).To(HaveKeyWithValue(clusterv1.ClusterTopologyMachineDeploymentNameLabel, "big-pool-of-machines")) g.Expect(actualMd.Labels).To(HaveKey(clusterv1.ClusterTopologyOwnedLabel)) + for k, v := range mergeMap(mdTopology.Metadata.Labels, md1.Template.Metadata.Labels) { + g.Expect(actualMd.Labels).To(HaveKeyWithValue(k, v)) + } g.Expect(actualMd.Spec.Template.ObjectMeta.Labels).To(HaveKeyWithValue("foo", "baz")) g.Expect(actualMd.Spec.Template.ObjectMeta.Labels).To(HaveKeyWithValue("fizz", "buzz")) diff --git a/test/e2e/data/infrastructure-docker/main/bases/cluster-with-topology.yaml b/test/e2e/data/infrastructure-docker/main/bases/cluster-with-topology.yaml index b54e06498860..597cb649f852 100644 --- a/test/e2e/data/infrastructure-docker/main/bases/cluster-with-topology.yaml +++ b/test/e2e/data/infrastructure-docker/main/bases/cluster-with-topology.yaml @@ -16,7 +16,11 @@ spec: class: "quick-start" version: "${KUBERNETES_VERSION}" controlPlane: - metadata: {} + metadata: + labels: + label-from-cluster-topology: "value-from-cluster-topology" + annotations: + annotation-from-cluster-topology: "value-from-cluster-topology" nodeDeletionTimeout: "30s" nodeVolumeDetachTimeout: "5m" replicas: ${CONTROL_PLANE_MACHINE_COUNT} @@ -24,6 +28,11 @@ spec: machineDeployments: - class: "default-worker" name: "md-0" + metadata: + labels: + label-from-cluster-topology: "value-from-cluster-topology" + annotations: + annotation-from-cluster-topology: "value-from-cluster-topology" nodeDeletionTimeout: "30s" nodeVolumeDetachTimeout: "5m" minReadySeconds: 5 diff --git a/test/e2e/data/infrastructure-docker/main/clusterclass-quick-start.yaml b/test/e2e/data/infrastructure-docker/main/clusterclass-quick-start.yaml index c847da962320..06ded8f71045 100644 --- a/test/e2e/data/infrastructure-docker/main/clusterclass-quick-start.yaml +++ b/test/e2e/data/infrastructure-docker/main/clusterclass-quick-start.yaml @@ -4,6 +4,11 @@ metadata: name: quick-start spec: controlPlane: + metadata: + labels: + label-from-clusterclass: "value-from-clusterclass" + annotations: + annotation-from-clusterclass: "value-from-clusterclass" ref: apiVersion: controlplane.cluster.x-k8s.io/v1beta1 kind: KubeadmControlPlaneTemplate @@ -28,6 +33,11 @@ spec: machineDeployments: - class: default-worker template: + metadata: + labels: + label-from-clusterclass: "value-from-clusterclass" + annotations: + annotation-from-clusterclass: "value-from-clusterclass" bootstrap: ref: apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 diff --git a/test/e2e/data/infrastructure-docker/v1.2/bases/cluster-with-topology.yaml b/test/e2e/data/infrastructure-docker/v1.2/bases/cluster-with-topology.yaml index b0a0ba389aad..f5c9fab6785c 100644 --- a/test/e2e/data/infrastructure-docker/v1.2/bases/cluster-with-topology.yaml +++ b/test/e2e/data/infrastructure-docker/v1.2/bases/cluster-with-topology.yaml @@ -16,7 +16,11 @@ spec: class: "quick-start" version: "${KUBERNETES_VERSION}" controlPlane: - metadata: {} + metadata: + labels: + label-from-cluster-topology: "value-from-cluster-topology" + annotations: + annotation-from-cluster-topology: "value-from-cluster-topology" # Can't be used as this field doesn't exist in v1.2.x. #nodeDeletionTimeout: "30s" replicas: ${CONTROL_PLANE_MACHINE_COUNT} @@ -24,6 +28,11 @@ spec: machineDeployments: - class: "default-worker" name: "md-0" + metadata: + labels: + label-from-cluster-topology: "value-from-cluster-topology" + annotations: + annotation-from-cluster-topology: "value-from-cluster-topology" # Can't be used as this field doesn't exist in v1.2.x. #nodeDeletionTimeout: "30s" replicas: ${WORKER_MACHINE_COUNT} diff --git a/test/e2e/data/infrastructure-docker/v1.2/clusterclass-quick-start.yaml b/test/e2e/data/infrastructure-docker/v1.2/clusterclass-quick-start.yaml index ed0d800b77bc..752166a744ca 100644 --- a/test/e2e/data/infrastructure-docker/v1.2/clusterclass-quick-start.yaml +++ b/test/e2e/data/infrastructure-docker/v1.2/clusterclass-quick-start.yaml @@ -4,6 +4,11 @@ metadata: name: quick-start spec: controlPlane: + metadata: + labels: + label-from-clusterclass: "value-from-clusterclass" + annotations: + annotation-from-clusterclass: "value-from-clusterclass" ref: apiVersion: controlplane.cluster.x-k8s.io/v1beta1 kind: KubeadmControlPlaneTemplate @@ -28,6 +33,11 @@ spec: machineDeployments: - class: default-worker template: + metadata: + labels: + label-from-clusterclass: "value-from-clusterclass" + annotations: + annotation-from-clusterclass: "value-from-clusterclass" bootstrap: ref: apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 diff --git a/test/e2e/data/infrastructure-docker/v1.3/bases/cluster-with-topology.yaml b/test/e2e/data/infrastructure-docker/v1.3/bases/cluster-with-topology.yaml index 96574eab73ce..5d03ea309283 100644 --- a/test/e2e/data/infrastructure-docker/v1.3/bases/cluster-with-topology.yaml +++ b/test/e2e/data/infrastructure-docker/v1.3/bases/cluster-with-topology.yaml @@ -16,7 +16,11 @@ spec: class: "quick-start" version: "${KUBERNETES_VERSION}" controlPlane: - metadata: {} + metadata: + labels: + label-from-cluster-topology: "value-from-cluster-topology" + annotations: + annotation-from-cluster-topology: "value-from-cluster-topology" nodeDeletionTimeout: "30s" nodeVolumeDetachTimeout: "5m" replicas: ${CONTROL_PLANE_MACHINE_COUNT} @@ -24,6 +28,11 @@ spec: machineDeployments: - class: "default-worker" name: "md-0" + metadata: + labels: + label-from-cluster-topology: "value-from-cluster-topology" + annotations: + annotation-from-cluster-topology: "value-from-cluster-topology" nodeDeletionTimeout: "30s" nodeVolumeDetachTimeout: "5m" minReadySeconds: 5 diff --git a/test/e2e/data/infrastructure-docker/v1.3/clusterclass-quick-start.yaml b/test/e2e/data/infrastructure-docker/v1.3/clusterclass-quick-start.yaml index f11423db1d00..483a944ade01 100644 --- a/test/e2e/data/infrastructure-docker/v1.3/clusterclass-quick-start.yaml +++ b/test/e2e/data/infrastructure-docker/v1.3/clusterclass-quick-start.yaml @@ -4,6 +4,11 @@ metadata: name: quick-start spec: controlPlane: + metadata: + labels: + label-from-clusterclass: "value-from-clusterclass" + annotations: + annotation-from-clusterclass: "value-from-clusterclass" ref: apiVersion: controlplane.cluster.x-k8s.io/v1beta1 kind: KubeadmControlPlaneTemplate @@ -28,6 +33,11 @@ spec: machineDeployments: - class: default-worker template: + metadata: + labels: + label-from-clusterclass: "value-from-clusterclass" + annotations: + annotation-from-clusterclass: "value-from-clusterclass" bootstrap: ref: apiVersion: bootstrap.cluster.x-k8s.io/v1beta1