diff --git a/charts/cluster-addons/templates/custom-addons.yaml b/charts/cluster-addons/templates/custom-addons.yaml new file mode 100644 index 0000000..dcde8a9 --- /dev/null +++ b/charts/cluster-addons/templates/custom-addons.yaml @@ -0,0 +1,67 @@ +{{- range $name, $addon := .Values.custom }} +{{- if eq $addon.kind "HelmRelease" }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "cluster-addons.componentName" (list $ $name) }}-config + labels: + {{- include "cluster-addons.componentLabels" (list $ $name) | nindent 4 }} + addons.stackhpc.com/watch: "" +stringData: + # Ensure that any template syntax in the values is ignored + values: | + {%- raw %} + {{- toYaml $addon.spec.values | nindent 4 }} + {%- endraw %} +--- +apiVersion: addons.stackhpc.com/v1alpha1 +kind: HelmRelease +metadata: + name: {{ include "cluster-addons.componentName" (list $ $name) }} + labels: {{ include "cluster-addons.componentLabels" (list $ $name) | nindent 4 }} +spec: + clusterName: {{ include "cluster-addons.clusterName" $ }} + bootstrap: true + chart: {{ toYaml $addon.spec.chart | nindent 4 }} + targetNamespace: {{ $addon.spec.namespace }} + releaseName: {{ $name }} + valuesSources: + - secret: + name: {{ include "cluster-addons.componentName" (list $ $name) }}-config + key: values +{{- else if eq $addon.kind "Manifests" }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "cluster-addons.componentName" (list $ $name) }}-config + labels: + {{- include "cluster-addons.componentLabels" (list $ $name) | nindent 4 }} + addons.stackhpc.com/watch: "" +stringData: + # Ensure that any template syntax in the manifests is ignored + {{- range $key, $manifest := $addon.spec.manifests }} + {{ $key }}: | + {%- raw %} + {{- $manifest | nindent 4 }} + {%- endraw %} + {{- end }} +--- +apiVersion: addons.stackhpc.com/v1alpha1 +kind: Manifests +metadata: + name: {{ include "cluster-addons.componentName" (list $ $name) }} + labels: {{ include "cluster-addons.componentLabels" (list $ $name) | nindent 4 }} +spec: + clusterName: {{ include "cluster-addons.clusterName" $ }} + bootstrap: true + targetNamespace: {{ $addon.spec.namespace }} + releaseName: {{ $name }} + manifestSources: + - secret: + name: {{ include "cluster-addons.componentName" (list $ $name) }}-config +{{- else }} +{{- printf "Unrecognised addon kind - %s" $addon.kind | fail }} +{{- end }} +{{- end }} diff --git a/charts/cluster-addons/values.yaml b/charts/cluster-addons/values.yaml index 11f2d20..523b43e 100644 --- a/charts/cluster-addons/values.yaml +++ b/charts/cluster-addons/values.yaml @@ -212,3 +212,39 @@ mellanoxNetworkOperator: release: namespace: network-operator values: {} + +# Settings for any custom addons +custom: {} + # # Indexed by the name of the release on the target cluster + # my-custom-helm-release: + # # Indicates that this is a Helm addon + # kind: HelmRelease + # spec: + # # The namespace that the addon should be in + # namespace: my-namespace + # # Details of the Helm chart to use + # chart: + # # The chart repository that contains the chart to use + # repo: https://my-project/charts + # # The name of the chart to use + # name: my-chart + # # The version of the chart to use (must be an exact version) + # version: 1.5.0 + # # The Helm values to use for the release + # values: {} + # # Indexed by the name of the release on the target cluster + # my-custom-manifests: + # # Indicates that this is a Manifests addon + # kind: Manifests + # spec: + # # The namespace that the addon should be in + # namespace: my-namespace + # # The manifests for the addon, indexed by filename + # manifests: + # secret.yaml: |- + # apiVersion: v1 + # kind: Secret + # metadata: + # name: my-secret + # stringData: + # secret-file: "secret-data"