Add support for custom addons

This commit is contained in:
Matt Pryor 2022-10-21 10:35:23 +01:00
parent 2f906a37e9
commit e0f278d594
2 changed files with 103 additions and 0 deletions

View File

@ -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 }}

View File

@ -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"