Skip to content

Commit

Permalink
Merge pull request #484 from k8s-infra-cherrypick-robot/cherry-pick-4…
Browse files Browse the repository at this point in the history
…48-to-release-0.9

[release-0.9] ✨ Ability to add provider specific featureGates with Helm
  • Loading branch information
k8s-ci-robot authored Apr 9, 2024
2 parents 5f27a69 + f7f569d commit 4622794
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 3 deletions.
9 changes: 9 additions & 0 deletions hack/charts/cluster-api-operator/templates/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
10 changes: 7 additions & 3 deletions hack/charts/cluster-api-operator/templates/infra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
23 changes: 23 additions & 0 deletions test/e2e/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
})
})
123 changes: 123 additions & 0 deletions test/e2e/resources/feature-gates.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4622794

Please sign in to comment.