Skip to content

Commit 215e425

Browse files
authored
Merge pull request #638 from rbjorklin/revamp-chart
⚠️ Make helm chart values extensible per component
2 parents 5c91920 + 02019c7 commit 215e425

File tree

10 files changed

+315
-226
lines changed

10 files changed

+315
-226
lines changed

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

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
11
# Addon provider
2-
{{- if .Values.addon }}
3-
{{- $addons := split ";" .Values.addon }}
4-
{{- $addonNamespace := "" }}
5-
{{- $addonName := "" }}
6-
{{- $addonVersion := "" }}
7-
{{- range $addon := $addons }}
8-
{{- $addonArgs := split ":" $addon }}
9-
{{- $addonArgsLen := len $addonArgs }}
10-
{{- if eq $addonArgsLen 3 }}
11-
{{- $addonNamespace = $addonArgs._0 }}
12-
{{- $addonName = $addonArgs._1 }}
13-
{{- $addonVersion = $addonArgs._2 }}
14-
{{- else if eq $addonArgsLen 2 }}
15-
{{- $addonNamespace = print $addonArgs._0 "-addon-system" }}
16-
{{- $addonName = $addonArgs._0 }}
17-
{{- $addonVersion = $addonArgs._1 }}
18-
{{- else if eq $addonArgsLen 1 }}
19-
{{- $addonNamespace = print $addonArgs._0 "-addon-system" }}
20-
{{- $addonName = $addonArgs._0 }}
21-
{{- else }}
22-
{{- fail "addon provider argument should have the following format helm:v1.0.0 or mynamespace:helm:v1.0.0" }}
23-
{{- end }}
2+
{{- range $name, $addon := $.Values.addon }}
3+
{{- $addonNamespace := default ( printf "%s-%s" $name "addon-system" ) (get $addon "namespace") }}
4+
{{- $addonName := $name }}
5+
{{- $addonVersion := get $addon "version" }}
246
---
257
apiVersion: v1
268
kind: Namespace
@@ -56,5 +38,24 @@ spec:
5638
{{- if $.Values.secretNamespace }}
5739
secretNamespace: {{ $.Values.secretNamespace }}
5840
{{- end }}
41+
{{- if $addon.manifestPatches }}
42+
manifestPatches: {{ toYaml $addon.manifestPatches | nindent 4 }}
43+
{{- end }}
44+
{{- if $addon.additionalManifests }}
45+
additionalManifests:
46+
name: {{ $addon.additionalManifests.name }}
47+
{{- if $addon.additionalManifests.namespace }}
48+
namespace: {{ $addon.additionalManifests.namespace }}
49+
{{- end }} {{/* if $addon.additionalManifests.namespace */}}
5950
{{- end }}
51+
{{- if $addon.additionalManifests }}
52+
---
53+
apiVersion: v1
54+
kind: ConfigMap
55+
metadata:
56+
name: {{ $addon.additionalManifests.name }}
57+
namespace: {{ default $addonNamespace $addon.additionalManifests.namespace }}
58+
data:
59+
manifests: {{- toYaml $addon.additionalManifests.manifests | nindent 4 }}
6060
{{- end }}
61+
{{- end }} {{/* range $name, $addon := .Values.addon */}}

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

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
11
# Bootstrap provider
2-
{{- if .Values.bootstrap }}
3-
{{- $bootstraps := split ";" .Values.bootstrap }}
4-
{{- $bootstrapNamespace := "" }}
5-
{{- $bootstrapName := "" }}
6-
{{- $bootstrapVersion := "" }}
7-
{{- range $bootstrap := $bootstraps }}
8-
{{- $bootstrapArgs := split ":" $bootstrap }}
9-
{{- $bootstrapArgsLen := len $bootstrapArgs }}
10-
{{- if eq $bootstrapArgsLen 3 }}
11-
{{- $bootstrapNamespace = $bootstrapArgs._0 }}
12-
{{- $bootstrapName = $bootstrapArgs._1 }}
13-
{{- $bootstrapVersion = $bootstrapArgs._2 }}
14-
{{- else if eq $bootstrapArgsLen 2 }}
15-
{{- $bootstrapNamespace = print $bootstrapArgs._0 "-bootstrap-system" }}
16-
{{- $bootstrapName = $bootstrapArgs._0 }}
17-
{{- $bootstrapVersion = $bootstrapArgs._1 }}
18-
{{- else if eq $bootstrapArgsLen 1 }}
19-
{{- $bootstrapNamespace = print $bootstrapArgs._0 "-bootstrap-system" }}
20-
{{- $bootstrapName = $bootstrapArgs._0 }}
21-
{{- else }}
22-
{{- fail "bootstrap provider argument should have the following format kubeadm:v1.0.0 or mynamespace:kubeadm:v1.0.0" }}
23-
{{- end }}
2+
{{- range $name, $bootstrap := $.Values.bootstrap }}
3+
{{- $bootstrapNamespace := default ( printf "%s-%s" $name "bootstrap-system" ) (get $bootstrap "namespace") }}
4+
{{- $bootstrapName := $name }}
5+
{{- $bootstrapVersion := get $bootstrap "version" }}
246
---
257
apiVersion: v1
268
kind: Namespace
@@ -57,5 +39,24 @@ spec:
5739
namespace: {{ $.Values.configSecret.namespace }}
5840
{{- end }}
5941
{{- end }}
42+
{{- if $bootstrap.manifestPatches }}
43+
manifestPatches: {{ toYaml $bootstrap.manifestPatches | nindent 4 }}
44+
{{- end }}
45+
{{- if $bootstrap.additionalManifests }}
46+
additionalManifests:
47+
name: {{ $bootstrap.additionalManifests.name }}
48+
{{- if $bootstrap.additionalManifests.namespace }}
49+
namespace: {{ $bootstrap.additionalManifests.namespace }}
50+
{{- end }} {{/* if $bootstrap.additionalManifests.namespace */}}
6051
{{- end }}
52+
{{- if $bootstrap.additionalManifests }}
53+
---
54+
apiVersion: v1
55+
kind: ConfigMap
56+
metadata:
57+
name: {{ $bootstrap.additionalManifests.name }}
58+
namespace: {{ default $bootstrapNamespace $bootstrap.additionalManifests.namespace }}
59+
data:
60+
manifests: {{- toYaml $bootstrap.additionalManifests.manifests | nindent 4 }}
6161
{{- end }}
62+
{{- end }} {{/* range $name, $bootstrap := .Values.bootstrap */}}

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

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
11
# Control plane provider
2-
{{- if .Values.controlPlane }}
3-
{{- $controlPlanes := split ";" .Values.controlPlane }}
4-
{{- $controlPlaneNamespace := "" }}
5-
{{- $controlPlaneName := "" }}
6-
{{- $controlPlaneVersion := "" }}
7-
{{- range $controlPlane := $controlPlanes }}
8-
{{- $controlPlaneArgs := split ":" $controlPlane }}
9-
{{- $controlPlaneArgsLen := len $controlPlaneArgs }}
10-
{{- if eq $controlPlaneArgsLen 3 }}
11-
{{- $controlPlaneNamespace = $controlPlaneArgs._0 }}
12-
{{- $controlPlaneName = $controlPlaneArgs._1 }}
13-
{{- $controlPlaneVersion = $controlPlaneArgs._2 }}
14-
{{- else if eq $controlPlaneArgsLen 2 }}
15-
{{- $controlPlaneNamespace = print $controlPlaneArgs._0 "-control-plane-system" }}
16-
{{- $controlPlaneName = $controlPlaneArgs._0 }}
17-
{{- $controlPlaneVersion = $controlPlaneArgs._1 }}
18-
{{- else if eq $controlPlaneArgsLen 1 }}
19-
{{- $controlPlaneNamespace = print $controlPlaneArgs._0 "-control-plane-system" }}
20-
{{- $controlPlaneName = $controlPlaneArgs._0 }}
21-
{{- else }}
22-
{{- fail "controlplane provider argument should have the following format kubeadm:v1.0.0 or mynamespace:kubeadm:v1.0.0" }}
23-
{{- end }}
2+
{{- range $name, $controlPlane := $.Values.controlPlane }}
3+
{{- $controlPlaneNamespace := default ( printf "%s-%s" $name "control-plane-system" ) (get $controlPlane "namespace") }}
4+
{{- $controlPlaneName := $name }}
5+
{{- $controlPlaneVersion := get $controlPlane "version" }}
246
---
257
apiVersion: v1
268
kind: Namespace
@@ -70,5 +52,24 @@ spec:
7052
namespace: {{ $.Values.configSecret.namespace }}
7153
{{- end }}
7254
{{- end }}
55+
{{- if $controlPlane.manifestPatches }}
56+
manifestPatches: {{ toYaml $controlPlane.manifestPatches | nindent 4 }}
7357
{{- end }}
58+
{{- if $controlPlane.additionalManifests }}
59+
additionalManifests:
60+
name: {{ $controlPlane.additionalManifests.name }}
61+
{{- if $controlPlane.additionalManifests.namespace }}
62+
namespace: {{ $controlPlane.additionalManifests.namespace }}
63+
{{- end }} {{/* if $controlPlane.additionalManifests.namespace */}}
7464
{{- end }}
65+
{{- if $controlPlane.additionalManifests }}
66+
---
67+
apiVersion: v1
68+
kind: ConfigMap
69+
metadata:
70+
name: {{ $controlPlane.additionalManifests.name }}
71+
namespace: {{ default $controlPlaneNamespace $controlPlane.additionalManifests.namespace }}
72+
data:
73+
manifests: {{- toYaml $controlPlane.additionalManifests.manifests | nindent 4 }}
74+
{{- end }}
75+
{{- end }} {{/* range $name, $controlPlane := .Values.controlPlane */}}

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

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,8 @@
11
# Core provider
2-
{{- if .Values.core }}
3-
{{- $coreArgs := split ":" .Values.core }}
4-
{{- $coreArgsLen := len $coreArgs }}
5-
{{- $coreVersion := "" }}
6-
{{- $coreNamespace := "" }}
7-
{{- $coreName := "" }}
8-
{{- $coreVersion := "" }}
9-
{{- if eq $coreArgsLen 3 }}
10-
{{- $coreNamespace = $coreArgs._0 }}
11-
{{- $coreName = $coreArgs._1 }}
12-
{{- $coreVersion = $coreArgs._2 }}
13-
{{- else if eq $coreArgsLen 2 }}
14-
{{- $coreNamespace = "capi-system" }}
15-
{{- $coreName = $coreArgs._0 }}
16-
{{- $coreVersion = $coreArgs._1 }}
17-
{{- else if eq $coreArgsLen 1 }}
18-
{{- $coreNamespace = "capi-system" }}
19-
{{- $coreName = $coreArgs._0 }}
20-
{{- else }}
21-
{{- fail "core provider argument should have the following format cluster-api:v1.0.0 or mynamespace:cluster-api:v1.0.0" }}
22-
{{- end }}
2+
{{- range $name, $core := $.Values.core }}
3+
{{- $coreNamespace := default "capi-system" (get $core "namespace") }}
4+
{{- $coreName := $name }}
5+
{{- $coreVersion := get $core "version" }}
236
---
247
apiVersion: v1
258
kind: Namespace
@@ -65,4 +48,24 @@ spec:
6548
namespace: {{ $.Values.configSecret.namespace }}
6649
{{- end }}
6750
{{- end }}
51+
{{- if $core.manifestPatches }}
52+
manifestPatches: {{ toYaml $core.manifestPatches | nindent 4 }}
6853
{{- end }}
54+
{{- if $core.additionalManifests }}
55+
additionalManifests:
56+
name: {{ $core.additionalManifests.name }}
57+
{{- if $core.additionalManifests.namespace }}
58+
namespace: {{ $core.additionalManifests.namespace }}
59+
{{- end }}
60+
{{- end }}
61+
{{- if $core.additionalManifests }}
62+
---
63+
apiVersion: v1
64+
kind: ConfigMap
65+
metadata:
66+
name: {{ $core.additionalManifests.name }}
67+
namespace: {{ default $coreNamespace $core.additionalManifests.namespace }}
68+
data:
69+
manifests: {{- toYaml $core.additionalManifests.manifests | nindent 4 }}
70+
{{- end }}
71+
{{- end }} {{/* range $name, $core := .Values.core */}}

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

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
11
# Infrastructure providers
2-
{{- if .Values.infrastructure }}
3-
{{- $infrastructures := split ";" .Values.infrastructure }}
4-
{{- $infrastructureNamespace := "" }}
5-
{{- $infrastructureName := "" }}
6-
{{- $infrastructureVersion := "" }}
7-
{{- range $infrastructure := $infrastructures }}
8-
{{- $infrastructureArgs := split ":" $infrastructure }}
9-
{{- $infrastructureArgsLen := len $infrastructureArgs }}
10-
{{- if eq $infrastructureArgsLen 3 }}
11-
{{- $infrastructureNamespace = $infrastructureArgs._0 }}
12-
{{- $infrastructureName = $infrastructureArgs._1 }}
13-
{{- $infrastructureVersion = $infrastructureArgs._2 }}
14-
{{- else if eq $infrastructureArgsLen 2 }}
15-
{{- $infrastructureNamespace = print $infrastructureArgs._0 "-infrastructure-system" }}
16-
{{- $infrastructureName = $infrastructureArgs._0 }}
17-
{{- $infrastructureVersion = $infrastructureArgs._1 }}
18-
{{- else if eq $infrastructureArgsLen 1 }}
19-
{{- $infrastructureNamespace = print $infrastructureArgs._0 "-infrastructure-system" }}
20-
{{- $infrastructureName = $infrastructureArgs._0 }}
21-
{{- else }}
22-
{{- fail "infrastructure provider argument should have the following format aws:v1.0.0 or mynamespace:aws:v1.0.0" }}
23-
{{- end }}
2+
{{- range $name, $infra := $.Values.infrastructure }}
3+
{{- $infrastructureNamespace := default ( printf "%s-%s" $name "infrastructure-system" ) (get $infra "namespace") }}
4+
{{- $infrastructureName := $name }}
5+
{{- $infrastructureVersion := get $infra "version" }}
246
---
257
apiVersion: v1
268
kind: Namespace
@@ -83,5 +65,24 @@ spec:
8365
{{- if $.Values.additionalDeployments }}
8466
additionalDeployments: {{ toYaml $.Values.additionalDeployments | nindent 4 }}
8567
{{- end }}
68+
{{- if $infra.manifestPatches }}
69+
manifestPatches: {{- toYaml $infra.manifestPatches | nindent 4 }}
70+
{{- end }} {{/* if $infra.manifestPatches */}}
71+
{{- if $infra.additionalManifests }}
72+
additionalManifests:
73+
name: {{ $infra.additionalManifests.name }}
74+
{{- if $infra.additionalManifests.namespace }}
75+
namespace: {{ $infra.additionalManifests.namespace }}
76+
{{- end }} {{/* if $infra.additionalManifests.namespace */}}
77+
{{- end }} {{/* if $infra.additionalManifests */}}
78+
{{- if $infra.additionalManifests }}
79+
---
80+
apiVersion: v1
81+
kind: ConfigMap
82+
metadata:
83+
name: {{ $infra.additionalManifests.name }}
84+
namespace: {{ default $infrastructureNamespace $infra.additionalManifests.namespace }}
85+
data:
86+
manifests: {{- toYaml $infra.additionalManifests.manifests | nindent 4 }}
8687
{{- end }}
87-
{{- end }}
88+
{{- end }} {{/* range $name, $infra := .Values.infrastructure */}}

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

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
11
# IPAM providers
2-
{{- if .Values.ipam }}
3-
{{- $ipams := split ";" .Values.ipam }}
4-
{{- $ipamNamespace := "" }}
5-
{{- $ipamName := "" }}
6-
{{- $ipamVersion := "" }}
7-
{{- range $ipam := $ipams }}
8-
{{- $ipamArgs := split ":" $ipam }}
9-
{{- $ipamArgsLen := len $ipamArgs }}
10-
{{- if eq $ipamArgsLen 3 }}
11-
{{- $ipamNamespace = $ipamArgs._0 }}
12-
{{- $ipamName = $ipamArgs._1 }}
13-
{{- $ipamVersion = $ipamArgs._2 }}
14-
{{- else if eq $ipamArgsLen 2 }}
15-
{{- $ipamNamespace = print $ipamArgs._0 "-ipam-system" }}
16-
{{- $ipamName = $ipamArgs._0 }}
17-
{{- $ipamVersion = $ipamArgs._1 }}
18-
{{- else if eq $ipamArgsLen 1 }}
19-
{{- $ipamNamespace = print $ipamArgs._0 "-ipam-system" }}
20-
{{- $ipamName = $ipamArgs._0 }}
21-
{{- else }}
22-
{{- fail "ipam provider argument should have the following format in-cluster:v1.0.0 or mynamespace:in-cluster:v1.0.0" }}
23-
{{- end }}
2+
{{- range $name, $ipam := $.Values.ipam }}
3+
{{- $ipamNamespace := default ( printf "%s-%s" $name "ipam-system" ) (get $ipam "namespace") }}
4+
{{- $ipamName := $name }}
5+
{{- $ipamVersion := get $ipam "version" }}
246
---
257
apiVersion: v1
268
kind: Namespace
@@ -70,8 +52,27 @@ spec:
7052
namespace: {{ $.Values.configSecret.namespace }}
7153
{{- end }}
7254
{{- end }}
55+
{{- if $ipam.manifestPatches }}
56+
manifestPatches: {{ toYaml $ipam.manifestPatches | nindent 4 }}
57+
{{- end }}
7358
{{- if $.Values.additionalDeployments }}
7459
additionalDeployments: {{ toYaml $.Values.additionalDeployments | nindent 4 }}
7560
{{- end }}
61+
{{- if $ipam.additionalManifests }}
62+
additionalManifests:
63+
name: {{ $ipam.additionalManifests.name }}
64+
{{- if $ipam.additionalManifests.namespace }}
65+
namespace: {{ $ipam.additionalManifests.namespace }}
66+
{{- end }} {{/* if $ipam.additionalManifests.namespace */}}
7667
{{- end }}
68+
{{- if $ipam.additionalManifests }}
69+
---
70+
apiVersion: v1
71+
kind: ConfigMap
72+
metadata:
73+
name: {{ $ipam.additionalManifests.name }}
74+
namespace: {{ default $ipamNamespace $ipam.additionalManifests.namespace }}
75+
data:
76+
manifests: {{- toYaml $ipam.additionalManifests.manifests | nindent 4 }}
7777
{{- end }}
78+
{{- end }} {{/* range $name, $ipam := .Values.ipam */}}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"properties": {
5+
"core": {
6+
"oneOf": [
7+
{ "type": "object" },
8+
{ "type": "null" }
9+
]
10+
},
11+
"bootstrap": {
12+
"type": "object",
13+
"oneOf": [
14+
{ "type": "object" },
15+
{ "type": "null" }
16+
]
17+
},
18+
"controlPlane": {
19+
"type": "object",
20+
"oneOf": [
21+
{ "type": "object" },
22+
{ "type": "null" }
23+
]
24+
},
25+
"infrastructure": {
26+
"type": "object",
27+
"oneOf": [
28+
{ "type": "object" },
29+
{ "type": "null" }
30+
]
31+
},
32+
"addon": {
33+
"type": "object",
34+
"oneOf": [
35+
{ "type": "object" },
36+
{ "type": "null" }
37+
]
38+
},
39+
"ipam": {
40+
"type": "object",
41+
"oneOf": [
42+
{ "type": "object" },
43+
{ "type": "null" }
44+
]
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)