diff --git a/hack/charts/cluster-api-operator/templates/core.yaml b/hack/charts/cluster-api-operator/templates/core.yaml index 260efb59..4235cd71 100644 --- a/hack/charts/cluster-api-operator/templates/core.yaml +++ b/hack/charts/cluster-api-operator/templates/core.yaml @@ -43,6 +43,15 @@ spec: {{- if $coreVersion }} version: {{ $coreVersion }} {{- end }} +{{- if $.Values.manager }} + manager: +{{- if $.Values.manager.featureGates.core }} + featureGates: + {{- range $key, $value := $.Values.manager.featureGates.core }} + {{ $key }}: {{ $value }} + {{- end }} +{{- end }} +{{- end }} {{- if $.Values.configSecret.name }} configSecret: name: {{ $.Values.configSecret.name }} diff --git a/hack/charts/cluster-api-operator/templates/infra.yaml b/hack/charts/cluster-api-operator/templates/infra.yaml index d7b46e71..5f813a22 100644 --- a/hack/charts/cluster-api-operator/templates/infra.yaml +++ b/hack/charts/cluster-api-operator/templates/infra.yaml @@ -46,10 +46,14 @@ spec: {{- end }} {{- if $.Values.manager }} manager: -{{- if $.Values.manager.featureGates }} - featureGates: +{{- if hasKey $.Values.manager.featureGates $infrastructureName }} {{- range $key, $value := $.Values.manager.featureGates }} - {{ $key }}: {{ $value }} + {{- if eq $key $infrastructureName }} + featureGates: + {{- range $k, $v := $value }} + {{ $k }}: {{ $v }} + {{- end }} + {{- end }} {{- end }} {{- end }} {{- end }} diff --git a/test/e2e/helm_test.go b/test/e2e/helm_test.go index 066ca938..9f109ab8 100644 --- a/test/e2e/helm_test.go +++ b/test/e2e/helm_test.go @@ -206,4 +206,27 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func Expect(err).ToNot(HaveOccurred()) Expect(manifests).To(Equal(string(expectedManifests))) }) + It("should deploy core and infra with feature gates enabled", func() { + manifests, err := helmChart.Run(map[string]string{ + "configSecret.name": "aws-variables", + "configSecret.namespace": "default", + "infrastructure": "aws:v2.4.0", + "addon": "helm:", + "image.manager.tag": "v0.9.1", + "cert-manager.enabled": "false", + "cert-manager.installCRDs": "false", + "core": "cluster-api:v1.6.2", + "manager.featureGates.core.ClusterTopology": "true", + "manager.featureGates.core.MachinePool": "true", + "manager.featureGates.aws.ClusterTopology": "true", + "manager.featureGates.aws.MachinePool": "true", + "manager.featureGates.aws.EKSEnableIAM": "true", + "manager.featureGates.aws.EKSAllowAddRoles": "true", + }) + Expect(err).ToNot(HaveOccurred()) + Expect(manifests).ToNot(BeEmpty()) + expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "feature-gates.yaml")) + Expect(err).ToNot(HaveOccurred()) + Expect(manifests).To(Equal(string(expectedManifests))) + }) }) diff --git a/test/e2e/resources/feature-gates.yaml b/test/e2e/resources/feature-gates.yaml new file mode 100644 index 00000000..2bc1baa8 --- /dev/null +++ b/test/e2e/resources/feature-gates.yaml @@ -0,0 +1,123 @@ +--- +# Source: cluster-api-operator/templates/addon.yaml +apiVersion: v1 +kind: Namespace +metadata: + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "1" + name: helm-addon-system +--- +# Source: cluster-api-operator/templates/core.yaml +apiVersion: v1 +kind: Namespace +metadata: + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "1" + name: capi-system +--- +# Source: cluster-api-operator/templates/infra-conditions.yaml +apiVersion: v1 +kind: Namespace +metadata: + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "1" + name: capi-kubeadm-bootstrap-system +--- +# Source: cluster-api-operator/templates/infra-conditions.yaml +apiVersion: v1 +kind: Namespace +metadata: + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "1" + name: capi-kubeadm-control-plane-system +--- +# Source: cluster-api-operator/templates/infra.yaml +apiVersion: v1 +kind: Namespace +metadata: + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "1" + name: aws-infrastructure-system +--- +# Source: cluster-api-operator/templates/addon.yaml +apiVersion: operator.cluster.x-k8s.io/v1alpha2 +kind: AddonProvider +metadata: + name: helm + namespace: helm-addon-system + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "2" +--- +# Source: cluster-api-operator/templates/infra-conditions.yaml +apiVersion: operator.cluster.x-k8s.io/v1alpha2 +kind: BootstrapProvider +metadata: + name: kubeadm + namespace: capi-kubeadm-bootstrap-system + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "2" +spec: + configSecret: + name: aws-variables + namespace: default +--- +# Source: cluster-api-operator/templates/infra-conditions.yaml +apiVersion: operator.cluster.x-k8s.io/v1alpha2 +kind: ControlPlaneProvider +metadata: + name: kubeadm + namespace: capi-kubeadm-control-plane-system + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "2" +spec: + configSecret: + name: aws-variables + namespace: default +--- +# Source: cluster-api-operator/templates/core.yaml +apiVersion: operator.cluster.x-k8s.io/v1alpha2 +kind: CoreProvider +metadata: + name: cluster-api + namespace: capi-system + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "2" +spec: + version: v1.6.2 + manager: + featureGates: + ClusterTopology: true + MachinePool: true + configSecret: + name: aws-variables + namespace: default +--- +# Source: cluster-api-operator/templates/infra.yaml +apiVersion: operator.cluster.x-k8s.io/v1alpha2 +kind: InfrastructureProvider +metadata: + name: aws + namespace: aws-infrastructure-system + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "2" +spec: + version: v2.4.0 + manager: + featureGates: + ClusterTopology: true + EKSAllowAddRoles: true + EKSEnableIAM: true + MachinePool: true + configSecret: + name: aws-variables + namespace: default \ No newline at end of file