|
| 1 | + |
| 2 | +{{- range $key, $service := .Values.services }} |
| 3 | +{{- if $service.enabled }} |
| 4 | +apiVersion: apps/v1 |
| 5 | +kind: Deployment |
| 6 | +metadata: |
| 7 | + name: {{ include "deploystack.fullname" $ }}-{{ $key }} |
| 8 | + labels: |
| 9 | + {{- include "deploystack.labels" $ | nindent 4 }} |
| 10 | + app.kubernetes.io/component: {{ $key }} |
| 11 | +spec: |
| 12 | + {{- if not $service.autoscaling.enabled }} |
| 13 | + replicas: {{ $service.replicaCount }} |
| 14 | + {{- end }} |
| 15 | + selector: |
| 16 | + matchLabels: |
| 17 | + {{- include "deploystack.selectorLabels" $ | nindent 6 }} |
| 18 | + app.kubernetes.io/component: {{ $key }} |
| 19 | + template: |
| 20 | + metadata: |
| 21 | + {{- with $.Values.global.podAnnotations }} |
| 22 | + annotations: |
| 23 | + {{- toYaml . | nindent 8 }} |
| 24 | + {{- end }} |
| 25 | + labels: |
| 26 | + {{- include "deploystack.selectorLabels" $ | nindent 8 }} |
| 27 | + app.kubernetes.io/component: {{ $key }} |
| 28 | + spec: |
| 29 | + {{- with $.Values.global.imagePullSecrets }} |
| 30 | + imagePullSecrets: |
| 31 | + {{- toYaml . | nindent 8 }} |
| 32 | + {{- end }} |
| 33 | + securityContext: |
| 34 | + {{- toYaml $.Values.global.podSecurityContext | nindent 8 }} |
| 35 | + containers: |
| 36 | + - name: {{ $key }} |
| 37 | + securityContext: |
| 38 | + {{- toYaml $.Values.global.securityContext | nindent 12 }} |
| 39 | + image: "{{ $service.image.repository }}:{{ $service.image.tag | default "latest" }}" |
| 40 | + imagePullPolicy: {{ $service.image.pullPolicy }} |
| 41 | + {{- if $service.command }} |
| 42 | + command: |
| 43 | + {{- toYaml $service.command | nindent 12 }} |
| 44 | + {{- end }} |
| 45 | + ports: |
| 46 | + {{- range $service.service.ports }} |
| 47 | + - name: http-{{ .port }} |
| 48 | + containerPort: {{ .targetPort }} |
| 49 | + protocol: {{ .protocol }} |
| 50 | + {{- end }} |
| 51 | + {{- if or $service.environment.regular $service.environment.sensitive }} |
| 52 | + env: |
| 53 | + {{- range $envKey, $envValue := $service.environment.regular }} |
| 54 | + - name: {{ $envKey }} |
| 55 | + valueFrom: |
| 56 | + configMapKeyRef: |
| 57 | + name: {{ include "deploystack.fullname" $ }}-{{ $key }}-config |
| 58 | + key: {{ $envKey }} |
| 59 | + {{- end }} |
| 60 | + {{- range $envKey, $envValue := $service.environment.sensitive }} |
| 61 | + - name: {{ $envKey }} |
| 62 | + valueFrom: |
| 63 | + secretKeyRef: |
| 64 | + name: {{ include "deploystack.fullname" $ }}-{{ $key }}-secret |
| 65 | + key: {{ $envKey }} |
| 66 | + {{- end }} |
| 67 | + {{- if $service.dependencies }} |
| 68 | + {{- range $service.dependencies }} |
| 69 | + {{- range $envKey, $envValue := .variables }} |
| 70 | + - name: {{ $envKey }} |
| 71 | + valueFrom: |
| 72 | + configMapKeyRef: |
| 73 | + name: {{ include "deploystack.fullname" $ }}-{{ $key }}-dependencies |
| 74 | + key: {{ $envKey }} |
| 75 | + {{- end }} |
| 76 | + {{- end }} |
| 77 | + {{- end }} |
| 78 | + {{- end }} |
| 79 | + {{- with $service.volumes }} |
| 80 | + volumeMounts: |
| 81 | + {{- toYaml . | nindent 12 }} |
| 82 | + {{- end }} |
| 83 | + resources: |
| 84 | + {{- toYaml $service.resources | nindent 12 }} |
| 85 | + {{- with $service.volumes }} |
| 86 | + volumes: |
| 87 | + {{- range . }} |
| 88 | + - name: {{ .name }} |
| 89 | + hostPath: |
| 90 | + path: {{ .hostPath }} |
| 91 | + {{- end }} |
| 92 | + {{- end }} |
| 93 | +{{- end }} |
| 94 | +{{- end }} |
0 commit comments