Update git submodules
[oom.git] / kubernetes / policy / charts / policy-api / templates / deployment.yaml
1 apiVersion: apps/v1
2 kind: Deployment
3 metadata:
4   name: {{ include "common.fullname" . }}
5   namespace: {{ include "common.namespace" . }}
6   labels:
7     app: {{ include "common.name" . }}
8     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
9     release: {{ include "common.release" . }}
10     heritage: {{ .Release.Service }}
11 spec:
12   selector:
13     matchLabels:
14       app: {{ include "common.name" . }}
15   replicas: {{ .Values.replicaCount }}
16   template:
17     metadata:
18       labels:
19         app: {{ include "common.name" . }}
20         release: {{ include "common.release" . }}
21     spec:
22       initContainers:
23         - command:
24           - /root/ready.py
25           args:
26           - --container-name
27           - {{ include "common.release" . }}-galera-config
28           env:
29           - name: NAMESPACE
30             valueFrom:
31               fieldRef:
32                 apiVersion: v1
33                 fieldPath: metadata.namespace
34           image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
35           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
36           name: {{ include "common.name" . }}-readiness
37
38         - command:
39           - sh
40           args:
41           - -c
42           - "export SQL_PASSWORD_BASE64=`echo -n ${SQL_PASSWORD} | base64`; cd /config-input && for PFILE in `ls -1 .`; do envsubst <${PFILE} >/config/${PFILE}; done"
43           env:
44           - name: SQL_USER
45             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-creds" "key" "login") | indent 12 }}
46           - name: SQL_PASSWORD
47             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-creds" "key" "password") | indent 12 }}
48           - name: RESTSERVER_USER
49             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restserver-creds" "key" "login") | indent 12 }}
50           - name: RESTSERVER_PASSWORD
51             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restserver-creds" "key" "password") | indent 12 }}
52           volumeMounts:
53           - mountPath: /config-input
54             name: apiconfig
55           - mountPath: /config
56             name: apiconfig-processed
57           image: "{{ .Values.global.envsubstImage }}"
58           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
59           name: {{ include "common.name" . }}-update-config
60
61       containers:
62         - name: {{ include "common.name" . }}
63           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
64           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
65           command: ["/opt/app/policy/api/bin/policy-api.sh"]
66           args: ["/opt/app/policy/api/etc/mounted/config.json"]
67           ports:
68           - containerPort: {{ .Values.service.internalPort }}
69           # disable liveness probe when breakpoints set in debugger
70           # so K8s doesn't restart unresponsive container
71           {{- if eq .Values.liveness.enabled true }}
72           livenessProbe:
73             tcpSocket:
74               port: {{ .Values.service.internalPort }}
75             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
76             periodSeconds: {{ .Values.liveness.periodSeconds }}
77           {{ end -}}
78           readinessProbe:
79             tcpSocket:
80               port: {{ .Values.service.internalPort }}
81             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
82             periodSeconds: {{ .Values.readiness.periodSeconds }}
83           volumeMounts:
84           - mountPath: /etc/localtime
85             name: localtime
86             readOnly: true
87           - mountPath: /opt/app/policy/api/etc/mounted
88             name: apiconfig-processed
89           resources:
90 {{ include "common.resources" . | indent 12 }}
91         {{- if .Values.nodeSelector }}
92         nodeSelector:
93 {{ toYaml .Values.nodeSelector | indent 10 }}
94         {{- end -}}
95         {{- if .Values.affinity }}
96         affinity:
97 {{ toYaml .Values.affinity | indent 10 }}
98         {{- end }}
99       volumes:
100         - name: localtime
101           hostPath:
102              path: /etc/localtime
103         - name: apiconfig
104           configMap:
105             name: {{ include "common.fullname" . }}-configmap
106             defaultMode: 0755
107         - name: apiconfig-processed
108           emptyDir:
109             medium: Memory
110       imagePullSecrets:
111       - name: "{{ include "common.namespace" . }}-docker-registry-key"