Files
helm-charts-hardened/charts/spire/charts/spire-server/templates/post-install-hook.yaml
T
Rowan Ruseler 75ffbd06f5 Add imagePullSecrets support to helm hook jobs (#741)
* Add imagePullSecrets support to helm hook jobs

Hook jobs lacked imagePullSecrets configuration on their pod specs,
causing image pull failures in environments using private registries
with authentication

* spire-server: post-install, pre-upgrade, post-upgrade, pre-delete
  hooks
* spire-oidc-discovery-provider: pre-delete hook
* spike-nexus: bootstrap hook
* spire: global imagePullSecrets

Fixes #649

Signed-off-by: Rowan Ruseler <[email protected]>

* Document global.imagePullSecrets parameter

Signed-off-by: Rowan Ruseler <[email protected]>

* Replaced non functioning 'or' with 'coalesce'

Signed-off-by: Rowan Ruseler <[email protected]>

---------

Signed-off-by: Rowan Ruseler <[email protected]>
2026-02-11 15:16:16 -08:00

106 lines
4.0 KiB
YAML

{{- if not .Values.externalServer }}
{{- if eq ((dig "installAndUpgradeHooks" "enabled" .Values.controllerManager.installAndUpgradeHook.enabled .Values.global) | toString) "true" }}
{{- if eq .Values.controllerManager.staticManifestMode "off" }}
{{- if and (eq (.Values.controllerManager.enabled | toString) "true") .Values.controllerManager.validatingWebhookConfiguration.enabled }}
{{- if eq .Values.controllerManager.validatingWebhookConfiguration.failurePolicy "Fail" }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "spire-server.serviceAccountName" . }}-post-install
namespace: {{ include "spire-server.namespace" . }}
labels:
{{- include "spire-server.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": post-install
"helm.sh/hook-delete-policy": before-hook-creation, hook-succeeded, hook-failed
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "spire-server.fullname" . }}-post-install
annotations:
"helm.sh/hook": post-install
"helm.sh/hook-delete-policy": before-hook-creation, hook-succeeded, hook-failed
rules:
- apiGroups: ["admissionregistration.k8s.io"]
resources: ["validatingwebhookconfigurations"]
resourceNames: [{{ printf "%s-%s-webhook" .Release.Namespace (include "spire-controller-manager.fullname" .) | quote }}]
verbs: ["get", "patch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "spire-server.fullname" . }}-post-install
annotations:
"helm.sh/hook": post-install
"helm.sh/hook-delete-policy": before-hook-creation, hook-succeeded, hook-failed
subjects:
- kind: ServiceAccount
name: {{ include "spire-server.serviceAccountName" . }}-post-install
namespace: {{ include "spire-server.namespace" . }}
roleRef:
kind: ClusterRole
name: {{ include "spire-server.fullname" . }}-post-install
apiGroup: rbac.authorization.k8s.io
---
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "spire-server.fullname" . }}-post-install
namespace: {{ include "spire-server.namespace" . }}
labels:
{{- include "spire-server.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": post-install
"helm.sh/hook-delete-policy": before-hook-creation, hook-succeeded, hook-failed
spec:
template:
metadata:
name: {{ include "spire-server.fullname" . }}-post-install
spec:
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
restartPolicy: Never
{{- with (coalesce .Values.imagePullSecrets .Values.global.imagePullSecrets) }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "spire-server.serviceAccountName" . }}-post-install
securityContext:
{{- include "spire-lib.podsecuritycontext" . | nindent 8 }}
containers:
- name: post-install-job
securityContext:
{{- include "spire-lib.securitycontext" . | nindent 10 }}
image: {{ template "spire-lib.kubectl-image" (dict "appVersion" $.Chart.AppVersion "image" .Values.tools.kubectl.image "global" .Values.global "KubeVersion" .Capabilities.KubeVersion.Version) }}
args:
- patch
- validatingwebhookconfiguration
- {{ .Release.Namespace }}-{{ include "spire-controller-manager.fullname" . }}-webhook
- --type=strategic
- -p
- |
{
"webhooks":[
{
"name":"vclusterspiffeid.kb.io",
"failurePolicy":"{{ .Values.controllerManager.validatingWebhookConfiguration.failurePolicy }}"
},
{
"name":"vclusterfederatedtrustdomain.kb.io",
"failurePolicy":"{{ .Values.controllerManager.validatingWebhookConfiguration.failurePolicy }}"
}
]
}
{{- with (((.Values).global).installAndUpgradeHooks).resources }}
resources:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}