Files
helm-charts-hardened/charts/spire/charts/spire-server/templates/statefulset.yaml
T
Kevin Fox b7f8c86478 Add extra initContainers, containers, volumes to agent and server
With plugin support, agents and servers need more customization.
This patch enables initContainers, extraContainers, extraVolumes
and extraVolumeMounts to be added to those services.

Signed-off-by: Kevin Fox <[email protected]>
2023-03-02 08:02:19 -08:00

186 lines
6.6 KiB
YAML

{{- $configSum := (include (print $.Template.BasePath "/configmap.yaml") . | sha256sum) }}
{{- $fullname := include "spire-server.fullname" . }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "spire-server.fullname" . }}
labels:
{{- include "spire-server.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
serviceName: {{ include "spire-server.fullname" . }}
selector:
matchLabels:
{{- include "spire-server.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
checksum/config: {{ $configSum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "spire-server.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "spire-server.serviceAccountName" . }}
shareProcessNamespace: true
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if gt (len .Values.initContainers) 0 }}
initContainers:
{{- toYaml .Values.initContainers | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: {{ template "spire-server.image" (dict "appVersion" $.Chart.AppVersion "image" .Values.image) }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- -config
- /run/spire/config/server.conf
env:
- name: PATH
value: "/opt/spire/bin:/bin"
ports:
- name: grpc
containerPort: 8081
protocol: TCP
- containerPort: 8080
name: healthz
{{- if (dig "telemetry" "prometheus" "enabled" .Values.telemetry.prometheus.enabled .Values.global) }}
- containerPort: 9988
name: prom
{{- end }}
livenessProbe:
httpGet:
path: /live
port: healthz
failureThreshold: 2
initialDelaySeconds: 15
periodSeconds: 60
timeoutSeconds: 3
readinessProbe:
httpGet:
path: /ready
port: healthz
initialDelaySeconds: 5
periodSeconds: 5
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: spire-server-socket
mountPath: /tmp/spire-server/private
readOnly: false
- name: spire-config
mountPath: /run/spire/config
readOnly: true
{{- if eq (.Values.dataStorage.enabled | toString) "true" }}
- name: spire-data
mountPath: /run/spire/data
readOnly: false
{{- end }}
{{- if eq (.Values.upstreamAuthority.disk.enabled | toString) "true" }}
- name: upstream-ca
mountPath: /run/spire/upstream_ca
readOnly: false
{{ end }}
{{- if gt (len .Values.extraVolumeMounts) 0 }}
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
{{- end }}
{{- if eq (.Values.controllerManager.enabled | toString) "true" }}
- name: spire-controller-manager
securityContext:
{{- toYaml .Values.controllerManager.securityContext | nindent 12 }}
image: {{ template "spire-server.image" (dict "appVersion" $.Chart.AppVersion "image" .Values.controllerManager.image) }}
imagePullPolicy: {{ .Values.controllerManager.image.pullPolicy }}
args:
- --config=controller-manager-config.yaml
ports:
- name: https
containerPort: 9443
protocol: TCP
- containerPort: 8083
name: healthz
{{- if (dig "telemetry" "prometheus" "enabled" .Values.telemetry.prometheus.enabled .Values.global) }}
- containerPort: 8082
name: prom2
{{- end }}
livenessProbe:
httpGet:
path: /healthz
port: healthz
readinessProbe:
httpGet:
path: /readyz
port: healthz
resources:
{{- toYaml .Values.controllerManager.resources | nindent 12 }}
volumeMounts:
- name: spire-server-socket
mountPath: /tmp/spire-server/private
readOnly: true
- name: controller-manager-config
mountPath: /controller-manager-config.yaml
subPath: controller-manager-config.yaml
readOnly: true
{{- end }}
{{- if gt (len .Values.extraContainers) 0 }}
{{- toYaml .Values.extraContainers | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: spire-config
configMap:
name: {{ include "spire-server.fullname" . }}
- name: spire-server-socket
emptyDir: {}
{{- if eq (.Values.upstreamAuthority.disk.enabled | toString) "true" }}
- name: upstream-ca
secret:
secretName: {{ include "spire-server.upstream-ca-secret" . }}
{{- end }}
{{- if eq (.Values.controllerManager.enabled | toString) "true" }}
- name: controller-manager-config
configMap:
name: {{ include "spire-controller-manager.fullname" . }}
{{- end }}
{{- if gt (len .Values.extraVolumes) 0 }}
{{- toYaml .Values.extraVolumes | nindent 8 }}
{{- end }}
volumeClaimTemplates:
{{- if eq (.Values.dataStorage.enabled | toString) "true" }}
- metadata:
name: spire-data
spec:
accessModes:
- {{ .Values.dataStorage.accessMode | default "ReadWriteOnce" }}
resources:
requests:
storage: {{ .Values.dataStorage.size }}
{{- if .Values.dataStorage.storageClass }}
storageClassName: {{ .Values.dataStorage.storageClass }}
{{- end }}
{{ end }}