mirror of
https://github.com/2martens/cloud-configuration.git
synced 2026-10-17 16:46:51 +02:00
139 lines
5.1 KiB
YAML
139 lines
5.1 KiB
YAML
{{- define "template.deployment" -}}
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ include "template.fullname" . }}
|
|
labels:
|
|
{{- include "template.labels" . | nindent 4 }}
|
|
annotations:
|
|
{{- include "template.annotations" . | nindent 4 }}
|
|
spec:
|
|
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
|
|
{{- if not .Values.autoscaling.enabled }}
|
|
replicas: {{ .Values.replicaCount }}
|
|
{{- end }}
|
|
selector:
|
|
matchLabels:
|
|
{{- include "template.selectorLabels" . | nindent 6 }}
|
|
template:
|
|
metadata:
|
|
annotations:
|
|
{{- if and $.Values.prometheus.enabled (not $.Values.prometheus.useCRDs) $.Values.application.isSpring }}
|
|
prometheus.io/scrape: "true"
|
|
prometheus.io/path: /actuator/prometheus
|
|
prometheus.io/port: "{{ $.Values.application.actuatorPort }}"
|
|
{{- end }}
|
|
{{- with .Values.podAnnotations }}
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- include "template.annotations" . | nindent 8 }}
|
|
labels:
|
|
{{- include "template.selectorLabels" . | nindent 8 }}
|
|
spec:
|
|
enableServiceLinks: {{ .Values.enableServiceLinks }}
|
|
{{- with .Values.imagePullSecrets }}
|
|
imagePullSecrets:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
serviceAccountName: {{ include "template.serviceAccountName" . }}
|
|
securityContext:
|
|
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
|
containers:
|
|
- name: {{ .Chart.Name }}
|
|
securityContext:
|
|
{{- toYaml .Values.securityContext | nindent 12 }}
|
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default "latest" }}"
|
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
|
{{- if or .Values.secrets .Values.vault.enabled }}
|
|
envFrom:
|
|
- secretRef:
|
|
name: {{ include "template.fullname" . }}
|
|
{{- end }}
|
|
env:
|
|
{{- if .Values.application.isSpring }}
|
|
- name: SPRING_PROFILES_ACTIVE
|
|
value: {{ .Values.application.profile }}
|
|
{{- end}}
|
|
{{- range .Values.environment }}
|
|
- name: {{ .name }}
|
|
value: {{ tpl (quote .value) $ }}
|
|
{{- end }}
|
|
{{- if or .Values.application.isSpring .Values.volumeMounts }}
|
|
volumeMounts:
|
|
{{- if .Values.application.isSpring }}
|
|
- mountPath: /tmp
|
|
name: tmp
|
|
{{- end }}
|
|
{{- if .Values.volumeMounts }}
|
|
{{- toYaml .Values.volumeMounts | nindent 12 }}
|
|
{{- end }}
|
|
{{- end }}
|
|
ports:
|
|
- name: http
|
|
containerPort: {{ .Values.application.port }}
|
|
protocol: TCP
|
|
{{- if .Values.application.isSpring }}
|
|
- name: http-actuator
|
|
containerPort: {{ .Values.application.actuatorPort }}
|
|
protocol: TCP
|
|
{{- end }}
|
|
{{- if .Values.livenessProbe.enabled }}
|
|
livenessProbe:
|
|
httpGet:
|
|
path: {{ .Values.livenessProbe.path }}
|
|
port: {{ .Values.livenessProbe.port }}
|
|
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
|
|
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
|
|
{{- end }}
|
|
{{- if .Values.readinessProbe.enabled }}
|
|
readinessProbe:
|
|
httpGet:
|
|
path: {{ .Values.readinessProbe.path }}
|
|
port: {{ .Values.readinessProbe.port }}
|
|
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
|
|
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
|
|
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
|
|
{{- end }}
|
|
resources:
|
|
{{- toYaml .Values.resources | nindent 12 }}
|
|
{{- with .Values.containerSpec }}
|
|
{{- toYaml . | nindent 10 }}
|
|
{{- end }}
|
|
{{/*
|
|
Due to the asynchronous way Kubernetes shuts down applications there is a period of
|
|
time when requests can be sent to the application while an application is being terminated.
|
|
To deal with this we can configure a pre-stop sleep to allow enough time for requests to
|
|
stop being routed to the application before it is terminated.
|
|
*/}}
|
|
lifecycle:
|
|
preStop:
|
|
exec:
|
|
command: [ "sh", "-c", "sleep 10" ]
|
|
{{- with .Values.nodeSelector }}
|
|
nodeSelector:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.affinity }}
|
|
affinity:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.tolerations }}
|
|
tolerations:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- if or .Values.application.isSpring .Values.volumes }}
|
|
volumes:
|
|
{{- if .Values.application.isSpring }}
|
|
- name: tmp
|
|
emptyDir:
|
|
medium: Memory
|
|
{{- end }}
|
|
{{- if .Values.volumes }}
|
|
{{- toYaml .Values.volumes | nindent 8 }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- with .Values.podSpec }}
|
|
{{- toYaml . | nindent 6 }}
|
|
{{- end }}
|
|
{{- end }}
|