Skip to content

Commit 201ba3f

Browse files
authored
Merge pull request #984 from andreipantelimonuip/helm-chart-deployment-spec
✨ Helm: Expose deployment spec for all provider types
2 parents 74509c6 + 7bcf2b8 commit 201ba3f

File tree

9 files changed

+285
-6
lines changed

9 files changed

+285
-6
lines changed

hack/charts/cluster-api-operator/templates/addon.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ metadata:
2828
"helm.sh/hook-weight": "2"
2929
{{- end }}
3030
"argocd.argoproj.io/sync-wave": "2"
31-
{{- if or $addonVersion $.Values.secretName $.Values.configSecret.name $addon.manager (($addon).configSecret).name }}
31+
{{- if or $addonVersion $.Values.secretName $.Values.configSecret.name $addon.manager $addon.deployment (($addon).configSecret).name }}
3232
spec:
3333
{{- end}}
34+
{{- if $addon.deployment }}
35+
deployment: {{ toYaml $addon.deployment | nindent 4 }}
36+
{{- end }}
3437
{{- if $addon.manager }}
3538
manager:
3639
{{- if $addon.manager.metrics }}

hack/charts/cluster-api-operator/templates/bootstrap.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ metadata:
2828
"helm.sh/hook-weight": "2"
2929
{{- end }}
3030
"argocd.argoproj.io/sync-wave": "2"
31-
{{- if or $bootstrapVersion $.Values.configSecret.name $bootstrap.manager (($bootstrap).configSecret).name }}
31+
{{- if or $bootstrapVersion $.Values.configSecret.name $bootstrap.manager $bootstrap.deployment (($bootstrap).configSecret).name }}
3232
spec:
3333
{{- end}}
34+
{{- if $bootstrap.deployment }}
35+
deployment: {{ toYaml $bootstrap.deployment | nindent 4 }}
36+
{{- end }}
3437
{{- if $bootstrap.manager }}
3538
manager:
3639
{{- if $bootstrap.manager.featureGates }}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ metadata:
2828
"helm.sh/hook-weight": "2"
2929
{{- end }}
3030
"argocd.argoproj.io/sync-wave": "2"
31-
{{- if or $controlPlaneVersion $.Values.configSecret.name $controlPlane.manager (($controlPlane).configSecret).name }}
31+
{{- if or $controlPlaneVersion $.Values.configSecret.name $controlPlane.manager $controlPlane.deployment (($controlPlane).configSecret).name }}
3232
spec:
3333
{{- end}}
3434
{{- if $controlPlaneVersion }}
3535
version: {{ $controlPlaneVersion }}
3636
{{- end }}
37+
{{- if $controlPlane.deployment }}
38+
deployment: {{ toYaml $controlPlane.deployment | nindent 4 }}
39+
{{- end }}
3740
{{- if $controlPlane.manager }}
3841
manager:
3942
{{- if $controlPlane.manager.featureGates }}

hack/charts/cluster-api-operator/templates/core.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ metadata:
2828
"helm.sh/hook-weight": "2"
2929
{{- end }}
3030
"argocd.argoproj.io/sync-wave": "2"
31-
{{- if or $coreVersion $.Values.configSecret.name $core.manager (($core).configSecret).name }}
31+
{{- if or $coreVersion $.Values.configSecret.name $core.manager $core.deployment (($core).configSecret).name }}
3232
spec:
3333
{{- end}}
3434
{{- if $coreVersion }}
3535
version: {{ $coreVersion }}
3636
{{- end }}
37+
{{- if $core.deployment }}
38+
deployment: {{ toYaml $core.deployment | nindent 4 }}
39+
{{- end }}
3740
{{- if $core.manager }}
3841
manager:
3942
{{- if $core.manager.featureGates }}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ metadata:
2828
"helm.sh/hook-weight": "2"
2929
{{- end }}
3030
"argocd.argoproj.io/sync-wave": "2"
31-
{{- if or $infrastructureVersion $.Values.configSecret.name $infra.manager $.Values.additionalDeployments (($infra).configSecret).name }}
31+
{{- if or $infrastructureVersion $.Values.configSecret.name $infra.manager $infra.deployment $.Values.additionalDeployments (($infra).configSecret).name }}
3232
spec:
3333
{{- end }}
3434
{{- if $infrastructureVersion }}
3535
version: {{ $infrastructureVersion }}
3636
{{- end }}
37+
{{- if $infra.deployment }}
38+
deployment: {{ toYaml $infra.deployment | nindent 4 }}
39+
{{- end }}
3740
{{- if $infra.manager }}
3841
manager:
3942
{{- if $infra.manager.featureGates }}

hack/charts/cluster-api-operator/templates/ipam.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ metadata:
2828
"helm.sh/hook-weight": "2"
2929
{{- end }}
3030
"argocd.argoproj.io/sync-wave": "2"
31-
{{- if or $ipamVersion $.Values.configSecret.name $ipam.manager $.Values.additionalDeployments (($ipam).configSecret).name }}
31+
{{- if or $ipamVersion $.Values.configSecret.name $ipam.manager $ipam.deployment $.Values.additionalDeployments (($ipam).configSecret).name }}
3232
spec:
3333
{{- end }}
3434
{{- if $ipamVersion }}
3535
version: {{ $ipamVersion }}
3636
{{- end }}
37+
{{- if $ipam.deployment }}
38+
deployment: {{ toYaml $ipam.deployment | nindent 4 }}
39+
{{- end }}
3740
{{- if $ipam.manager }}
3841
manager:
3942
{{- if $ipam.manager.featureGates }}

hack/charts/cluster-api-operator/values.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ core: {}
66
# namespace: "" # Optional
77
# version: "" # Optional
88
# createNamespace: true # Optional
9+
# deployment: # Optional
10+
# replicas: 1
11+
# nodeSelector: {}
12+
# tolerations: []
13+
# affinity: {}
14+
# containers: []
15+
# serviceAccountName: ""
16+
# imagePullSecrets: []
917
# manager: # Optional
1018
# featureGates:
1119
# ClusterTopology: true
@@ -17,6 +25,14 @@ bootstrap: {}
1725
# namespace: "" # Optional
1826
# version: "" # Optional
1927
# createNamespace: true # Optional
28+
# deployment: # Optional
29+
# replicas: 1
30+
# nodeSelector: {}
31+
# tolerations: []
32+
# affinity: {}
33+
# containers: []
34+
# serviceAccountName: ""
35+
# imagePullSecrets: []
2036
# manager: # Optional
2137
# featureGates:
2238
# ClusterTopology: true
@@ -29,6 +45,14 @@ controlPlane: {}
2945
# namespace: "" # Optional
3046
# version: "" # Optional
3147
# createNamespace: true # Optional
48+
# deployment: # Optional
49+
# replicas: 1
50+
# nodeSelector: {}
51+
# tolerations: []
52+
# affinity: {}
53+
# containers: []
54+
# serviceAccountName: ""
55+
# imagePullSecrets: []
3256
# manager: # Optional
3357
# featureGates:
3458
# ClusterTopology: true
@@ -40,6 +64,14 @@ infrastructure: {}
4064
# namespace: "" # Optional
4165
# version: "" # Optional
4266
# createNamespace: true # Optional
67+
# deployment: # Optional
68+
# replicas: 1
69+
# nodeSelector: {}
70+
# tolerations: []
71+
# affinity: {}
72+
# containers: []
73+
# serviceAccountName: ""
74+
# imagePullSecrets: []
4375
# manager: # Optional
4476
# featureGates:
4577
# ClusterTopology: true
@@ -51,6 +83,14 @@ addon: {}
5183
# namespace: "" # Optional
5284
# version: "" # Optional
5385
# createNamespace: true # Optional
86+
# deployment: # Optional
87+
# replicas: 1
88+
# nodeSelector: {}
89+
# tolerations: []
90+
# affinity: {}
91+
# containers: []
92+
# serviceAccountName: ""
93+
# imagePullSecrets: []
5494
# manager: # Optional
5595
# metrics:
5696
# insecureDiagnostics: true
@@ -60,6 +100,14 @@ ipam: {}
60100
# namespace: "" # Optional
61101
# version: "" # Optional
62102
# createNamespace: true # Optional
103+
# deployment: # Optional
104+
# replicas: 1
105+
# nodeSelector: {}
106+
# tolerations: []
107+
# affinity: {}
108+
# containers: []
109+
# serviceAccountName: ""
110+
# imagePullSecrets: []
63111
# manager: # Optional
64112
# featureGates:
65113
# ClusterTopology: true

test/e2e/helm_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,39 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
422422
Expect(err).ToNot(HaveOccurred())
423423
Expect(manifests).To(Equal(string(expectedManifests)))
424424
})
425+
It("should deploy all providers with deployment spec", func() {
426+
manifests, err := helmChart.Run(map[string]string{
427+
"configSecret.name": "test-secret-name",
428+
"configSecret.namespace": "test-secret-namespace",
429+
"core.cluster-api.version": "v1.7.7",
430+
"core.cluster-api.deployment.replicas": "2",
431+
"core.cluster-api.deployment.nodeSelector.tier": "control-plane",
432+
"bootstrap.kubeadm.version": "v1.7.7",
433+
"bootstrap.kubeadm.deployment.replicas": "2",
434+
"bootstrap.kubeadm.deployment.tolerations[0].key": "node-role",
435+
"bootstrap.kubeadm.deployment.tolerations[0].operator": "Exists",
436+
"bootstrap.kubeadm.deployment.tolerations[0].effect": "NoSchedule",
437+
"controlPlane.kubeadm.version": "v1.7.7",
438+
"controlPlane.kubeadm.deployment.replicas": "2",
439+
"controlPlane.kubeadm.deployment.serviceAccountName": "custom-cp-sa",
440+
"infrastructure.docker.version": "v1.7.7",
441+
"infrastructure.docker.deployment.replicas": "3",
442+
"infrastructure.docker.deployment.imagePullSecrets[0].name": "my-registry-secret",
443+
"ipam.in-cluster.version": "v1.0.0",
444+
"ipam.in-cluster.deployment.replicas": "1",
445+
"ipam.in-cluster.deployment.nodeSelector.disktype": "ssd",
446+
"addon.helm.version": "v0.2.6",
447+
"addon.helm.deployment.replicas": "1",
448+
"addon.helm.deployment.serviceAccountName": "addon-sa",
449+
})
450+
Expect(err).ToNot(HaveOccurred())
451+
Expect(manifests).ToNot(BeEmpty())
452+
453+
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "all-providers-deployment-spec.yaml"))
454+
Expect(err).ToNot(HaveOccurred())
455+
Expect(manifests).To(Equal(string(expectedManifests)))
456+
})
457+
425458
It("should deploy kubeadm control plane with manager specified", func() {
426459
manifests, err := helmChart.Run(map[string]string{
427460
"core.cluster-api.enabled": "true",

0 commit comments

Comments
 (0)