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