216 lines
No EOL
9.2 KiB
YAML
216 lines
No EOL
9.2 KiB
YAML
{{- include "go-bananas.validate" . }}
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ include "go-bananas.fullname" . }}
|
|
namespace: {{ .Release.Namespace }}
|
|
labels:
|
|
{{- include "go-bananas.labels" . | nindent 4 }}
|
|
app.kubernetes.io/component: server
|
|
{{- with .Values.global.extraAnnotations }}
|
|
annotations:
|
|
{{- toYaml . | nindent 4 }}
|
|
{{- end }}
|
|
spec:
|
|
{{- if not .Values.autoscaling.enabled }}
|
|
replicas: {{ .Values.deployment.replicaCount }}
|
|
{{- end }}
|
|
revisionHistoryLimit: {{ .Values.deployment.revisionHistoryLimit }}
|
|
minReadySeconds: {{ .Values.deployment.minReadySeconds }}
|
|
progressDeadlineSeconds: {{ .Values.deployment.progressDeadlineSeconds }}
|
|
strategy:
|
|
{{- toYaml .Values.deployment.strategy | nindent 4 }}
|
|
selector:
|
|
matchLabels:
|
|
{{- include "go-bananas.selectorLabels" . | nindent 6 }}
|
|
template:
|
|
metadata:
|
|
annotations:
|
|
# Rolling the pods when the ConfigMap changes is what makes `helm upgrade`
|
|
# actually apply a configuration change: without this annotation the
|
|
# Deployment spec is unchanged and Kubernetes would not restart anything.
|
|
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
|
|
{{- if and .Values.persistence.enabled (eq .Values.persistence.type "persistentVolumeClaim") (not .Values.persistence.existingClaim) (gt (int .Values.deployment.replicaCount) 1) }}
|
|
# A ReadWriteOnce volume can be mounted by one pod at a time. With more than
|
|
# one replica the others will fail to start unless the storage class
|
|
# supports concurrent mounts. Set deployment.replicaCount to 1, or use a
|
|
# ReadWriteMany filesystem.
|
|
go-bananas.urpi.be/storage-note: >-
|
|
ReadWriteOnce volume with {{ .Values.deployment.replicaCount }} replicas.
|
|
Only one replica can mount it unless the storage class permits concurrent
|
|
mounts.
|
|
{{- end }}
|
|
{{- if and (eq .Values.identity.mode "oidc") .Values.identity.oidc.generateSecret }}
|
|
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
|
|
{{- end }}
|
|
{{- with .Values.deployment.podAnnotations }}
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
labels:
|
|
{{- include "go-bananas.selectorLabels" . | nindent 8 }}
|
|
{{- with .Values.deployment.podLabels }}
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
spec:
|
|
serviceAccountName: {{ include "go-bananas.serviceAccountName" . }}
|
|
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
|
|
{{- with .Values.serviceAccount.annotations }}
|
|
annotations:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.global.imagePullSecrets }}
|
|
imagePullSecrets:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.deployment.priorityClassName }}
|
|
priorityClassName: {{ . }}
|
|
{{- end }}
|
|
{{- with .Values.deployment.hostAliases }}
|
|
hostAliases:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
securityContext:
|
|
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
|
terminationGracePeriodSeconds: {{ .Values.deployment.terminationGracePeriodSeconds }}
|
|
containers:
|
|
- name: go-bananas
|
|
image: {{ include "go-bananas.image" . }}
|
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
|
{{- if .Values.deployment.lifecycle.preStop.enabled }}
|
|
# A preStop sleep gives the Service endpoints controller time to remove this
|
|
# pod from the endpoint list before the process starts refusing connections.
|
|
# Without it, a rolling update can drop requests that were already routed.
|
|
# lifecycle is a container field, not a podSpec field.
|
|
lifecycle:
|
|
preStop:
|
|
exec:
|
|
command: ["/bin/sh", "-c", "sleep {{ .Values.deployment.lifecycle.preStop.sleepSeconds }}"]
|
|
{{- end }}
|
|
{{- with .Values.deployment.extraArgs }}
|
|
args:
|
|
{{- toYaml . | nindent 12 }}
|
|
{{- end }}
|
|
securityContext:
|
|
{{- toYaml .Values.securityContext | nindent 12 }}
|
|
envFrom:
|
|
- configMapRef:
|
|
name: {{ include "go-bananas.fullname" . }}
|
|
{{- if ne .Values.identity.mode "disabled" }}
|
|
env:
|
|
{{- /*
|
|
Secrets are injected through env rather than a mounted volume. Both
|
|
are equally protected by the kubelet; env avoids the temptation to
|
|
read the value from a file path into a log line, and the application
|
|
never echoes it back.
|
|
*/}}
|
|
- name: BANANAS_SESSION_SECRET
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ include "go-bananas.secretName" . }}
|
|
key: {{ include "go-bananas.sessionSecretKey" . }}
|
|
optional: false
|
|
{{- if and (eq .Values.identity.mode "oidc") (not (empty (include "go-bananas.usesExistingSecret" .))) }}
|
|
- name: BANANAS_OIDC_CLIENT_SECRET
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ include "go-bananas.secretName" . }}
|
|
key: {{ include "go-bananas.clientSecretKey" . }}
|
|
optional: false
|
|
{{- end }}
|
|
{{- with .Values.extraEnv }}
|
|
{{- toYaml . | nindent 12 }}
|
|
{{- end }}
|
|
{{- end }}
|
|
ports:
|
|
- name: http
|
|
containerPort: 8080
|
|
protocol: TCP
|
|
{{- if .Values.probes.startup.enabled }}
|
|
startupProbe:
|
|
httpGet:
|
|
path: {{ .Values.probes.startup.path }}
|
|
port: http
|
|
periodSeconds: {{ .Values.probes.startup.periodSeconds }}
|
|
failureThreshold: {{ .Values.probes.startup.failureThreshold }}
|
|
{{- end }}
|
|
{{- if .Values.probes.liveness.enabled }}
|
|
# Liveness deliberately uses /healthz, which does not touch the database.
|
|
# A probe that fails on a slow database would have the kubelet restart a
|
|
# process that is otherwise healthy, turning a dependency blip into an
|
|
# outage.
|
|
livenessProbe:
|
|
httpGet:
|
|
path: {{ .Values.probes.liveness.path }}
|
|
port: http
|
|
initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }}
|
|
periodSeconds: {{ .Values.probes.liveness.periodSeconds }}
|
|
timeoutSeconds: {{ .Values.probes.liveness.timeoutSeconds }}
|
|
failureThreshold: {{ .Values.probes.liveness.failureThreshold }}
|
|
{{- end }}
|
|
{{- if .Values.probes.readiness.enabled }}
|
|
# Readiness does check the database: a pod that cannot reach it cannot
|
|
# serve anything, and removing it from the endpoints is the correct
|
|
# response.
|
|
readinessProbe:
|
|
httpGet:
|
|
path: {{ .Values.probes.readiness.path }}
|
|
port: http
|
|
initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }}
|
|
periodSeconds: {{ .Values.probes.readiness.periodSeconds }}
|
|
timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }}
|
|
failureThreshold: {{ .Values.probes.readiness.failureThreshold }}
|
|
{{- end }}
|
|
resources:
|
|
{{- toYaml .Values.resources | nindent 12 }}
|
|
volumeMounts:
|
|
- name: data
|
|
mountPath: {{ .Values.persistence.mountPath }}
|
|
{{- /*
|
|
The root filesystem is read-only, so /tmp has to be an explicit
|
|
emptyDir. Go writes temporary files there during compression and
|
|
the SQLite driver uses it for spill, so without this the process
|
|
fails in ways that look unrelated.
|
|
*/}}
|
|
- name: tmp
|
|
mountPath: /tmp
|
|
{{- with .Values.extraVolumeMounts }}
|
|
{{- toYaml . | nindent 12 }}
|
|
{{- end }}
|
|
volumes:
|
|
- name: data
|
|
{{- if not .Values.persistence.enabled }}
|
|
emptyDir: {}
|
|
{{- else if .Values.persistence.existingClaim }}
|
|
persistentVolumeClaim:
|
|
claimName: {{ .Values.persistence.existingClaim }}
|
|
readOnly: false
|
|
{{- else if eq .Values.persistence.type "persistentVolumeClaim" }}
|
|
persistentVolumeClaim:
|
|
claimName: {{ include "go-bananas.dataVolumeName" . }}
|
|
readOnly: false
|
|
{{- else }}
|
|
emptyDir: {}
|
|
{{- end }}
|
|
- name: tmp
|
|
emptyDir:
|
|
medium: Memory
|
|
sizeLimit: 32Mi
|
|
{{- with .Values.extraVolumes }}
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.deployment.nodeSelector }}
|
|
nodeSelector:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.deployment.tolerations }}
|
|
tolerations:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.deployment.affinity }}
|
|
affinity:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.deployment.topologySpreadConstraints }}
|
|
topologySpreadConstraints:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }} |