Skip to content

Commit a3e346e

Browse files
Add addon provider to helm chart
1 parent c03f518 commit a3e346e

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{- if .Values.addon }}
2+
# Deploy core components if not specified
3+
{{- if not .Values.core }}
4+
---
5+
apiVersion: v1
6+
kind: Namespace
7+
metadata:
8+
annotations:
9+
"helm.sh/hook": "post-install"
10+
"helm.sh/hook-weight": "1"
11+
name: capi-system
12+
---
13+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
14+
kind: CoreProvider
15+
metadata:
16+
name: cluster-api
17+
namespace: capi-system
18+
annotations:
19+
"helm.sh/hook": "post-install"
20+
"helm.sh/hook-weight": "2"
21+
{{- if .Values.secretName }}
22+
spec:
23+
secretName: {{ .Values.secretName }}
24+
{{- if .Values.secretNamespace }}
25+
secretNamespace: {{ .Values.secretNamespace }}
26+
{{- end }}
27+
{{- end }}
28+
{{- end }}
29+
{{- end }}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# 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 }}
24+
---
25+
apiVersion: v1
26+
kind: Namespace
27+
metadata:
28+
annotations:
29+
"helm.sh/hook": "post-install"
30+
"helm.sh/hook-weight": "1"
31+
name: {{ $addonNamespace }}
32+
---
33+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
34+
kind: AddonProvider
35+
metadata:
36+
name: {{ $addonName }}
37+
namespace: {{ $addonNamespace }}
38+
annotations:
39+
"helm.sh/hook": "post-install"
40+
"helm.sh/hook-weight": "2"
41+
{{- if or $addonVersion $.Values.secretName }}
42+
spec:
43+
{{- end}}
44+
{{- if $addonVersion }}
45+
version: {{ $addonVersion }}
46+
{{- end }}
47+
{{- if $.Values.secretName }}
48+
secretName: {{ $.Values.secretName }}
49+
{{- end }}
50+
{{- if $.Values.secretNamespace }}
51+
secretNamespace: {{ $.Values.secretNamespace }}
52+
{{- end }}
53+
{{- end }}
54+
{{- end }}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ core: ""
1111
bootstrap: ""
1212
controlPlane: ""
1313
infrastructure: ""
14+
addon: ""
1415
# ---
1516
# Common configuration secret options
1617
configSecret: {}

0 commit comments

Comments
 (0)