Skip to content

Commit 7eb2d57

Browse files
authored
Merge pull request #536 from kahirokunn/kubeadm-feature-flag
✨ Add featureGates to ControlPlaneProvider
2 parents e70a9ee + 80c8b64 commit 7eb2d57

File tree

4 files changed

+147
-1
lines changed

4 files changed

+147
-1
lines changed

hack/charts/cluster-api-operator/templates/control-plane.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,25 @@ metadata:
3838
annotations:
3939
"helm.sh/hook": "post-install,post-upgrade"
4040
"helm.sh/hook-weight": "2"
41-
{{- if or $controlPlaneVersion $.Values.configSecret.name }}
41+
{{- if or $controlPlaneVersion $.Values.configSecret.name $.Values.manager }}
4242
spec:
4343
{{- end}}
4444
{{- if $controlPlaneVersion }}
4545
version: {{ $controlPlaneVersion }}
4646
{{- end }}
47+
{{- if $.Values.manager }}
48+
manager:
49+
{{- if hasKey $.Values.manager.featureGates $controlPlaneName }}
50+
{{- range $key, $value := $.Values.manager.featureGates }}
51+
{{- if eq $key $controlPlaneName }}
52+
featureGates:
53+
{{- range $k, $v := $value }}
54+
{{ $k }}: {{ $v }}
55+
{{- end }}
56+
{{- end }}
57+
{{- end }}
58+
{{- end }}
59+
{{- end }}
4760
{{- if $.Values.configSecret.name }}
4861
configSecret:
4962
name: {{ $.Values.configSecret.name }}

hack/charts/cluster-api-operator/templates/infra-conditions.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ metadata:
5353
"argocd.argoproj.io/sync-wave": "2"
5454
{{- with .Values.configSecret }}
5555
spec:
56+
{{- if $.Values.manager }}
57+
manager:
58+
{{- if and $.Values.manager.featureGates $.Values.manager.featureGates.kubeadm }}
59+
featureGates:
60+
{{- range $key, $value := $.Values.manager.featureGates.kubeadm }}
61+
{{ $key }}: {{ $value }}
62+
{{- end }}
63+
{{- end }}
64+
{{- end }}
5665
configSecret:
5766
name: {{ .name }}
5867
{{- if .namespace }}

test/e2e/helm_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,20 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
261261
Expect(err).ToNot(HaveOccurred())
262262
Expect(manifests).To(MatchYAML(string(expectedManifests)))
263263
})
264+
It("should deploy kubeadm control plane with manager specified", func() {
265+
manifests, err := helmChart.Run(map[string]string{
266+
"core": "cluster-api",
267+
"controlPlane": "kubeadm",
268+
"bootstrap": "kubeadm",
269+
"infrastructure": "docker",
270+
"addon": "helm",
271+
"manager.featureGates.kubeadm.ClusterTopology": "true",
272+
"manager.featureGates.kubeadm.MachinePool": "true",
273+
})
274+
Expect(err).ToNot(HaveOccurred())
275+
Expect(manifests).ToNot(BeEmpty())
276+
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "kubeadm-manager-defined.yaml"))
277+
Expect(err).ToNot(HaveOccurred())
278+
Expect(manifests).To(MatchYAML(string(expectedManifests)))
279+
})
264280
})
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
# Source: cluster-api-operator/templates/addon.yaml
3+
apiVersion: v1
4+
kind: Namespace
5+
metadata:
6+
annotations:
7+
"helm.sh/hook": "post-install,post-upgrade"
8+
"helm.sh/hook-weight": "1"
9+
"argocd.argoproj.io/sync-wave": "1"
10+
name: helm-addon-system
11+
---
12+
# Source: cluster-api-operator/templates/bootstrap.yaml
13+
apiVersion: v1
14+
kind: Namespace
15+
metadata:
16+
annotations:
17+
"helm.sh/hook": "post-install,post-upgrade"
18+
"helm.sh/hook-weight": "1"
19+
name: kubeadm-bootstrap-system
20+
---
21+
# Source: cluster-api-operator/templates/control-plane.yaml
22+
apiVersion: v1
23+
kind: Namespace
24+
metadata:
25+
annotations:
26+
"helm.sh/hook": "post-install,post-upgrade"
27+
"helm.sh/hook-weight": "1"
28+
name: kubeadm-control-plane-system
29+
---
30+
# Source: cluster-api-operator/templates/core.yaml
31+
apiVersion: v1
32+
kind: Namespace
33+
metadata:
34+
annotations:
35+
"helm.sh/hook": "post-install,post-upgrade"
36+
"helm.sh/hook-weight": "1"
37+
name: capi-system
38+
---
39+
# Source: cluster-api-operator/templates/infra.yaml
40+
apiVersion: v1
41+
kind: Namespace
42+
metadata:
43+
annotations:
44+
"helm.sh/hook": "post-install,post-upgrade"
45+
"helm.sh/hook-weight": "1"
46+
"argocd.argoproj.io/sync-wave": "1"
47+
name: docker-infrastructure-system
48+
---
49+
# Source: cluster-api-operator/templates/addon.yaml
50+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
51+
kind: AddonProvider
52+
metadata:
53+
name: helm
54+
namespace: helm-addon-system
55+
annotations:
56+
"helm.sh/hook": "post-install,post-upgrade"
57+
"helm.sh/hook-weight": "2"
58+
"argocd.argoproj.io/sync-wave": "2"
59+
---
60+
# Source: cluster-api-operator/templates/bootstrap.yaml
61+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
62+
kind: BootstrapProvider
63+
metadata:
64+
name: kubeadm
65+
namespace: kubeadm-bootstrap-system
66+
annotations:
67+
"helm.sh/hook": "post-install,post-upgrade"
68+
"helm.sh/hook-weight": "2"
69+
---
70+
# Source: cluster-api-operator/templates/control-plane.yaml
71+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
72+
kind: ControlPlaneProvider
73+
metadata:
74+
name: kubeadm
75+
namespace: kubeadm-control-plane-system
76+
annotations:
77+
"helm.sh/hook": "post-install,post-upgrade"
78+
"helm.sh/hook-weight": "2"
79+
spec:
80+
manager:
81+
featureGates:
82+
ClusterTopology: true
83+
MachinePool: true
84+
---
85+
# Source: cluster-api-operator/templates/core.yaml
86+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
87+
kind: CoreProvider
88+
metadata:
89+
name: cluster-api
90+
namespace: capi-system
91+
annotations:
92+
"helm.sh/hook": "post-install,post-upgrade"
93+
"helm.sh/hook-weight": "2"
94+
"argocd.argoproj.io/sync-wave": "2"
95+
manager:
96+
---
97+
# Source: cluster-api-operator/templates/infra.yaml
98+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
99+
kind: InfrastructureProvider
100+
metadata:
101+
name: docker
102+
namespace: docker-infrastructure-system
103+
annotations:
104+
"helm.sh/hook": "post-install,post-upgrade"
105+
"helm.sh/hook-weight": "2"
106+
"argocd.argoproj.io/sync-wave": "2"
107+
spec:
108+
manager:

0 commit comments

Comments
 (0)