1bd94eed0bb58878ac3fe1741d64b7121d95155d
[oom.git] / kubernetes / policy / components / policy-xacml-pdp / templates / deployment.yaml
1 {{/*
2 #  ============LICENSE_START=======================================================
3 #   Copyright (C) 2020 AT&T Intellectual Property.
4 #  ================================================================================
5 #  Licensed under the Apache License, Version 2.0 (the "License");
6 #  you may not use this file except in compliance with the License.
7 #  You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #  Unless required by applicable law or agreed to in writing, software
12 #  distributed under the License is distributed on an "AS IS" BASIS,
13 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #  See the License for the specific language governing permissions and
15 #  limitations under the License.
16 #
17 #  SPDX-License-Identifier: Apache-2.0
18 #  ============LICENSE_END=========================================================
19 */}}
20
21 apiVersion: apps/v1
22 kind: Deployment
23 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
24 spec:
25   selector: {{- include "common.selectors" . | nindent 4 }}
26   replicas: {{ .Values.replicaCount }}
27   template:
28     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
29     spec:
30       initContainers:
31       - command:
32         - /app/ready.py
33         args:
34         - --job-name
35         - {{ include "common.release" . }}-policy-galera-config
36         env:
37         - name: NAMESPACE
38           valueFrom:
39             fieldRef:
40               apiVersion: v1
41               fieldPath: metadata.namespace
42         image: {{ include "repositoryGenerator.image.readiness" . }}
43         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
44         name: {{ include "common.name" . }}-readiness
45       - command:
46         - sh
47         args:
48         - -c
49         - "cd /config-input && for PFILE in `ls -1`; do envsubst <${PFILE} >/config/${PFILE}; done"
50         env:
51         - name: RESTSERVER_USER
52           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restserver-creds" "key" "login") | indent 10 }}
53         - name: RESTSERVER_PASSWORD
54           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restserver-creds" "key" "password") | indent 10 }}
55         - name: API_USER
56           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "api-creds" "key" "login") | indent 10 }}
57         - name: API_PASSWORD
58           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "api-creds" "key" "password") | indent 10 }}
59         - name: SQL_USER
60           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
61         - name: SQL_PASSWORD
62           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
63         volumeMounts:
64         - mountPath: /config-input
65           name: pdpxconfig
66         - mountPath: /config
67           name: pdpxconfig-processed
68         image: {{ include "repositoryGenerator.image.envsubst" . }}
69         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
70         name: {{ include "common.name" . }}-update-config
71       containers:
72         - name: {{ include "common.name" . }}
73           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
74           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
75           command: ["/opt/app/policy/pdpx/bin/policy-pdpx.sh"]
76           args: ["/opt/app/policy/pdpx/etc/mounted/config.json"]
77           ports: {{ include "common.containerPorts" . | nindent 12  }}
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/pdpx/etc/mounted
97             name: pdpxconfig-processed
98           resources: {{ include "common.resources" . | nindent 12 }}
99         {{- if .Values.nodeSelector }}
100         nodeSelector:
101 {{ toYaml .Values.nodeSelector | indent 10 }}
102         {{- end -}}
103         {{- if .Values.affinity }}
104         affinity:
105 {{ toYaml .Values.affinity | indent 10 }}
106         {{- end }}
107       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
108       volumes:
109         - name: localtime
110           hostPath:
111              path: /etc/localtime
112         - name: pdpxconfig
113           configMap:
114             name: {{ include "common.fullname" . }}-configmap
115             defaultMode: 0755
116         - name: pdpxconfig-processed
117           emptyDir:
118             medium: Memory
119       imagePullSecrets:
120       - name: "{{ include "common.namespace" . }}-docker-registry-key"