{{- define "template.deployment" -}} apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "template.fullname" . }} labels: {{- include "template.labels" . | nindent 4 }} spec: revisionHistoryLimit: {{ .Values.revisionHistoryLimit }} {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount }} {{- end }} selector: matchLabels: {{- include "template.selectorLabels" . | nindent 6 }} template: metadata: {{- with .Values.podAnnotations }} annotations: {{- toYaml . | nindent 8 }} {{- end }} 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 .Values.secrets }} 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 }} 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 }} {{- with .Values.podSpec }} {{- toYaml . | nindent 6 }} {{- end }} {{- end }}