Move reusable macros to root chart (#218)
This patch adds the start of a library to help reduce code duplication. It will be split out to its own library chart at the same time the other charts are split out. --------- Signed-off-by: Kevin Fox <[email protected]>
This commit is contained in:
@@ -82,18 +82,6 @@ Create the name of the service account to use
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "spire-server.image" -}}
|
||||
{{- if eq (substr 0 7 .image.version) "sha256:" -}}
|
||||
{{- printf "%s/%s@%s" .image.registry .image.repository .image.version -}}
|
||||
{{- else if .appVersion -}}
|
||||
{{- printf "%s/%s:%s" .image.registry .image.repository (default .appVersion .image.version) -}}
|
||||
{{- else if .image.version -}}
|
||||
{{- printf "%s/%s:%s" .image.registry .image.repository .image.version -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s/%s" .image.registry .image.repository -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{- define "spire-server.upstream-ca-secret" -}}
|
||||
{{- $root := . }}
|
||||
{{- with .Values.upstreamAuthority.disk -}}
|
||||
@@ -117,34 +105,3 @@ Create the name of the service account to use
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "spire-server.cluster-name" }}
|
||||
{{- if ne (len (dig "spire" "clusterName" "" .Values.global)) 0 }}
|
||||
{{- .Values.global.spire.clusterName }}
|
||||
{{- else }}
|
||||
{{- .Values.clusterName }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "spire-server.trust-domain" }}
|
||||
{{- if ne (len (dig "spire" "trustDomain" "" .Values.global)) 0 }}
|
||||
{{- .Values.global.spire.trustDomain }}
|
||||
{{- else }}
|
||||
{{- .Values.trustDomain }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "spire-server.bundle-configmap" }}
|
||||
{{- if ne (len (dig "spire" "bundleConfigMap" "" .Values.global)) 0 }}
|
||||
{{- .Values.global.spire.bundleConfigMap }}
|
||||
{{- else }}
|
||||
{{- .Values.bundleConfigMap }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "spire-server.cluster-domain" -}}
|
||||
{{- if ne (len (dig "k8s" "clusterDomain" "" .Values.global)) 0 }}
|
||||
{{- .Values.global.k8s.clusterDomain }}
|
||||
{{- else }}
|
||||
{{- .Values.clusterDomain }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ include "spire-server.bundle-configmap" . }}
|
||||
name: {{ include "spire-lib.bundle-configmap" . }}
|
||||
namespace: {{ .Values.notifier.k8sbundle.namespace | default $namespace }}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
server:
|
||||
bind_address: "0.0.0.0"
|
||||
bind_port: "8081"
|
||||
trust_domain: {{ include "spire-server.trust-domain" . | quote }}
|
||||
trust_domain: {{ include "spire-lib.trust-domain" . | quote }}
|
||||
data_dir: "/run/spire/data"
|
||||
log_level: {{ .Values.logLevel | quote }}
|
||||
jwt_issuer: {{ .Values.jwtIssuer | quote }}
|
||||
@@ -42,7 +42,7 @@ plugins:
|
||||
- k8s_psat:
|
||||
plugin_data:
|
||||
clusters:
|
||||
{{ include "spire-server.cluster-name" $root }}:
|
||||
{{ include "spire-lib.cluster-name" $root }}:
|
||||
service_account_allow_list: {{ include "spire-server.serviceAccountAllowedList" $root | trim }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -56,7 +56,7 @@ plugins:
|
||||
- k8sbundle:
|
||||
plugin_data:
|
||||
namespace: {{ .Values.notifier.k8sbundle.namespace | default (include "spire-server.namespace" .) | quote }}
|
||||
config_map: {{ include "spire-server.bundle-configmap" . | quote }}
|
||||
config_map: {{ include "spire-lib.bundle-configmap" . | quote }}
|
||||
|
||||
{{- with .Values.upstreamAuthority.disk }}
|
||||
{{- if eq (.enabled | toString) "true" }}
|
||||
|
||||
@@ -22,8 +22,8 @@ data:
|
||||
resourceName: {{ .Release.Name | sha256sum | trunc 8 }}.spiffe.io
|
||||
resourceNamespace: {{ include "spire-server.namespace" . }}
|
||||
validatingWebhookConfigurationName: {{ include "spire-controller-manager.fullname" . }}-webhook
|
||||
clusterName: {{ include "spire-server.cluster-name" . }}
|
||||
trustDomain: {{ include "spire-server.trust-domain" . }}
|
||||
clusterName: {{ include "spire-lib.cluster-name" . }}
|
||||
trustDomain: {{ include "spire-lib.trust-domain" . }}
|
||||
ignoreNamespaces:
|
||||
{{- with .Values.controllerManager.ignoreNamespaces }}
|
||||
{{- toYaml . | nindent 6 }}
|
||||
|
||||
@@ -63,7 +63,7 @@ spec:
|
||||
- name: post-install-job
|
||||
securityContext:
|
||||
{{- toYaml .Values.securityContext | nindent 10 }}
|
||||
image: {{ template "spire-server.image" (dict "appVersion" $.Chart.AppVersion "image" .Values.controllerManager.validatingWebhookConfiguration.upgradeHook.image) }}
|
||||
image: {{ template "spire-lib.image" (dict "appVersion" $.Chart.AppVersion "image" .Values.controllerManager.validatingWebhookConfiguration.upgradeHook.image) }}
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
|
||||
@@ -63,7 +63,7 @@ spec:
|
||||
- name: post-upgrade-job
|
||||
securityContext:
|
||||
{{- toYaml .Values.securityContext | nindent 10 }}
|
||||
image: {{ template "spire-server.image" (dict "appVersion" $.Chart.AppVersion "image" .Values.controllerManager.validatingWebhookConfiguration.upgradeHook.image) }}
|
||||
image: {{ template "spire-lib.image" (dict "appVersion" $.Chart.AppVersion "image" .Values.controllerManager.validatingWebhookConfiguration.upgradeHook.image) }}
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
|
||||
@@ -63,7 +63,7 @@ spec:
|
||||
- name: post-install-job
|
||||
securityContext:
|
||||
{{- toYaml .Values.securityContext | nindent 10 }}
|
||||
image: {{ template "spire-server.image" (dict "appVersion" $.Chart.AppVersion "image" .Values.controllerManager.validatingWebhookConfiguration.upgradeHook.image) }}
|
||||
image: {{ template "spire-lib.image" (dict "appVersion" $.Chart.AppVersion "image" .Values.controllerManager.validatingWebhookConfiguration.upgradeHook.image) }}
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
|
||||
@@ -8,7 +8,7 @@ metadata:
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: [configmaps]
|
||||
resourceNames: [{{ include "spire-server.bundle-configmap" . }}]
|
||||
resourceNames: [{{ include "spire-lib.bundle-configmap" . }}]
|
||||
verbs:
|
||||
- get
|
||||
- patch
|
||||
|
||||
@@ -43,7 +43,7 @@ spec:
|
||||
- name: {{ .Chart.Name }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.securityContext | nindent 12 }}
|
||||
image: {{ template "spire-server.image" (dict "appVersion" $.Chart.AppVersion "image" .Values.image) }}
|
||||
image: {{ template "spire-lib.image" (dict "appVersion" $.Chart.AppVersion "image" .Values.image) }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
args:
|
||||
- -config
|
||||
@@ -108,7 +108,7 @@ spec:
|
||||
- name: spire-controller-manager
|
||||
securityContext:
|
||||
{{- toYaml .Values.controllerManager.securityContext | nindent 12 }}
|
||||
image: {{ template "spire-server.image" (dict "appVersion" $.Chart.AppVersion "image" .Values.controllerManager.image) }}
|
||||
image: {{ template "spire-lib.image" (dict "appVersion" $.Chart.AppVersion "image" .Values.controllerManager.image) }}
|
||||
imagePullPolicy: {{ .Values.controllerManager.image.pullPolicy }}
|
||||
args:
|
||||
- --config=controller-manager-config.yaml
|
||||
|
||||
@@ -33,7 +33,7 @@ spec:
|
||||
- name: curl-federation-bundle-endpoint
|
||||
image: cgr.dev/chainguard/bash:latest
|
||||
command: ['curl']
|
||||
args: ['-k', '-s', '-f', 'https://{{ include "spire-server.fullname" . }}.{{ include "spire-server.namespace" . }}.svc.{{ include "spire-server.cluster-domain" . }}:{{ .Values.federation.bundleEndpoint.port }}']
|
||||
args: ['-k', '-s', '-f', 'https://{{ include "spire-server.fullname" . }}.{{ include "spire-server.namespace" . }}.svc.{{ include "spire-lib.cluster-domain" . }}:{{ .Values.federation.bundleEndpoint.port }}']
|
||||
securityContext:
|
||||
{{- toYaml .Values.securityContext | nindent 8 }}
|
||||
{{- end }}
|
||||
|
||||
Reference in New Issue
Block a user