Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚠️ ✨ Make helm chart values extensible per component #638

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions hack/charts/cluster-api-operator/templates/addon.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
# Addon provider
{{- if .Values.addon }}
{{- $addons := split ";" .Values.addon }}
{{- $addonNamespace := "" }}
{{- $addonName := "" }}
{{- $addonVersion := "" }}
{{- range $addon := $addons }}
{{- $addonArgs := split ":" $addon }}
{{- $addonArgsLen := len $addonArgs }}
{{- if eq $addonArgsLen 3 }}
{{- $addonNamespace = $addonArgs._0 }}
{{- $addonName = $addonArgs._1 }}
{{- $addonVersion = $addonArgs._2 }}
{{- else if eq $addonArgsLen 2 }}
{{- $addonNamespace = print $addonArgs._0 "-addon-system" }}
{{- $addonName = $addonArgs._0 }}
{{- $addonVersion = $addonArgs._1 }}
{{- else if eq $addonArgsLen 1 }}
{{- $addonNamespace = print $addonArgs._0 "-addon-system" }}
{{- $addonName = $addonArgs._0 }}
{{- else }}
{{- fail "addon provider argument should have the following format helm:v1.0.0 or mynamespace:helm:v1.0.0" }}
{{- end }}
{{- range $addon := .Values.addon }}
{{- $addonNamespace := default ( printf "%s-%s" $addon.name "addon-system" ) $addon.namespace }}
{{- $addonName := $addon.name }}
{{- $addonVersion := $addon.version }}
---
apiVersion: v1
kind: Namespace
Expand Down Expand Up @@ -52,5 +35,25 @@ spec:
{{- if $.Values.secretNamespace }}
secretNamespace: {{ $.Values.secretNamespace }}
{{- end }}
{{- if $addon.manifestPatches }}
manifestPatches: {{ toYaml $addon.manifestPatches | nindent 4 }}
{{- end }}
{{- if $addon.additionalManifests }}
additionalManifests:
name: {{ $addon.additionalManifests.name }}
{{- if $addon.additionalManifests.namespace }}
namespace: {{ $addon.additionalManifests.namespace }}
{{- end }} {{/* if $addon.additionalManifests.namespace */}}
{{- end }}
{{- if $addon.additionalManifests }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $addon.additionalManifests.name }}
namespace: {{ default $addonNamespace $addon.additionalManifests.namespace }}
data:
manifests: {{- toYaml $addon.additionalManifests.manifests | nindent 4 }}
{{- end }}
{{- end }} {{/* range $addon := .Values.addon */}}
{{- end }} {{/* if .Values.addon */}}
45 changes: 24 additions & 21 deletions hack/charts/cluster-api-operator/templates/bootstrap.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
# Bootstrap provider
{{- if .Values.bootstrap }}
{{- $bootstraps := split ";" .Values.bootstrap }}
{{- $bootstrapNamespace := "" }}
{{- $bootstrapName := "" }}
{{- $bootstrapVersion := "" }}
{{- range $bootstrap := $bootstraps }}
{{- $bootstrapArgs := split ":" $bootstrap }}
{{- $bootstrapArgsLen := len $bootstrapArgs }}
{{- if eq $bootstrapArgsLen 3 }}
{{- $bootstrapNamespace = $bootstrapArgs._0 }}
{{- $bootstrapName = $bootstrapArgs._1 }}
{{- $bootstrapVersion = $bootstrapArgs._2 }}
{{- else if eq $bootstrapArgsLen 2 }}
{{- $bootstrapNamespace = print $bootstrapArgs._0 "-bootstrap-system" }}
{{- $bootstrapName = $bootstrapArgs._0 }}
{{- $bootstrapVersion = $bootstrapArgs._1 }}
{{- else if eq $bootstrapArgsLen 1 }}
{{- $bootstrapNamespace = print $bootstrapArgs._0 "-bootstrap-system" }}
{{- $bootstrapName = $bootstrapArgs._0 }}
{{- else }}
{{- fail "bootstrap provider argument should have the following format kubeadm:v1.0.0 or mynamespace:kubeadm:v1.0.0" }}
{{- end }}
{{- range $bootstrap := .Values.bootstrap }}
{{- $bootstrapNamespace := default ( printf "%s-%s" $bootstrap.name "bootstrap-system" ) $bootstrap.namespace }}
{{- $bootstrapName := $bootstrap.name }}
{{- $bootstrapVersion := $bootstrap.version }}
---
apiVersion: v1
kind: Namespace
Expand Down Expand Up @@ -51,5 +34,25 @@ spec:
namespace: {{ $.Values.configSecret.namespace }}
{{- end }}
{{- end }}
{{- if $bootstrap.manifestPatches }}
manifestPatches: {{ toYaml $bootstrap.manifestPatches | nindent 4 }}
{{- end }}
{{- if $bootstrap.additionalManifests }}
additionalManifests:
name: {{ $bootstrap.additionalManifests.name }}
{{- if $bootstrap.additionalManifests.namespace }}
namespace: {{ $bootstrap.additionalManifests.namespace }}
{{- end }} {{/* if $bootstrap.additionalManifests.namespace */}}
{{- end }}
{{- if $bootstrap.additionalManifests }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $bootstrap.additionalManifests.name }}
namespace: {{ default $bootstrapNamespace $bootstrap.additionalManifests.namespace }}
data:
manifests: {{- toYaml $bootstrap.additionalManifests.manifests | nindent 4 }}
{{- end }}
{{- end }} {{/* range $bootstrap := .Values.bootstrap */}}
{{- end }} {{/* if .Values.bootstrap */}}
45 changes: 24 additions & 21 deletions hack/charts/cluster-api-operator/templates/control-plane.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
# Control plane provider
{{- if .Values.controlPlane }}
{{- $controlPlanes := split ";" .Values.controlPlane }}
{{- $controlPlaneNamespace := "" }}
{{- $controlPlaneName := "" }}
{{- $controlPlaneVersion := "" }}
{{- range $controlPlane := $controlPlanes }}
{{- $controlPlaneArgs := split ":" $controlPlane }}
{{- $controlPlaneArgsLen := len $controlPlaneArgs }}
{{- if eq $controlPlaneArgsLen 3 }}
{{- $controlPlaneNamespace = $controlPlaneArgs._0 }}
{{- $controlPlaneName = $controlPlaneArgs._1 }}
{{- $controlPlaneVersion = $controlPlaneArgs._2 }}
{{- else if eq $controlPlaneArgsLen 2 }}
{{- $controlPlaneNamespace = print $controlPlaneArgs._0 "-control-plane-system" }}
{{- $controlPlaneName = $controlPlaneArgs._0 }}
{{- $controlPlaneVersion = $controlPlaneArgs._1 }}
{{- else if eq $controlPlaneArgsLen 1 }}
{{- $controlPlaneNamespace = print $controlPlaneArgs._0 "-control-plane-system" }}
{{- $controlPlaneName = $controlPlaneArgs._0 }}
{{- else }}
{{- fail "controlplane provider argument should have the following format kubeadm:v1.0.0 or mynamespace:kubeadm:v1.0.0" }}
{{- end }}
{{- range $controlPlane := .Values.controlPlane }}
{{- $controlPlaneNamespace := default ( printf "%s-%s" $controlPlane.name "control-plane-system" ) $controlPlane.namespace }}
{{- $controlPlaneName := $controlPlane.name }}
{{- $controlPlaneVersion := $controlPlane.version }}
---
apiVersion: v1
kind: Namespace
Expand Down Expand Up @@ -51,5 +34,25 @@ spec:
namespace: {{ $.Values.configSecret.namespace }}
{{- end }}
{{- end }}
{{- if $controlPlane.manifestPatches }}
manifestPatches: {{ toYaml $controlPlane.manifestPatches | nindent 4 }}
{{- end }}
{{- if $controlPlane.additionalManifests }}
additionalManifests:
name: {{ $controlPlane.additionalManifests.name }}
{{- if $controlPlane.additionalManifests.namespace }}
namespace: {{ $controlPlane.additionalManifests.namespace }}
{{- end }} {{/* if $controlPlane.additionalManifests.namespace */}}
{{- end }}
{{- if $controlPlane.additionalManifests }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $controlPlane.additionalManifests.name }}
namespace: {{ default $controlPlaneNamespace $controlPlane.additionalManifests.namespace }}
data:
manifests: {{- toYaml $controlPlane.additionalManifests.manifests | nindent 4 }}
{{- end }}
{{- end }} {{/* range $controlPlane := .Values.controlPlane */}}
{{- end }} {{/* if .Values.controlPlane */}}
43 changes: 23 additions & 20 deletions hack/charts/cluster-api-operator/templates/core.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
# Core provider
{{- if .Values.core }}
{{- $coreArgs := split ":" .Values.core }}
{{- $coreArgsLen := len $coreArgs }}
{{- $coreVersion := "" }}
{{- $coreNamespace := "" }}
{{- $coreName := "" }}
{{- $coreVersion := "" }}
{{- if eq $coreArgsLen 3 }}
{{- $coreNamespace = $coreArgs._0 }}
{{- $coreName = $coreArgs._1 }}
{{- $coreVersion = $coreArgs._2 }}
{{- else if eq $coreArgsLen 2 }}
{{- $coreNamespace = "capi-system" }}
{{- $coreName = $coreArgs._0 }}
{{- $coreVersion = $coreArgs._1 }}
{{- else if eq $coreArgsLen 1 }}
{{- $coreNamespace = "capi-system" }}
{{- $coreName = $coreArgs._0 }}
{{- else }}
{{- fail "core provider argument should have the following format cluster-api:v1.0.0 or mynamespace:cluster-api:v1.0.0" }}
{{- end }}
{{- $coreNamespace := default ( printf "%s-%s" .Values.core.name "capi-system" ) .Values.core.namespace }}
{{- $coreName := .Values.core.name }}
{{- $coreVersion := .Values.core.version }}
---
apiVersion: v1
kind: Namespace
Expand Down Expand Up @@ -60,4 +43,24 @@ spec:
namespace: {{ $.Values.configSecret.namespace }}
{{- end }}
{{- end }}
{{- if .Values.core.manifestPatches }}
manifestPatches: {{ toYaml .Values.core.manifestPatches | nindent 4 }}
{{- end }}
{{- if .Values.core.additionalManifests }}
additionalManifests:
name: {{ .Values.core.additionalManifests.name }}
{{- if .Values.core.additionalManifests.namespace }}
namespace: {{ .Values.core.additionalManifests.namespace }}
{{- end }} {{/* if .Values.core.additionalManifests.namespace */}}
{{- end }}
{{- if .Values.core.additionalManifests }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.core.additionalManifests.name }}
namespace: {{ default .Values.coreNamespace .Values.core.additionalManifests.namespace }}
data:
manifests: {{- toYaml .Values.core.additionalManifests.manifests | nindent 4 }}
{{- end }}
{{- end }} {{/* if .Values.core */}}
47 changes: 25 additions & 22 deletions hack/charts/cluster-api-operator/templates/infra.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
# Infrastructure providers
{{- if .Values.infrastructure }}
{{- $infrastructures := split ";" .Values.infrastructure }}
{{- $infrastructureNamespace := "" }}
{{- $infrastructureName := "" }}
{{- $infrastructureVersion := "" }}
{{- range $infrastructure := $infrastructures }}
{{- $infrastructureArgs := split ":" $infrastructure }}
{{- $infrastructureArgsLen := len $infrastructureArgs }}
{{- if eq $infrastructureArgsLen 3 }}
{{- $infrastructureNamespace = $infrastructureArgs._0 }}
{{- $infrastructureName = $infrastructureArgs._1 }}
{{- $infrastructureVersion = $infrastructureArgs._2 }}
{{- else if eq $infrastructureArgsLen 2 }}
{{- $infrastructureNamespace = print $infrastructureArgs._0 "-infrastructure-system" }}
{{- $infrastructureName = $infrastructureArgs._0 }}
{{- $infrastructureVersion = $infrastructureArgs._1 }}
{{- else if eq $infrastructureArgsLen 1 }}
{{- $infrastructureNamespace = print $infrastructureArgs._0 "-infrastructure-system" }}
{{- $infrastructureName = $infrastructureArgs._0 }}
{{- else }}
{{- fail "infrastructure provider argument should have the following format aws:v1.0.0 or mynamespace:aws:v1.0.0" }}
{{- end }}
{{- range $infra := .Values.infrastructure }}
{{- $infrastructureNamespace := default ( printf "%s-%s" $infra.name "infrastructure-system" ) $infra.namespace }}
{{- $infrastructureName := $infra.name }}
{{- $infrastructureVersion := $infra.version }}
---
apiVersion: v1
kind: Namespace
Expand Down Expand Up @@ -69,5 +52,25 @@ spec:
{{- if $.Values.additionalDeployments }}
additionalDeployments: {{ toYaml $.Values.additionalDeployments | nindent 4 }}
{{- end }}
{{- if $infra.manifestPatches }}
manifestPatches: {{- toYaml $infra.manifestPatches | nindent 4 }}
{{- end }} {{/* if $infra.manifestPatches */}}
{{- if $infra.additionalManifests }}
additionalManifests:
name: {{ $infra.additionalManifests.name }}
{{- if $infra.additionalManifests.namespace }}
namespace: {{ $infra.additionalManifests.namespace }}
{{- end }} {{/* if $infra.additionalManifests.namespace */}}
{{- end }} {{/* if $infra.additionalManifests */}}
{{- if $infra.additionalManifests }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $infra.additionalManifests.name }}
namespace: {{ default $infrastructureNamespace $infra.additionalManifests.namespace }}
data:
manifests: {{- toYaml $infra.additionalManifests.manifests | nindent 4 }}
{{- end }}
{{- end }}
{{- end }} {{/* range $infra := .Values.infrastructure */}}
{{- end }} {{/* if .Values.infrastructure */}}
25 changes: 20 additions & 5 deletions hack/charts/cluster-api-operator/values.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
---
# ---
# Cluster API provider options
core: ""
bootstrap: ""
controlPlane: ""
infrastructure: ""
addon: ""
core:
name: ""
# namespace: "" # Optional
# version: "" # Optional
bootstrap:
- name: ""
# namespace: "" # Optional
# version: "" # Optional
controlPlane:
- name: ""
# namespace: "" # Optional
# version: "" # Optional
infrastructure:
- name: ""
# namespace: "" # Optional
# version: "" # Optional
addon:
- name: ""
# namespace: "" # Optional
# version: "" # Optional
manager.featureGates: {}
# ---
# Common configuration secret options
Expand Down
Loading