|
| 1 | +{{- if and .Values.api.enabled .Values.api.deployment.enabled }} |
| 2 | +apiVersion: apps/v1 |
| 3 | +kind: Deployment |
| 4 | +metadata: |
| 5 | + name: {{ include "api.fullname" . }} |
| 6 | + namespace: {{ .Release.Namespace }} |
| 7 | + labels: |
| 8 | + {{- include "api.labels" . | nindent 4 }} |
| 9 | +spec: |
| 10 | + {{- if not .Values.api.autoscaling.enabled }} |
| 11 | + replicas: {{ default 1 .Values.api.autoscaling.minReplicas }} |
| 12 | + {{- end }} |
| 13 | + selector: |
| 14 | + matchLabels: |
| 15 | + {{- include "api.selectorLabels" . | nindent 6 }} |
| 16 | + template: |
| 17 | + metadata: |
| 18 | + annotations: |
| 19 | + rollme: {{ randAlphaNum 5 | quote }} |
| 20 | + {{- if .Values.api.podAnnotations }} |
| 21 | + {{- tpl .Values.api.podAnnotations $ | nindent 8 }} |
| 22 | + {{- end }} |
| 23 | + labels: |
| 24 | + {{- include "api.labels" . | nindent 8 }} |
| 25 | + spec: |
| 26 | + securityContext: |
| 27 | + runAsNonRoot: true |
| 28 | + seccompProfile: |
| 29 | + type: RuntimeDefault |
| 30 | + containers: |
| 31 | + {{- range $c := .Values.api.containers }} |
| 32 | + - name: {{ $c.name }} |
| 33 | + image: "{{- if and $c.registry $c.repository -}}{{ tpl $c.registry $ }}/{{ tpl $c.repository $ }}/{{ tpl $c.image $ }}{{- else if $c.registry -}}{{ tpl $c.registry $ }}/{{ tpl $c.image $ }}{{- else -}}{{ tpl $c.image $ }}{{- end -}}{{- if $c.tag -}}:{{ tpl (printf "%v" $c.tag) $ }}{{- end -}}" |
| 34 | + securityContext: |
| 35 | + allowPrivilegeEscalation: false |
| 36 | + runAsNonRoot: true |
| 37 | + capabilities: |
| 38 | + drop: |
| 39 | + - ALL |
| 40 | + {{- if and $c.envFrom $c.envFrom.secretRef $c.envFrom.secretRef.name }} |
| 41 | + envFrom: |
| 42 | + - secretRef: |
| 43 | + name: {{ tpl $c.envFrom.secretRef.name $ }} |
| 44 | + {{- end }} |
| 45 | + {{- if $c.env }} |
| 46 | + env: |
| 47 | + {{- if and (kindIs "map" $c.env) $c.env.fromValues }} |
| 48 | + {{- range $e := $c.env.fromValues }} |
| 49 | + - name: {{ $e.name }} |
| 50 | + value: {{ tpl (printf "%v" $e.value) $ | quote }} |
| 51 | + {{- end }} |
| 52 | + {{- else if kindIs "slice" $c.env }} |
| 53 | + {{- tpl (toYaml $c.env) $ | nindent 12 }} |
| 54 | + {{- end }} |
| 55 | + {{- end }} |
| 56 | + {{- if $c.ports }} |
| 57 | + ports: |
| 58 | + {{- tpl (toYaml $c.ports) $ | nindent 12 }} |
| 59 | + {{- end }} |
| 60 | + {{- if $c.resources }} |
| 61 | + resources: |
| 62 | + {{- toYaml $c.resources | nindent 12 }} |
| 63 | + {{- end }} |
| 64 | + {{- if $c.readinessProbe }} |
| 65 | + readinessProbe: |
| 66 | + {{- toYaml $c.readinessProbe | nindent 12 }} |
| 67 | + {{- end }} |
| 68 | + {{- if $c.livenessProbe }} |
| 69 | + livenessProbe: |
| 70 | + {{- toYaml $c.livenessProbe | nindent 12 }} |
| 71 | + {{- end }} |
| 72 | + {{- end }} |
| 73 | + |
| 74 | + {{- with .Values.api.nodeSelector }} |
| 75 | + nodeSelector: |
| 76 | + {{- toYaml . | nindent 8 }} |
| 77 | + {{- end }} |
| 78 | + {{- with .Values.api.tolerations }} |
| 79 | + tolerations: |
| 80 | + {{- toYaml . | nindent 8 }} |
| 81 | + {{- end }} |
| 82 | + {{- with .Values.api.affinity }} |
| 83 | + affinity: |
| 84 | + {{- toYaml . | nindent 8 }} |
| 85 | + {{- end }} |
| 86 | +{{- end }} |
0 commit comments