{{- range $w := $.Values.workers }} --- apiVersion: extensions/v1beta1 kind: Deployment metadata: name: {{ $w.name }} namespace: {{ $.Release.Namespace }} labels: app: {{ $.Values.name }} type: {{ $.Values.type | default "service" }} {{- if $.Values.labels }} {{ toYaml $.Values.labels | indent 4 }} {{- end }} chart: {{ template "chart.chart" $ }} release: {{ $.Release.Name }} heritage: {{ $.Release.Service }} spec: replicas: {{ $w.replicaCount }} revisionHistoryLimit: 20 {{- if eq ($w.replicaCount | int) 1 }} strategy: rollingUpdate: maxUnavailable: 0 {{- end }} minReadySeconds: 10 selector: matchLabels: app: {{ $w.name }} release: {{ $.Release.Name }} template: metadata: labels: app: {{ $w.name }} release: {{ $.Release.Name }} annotations: checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") $ | sha256sum }} checksum/secrets: {{ include (print $.Template.BasePath "/secrets.yaml") $ | sha256sum }} spec: serviceAccountName: {{ $.Values.name }} #imagePullSecrets: containers: - name: {{ $.Values.name }} image: "{{ $.Values.image }}:{{ $.Values.version }}" {{- if $w.command }} command: {{ toYaml $w.command | indent 8}} {{- end }} imagePullPolicy: IfNotPresent resources: {{ toYaml $w.resources | indent 10 }} {{- if $w.httpPort }} ports: - name: http containerPort: {{ $w.httpPort }} protocol: TCP {{- end }} {{- if $w.readinessProbe }} readinessProbe: {{ toYaml $w.readinessProbe | indent 10 }} {{- end }} {{- if $w.livenessProbe }} livenessProbe: {{ toYaml $w.livenessProbe | indent 10 }} {{- end }} env: {{- range $k, $v := $.Values.env }} - name: {{ $k }} value: "{{ $v }}" {{- end }} {{- range $k, $v := $w.extraEnv }} - name: {{ $k }} value: "{{ $v }}" {{- end }} {{- range $k, $v := $.Values.secrets }} - name: {{ $k }} valueFrom: secretKeyRef: name: {{ $.Values.name }}-secrets key: {{ $k }} {{- end }} - name: SERVICE_NAME value: {{ $.Values.name }} - name: ENV_NAME value: {{ $.Values.environment }} - name: REGION_NAME value: {{ $.Values.region }} - name: SERVICE_VERSION value: {{ $.Values.version }} # volume mounts from the special case configMap or explicit mounts volumeMounts: {{- if $.Values.configs }} {{- $cfg := $.Values.configs }} {{- range $cfg.files }} - name: {{ $cfg.name }}-volume mountPath: {{ $cfg.mount }}{{ .dest }} subPath: {{ .dest }} {{- end }} {{- end }} {{- if $.Values.volumeMounts }} {{ toYaml $.Values.volumeMounts | indent 8 }} {{- end }} {{- range $index, $sidecar := $.Values.sidecars }} {{- $sidecar_template := printf "%s-sidecar" $sidecar.name -}} {{- include $sidecar_template $sidecar | indent 6 }} {{- end }} volumes: {{- if $.Values.configs }} # special case configmap first - name: {{ $.Values.configs.name }}-volume configMap: name: {{ $.Values.configs.name }} {{- end }} # other volumes {{- range $v := $.Values.volumes }} {{ toYaml (list $v) | indent 6 }} {{- end }} {{- end }}