datahaven/deploy/charts/node/templates/customNodeKeySecret.yaml

23 lines
1.1 KiB
YAML
Raw Permalink Normal View History

{{ $fullname := include "node.fullname" . }}
{{ if .Values.node.persistGeneratedNodeKey }}
{{ else if .Values.node.customNodeKey }}
apiVersion: v1
kind: Secret
metadata:
name: {{ $fullname }}-custom-node-key
data:
{{- if kindIs "string" .Values.node.customNodeKey }}
custom-node-key: {{ .Values.node.customNodeKey | mustRegexFind "^[0-9a-zA-Z]{64}$" | b64enc }}
{{- else if kindIs "slice" .Values.node.customNodeKey }}
{{- range $index, $key := .Values.node.customNodeKey }}
custom-node-key-{{ $index }}: {{ $key | mustRegexFind "^[0-9a-zA-Z]{64}$" | b64enc }}
{{- end }}
{{- else if kindIs "map" .Values.node.customNodeKey }}
{{- range $index := until (max .Values.autoscaling.maxReplicas .Values.node.replicas | int) }}
custom-node-key-{{ $index }}: {{ printf "%s/%s/%d" $.Values.node.customNodeKey.seed (default $fullname $.Values.node.customNodeKey.extraDerivation) $index | sha256sum | mustRegexFind "^[0-9a-zA-Z]{64}$" | b64enc }}
{{- end }}
{{- else }}
{{- fail (printf "ERROR: '.Values.node.customNodeKey' is invalid. Expected type 'string', 'slice', or 'map', but got: '%s'" (kindOf .Values.node.customNodeKey)) }}
{{- end }}
{{ end }}