f3cccff32b2d9b0d3cdf901826aaf54768d2270f
[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         resources:
46           limits:
47             cpu: "100m"
48             memory: "0.5Gi"
49           requests:
50             cpu: "3m"
51             memory: "0.02Gi"
52       - command:
53         - sh
54         args:
55         - -c
56         - "cd /config-input && for PFILE in `ls -1`; do envsubst <${PFILE} >/config/${PFILE}; done"
57         env:
58         - name: RESTSERVER_USER
59           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restserver-creds" "key" "login") | indent 10 }}
60         - name: RESTSERVER_PASSWORD
61           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restserver-creds" "key" "password") | indent 10 }}
62         - name: API_USER
63           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "api-creds" "key" "login") | indent 10 }}
64         - name: API_PASSWORD
65           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "api-creds" "key" "password") | indent 10 }}
66         - name: SQL_USER
67           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
68         - name: SQL_PASSWORD
69           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
70         volumeMounts:
71         - mountPath: /config-input
72           name: pdpxconfig
73         - mountPath: /config
74           name: pdpxconfig-processed
75         image: {{ include "repositoryGenerator.image.envsubst" . }}
76         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
77         name: {{ include "common.name" . }}-update-config
78       containers:
79         - name: {{ include "common.name" . }}
80           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
81           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
82           command: ["/opt/app/policy/pdpx/bin/policy-pdpx.sh"]
83           args: ["/opt/app/policy/pdpx/etc/mounted/config.json"]
84           ports: {{ include "common.containerPorts" . | nindent 12  }}
85           # disable liveness probe when breakpoints set in debugger
86           # so K8s doesn't restart unresponsive container
87           {{- if eq .Values.liveness.enabled true }}
88           livenessProbe:
89             tcpSocket:
90               port: {{ .Values.service.internalPort }}
91             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
92             periodSeconds: {{ .Values.liveness.periodSeconds }}
93           {{ end -}}
94           readinessProbe:
95             tcpSocket:
96               port: {{ .Values.service.internalPort }}
97             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
98             periodSeconds: {{ .Values.readiness.periodSeconds }}
99           volumeMounts:
100           - mountPath: /etc/localtime
101             name: localtime
102             readOnly: true
103           - mountPath: /opt/app/policy/pdpx/etc/mounted
104             name: pdpxconfig-processed
105           resources: {{ include "common.resources" . | nindent 12 }}
106         {{- if .Values.nodeSelector }}
107         nodeSelector:
108 {{ toYaml .Values.nodeSelector | indent 10 }}
109         {{- end -}}
110         {{- if .Values.affinity }}
111         affinity:
112 {{ toYaml .Values.affinity | indent 10 }}
113         {{- end }}
114       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
115       volumes:
116         - name: localtime
117           hostPath:
118              path: /etc/localtime
119         - name: pdpxconfig
120           configMap:
121             name: {{ include "common.fullname" . }}-configmap
122             defaultMode: 0755
123         - name: pdpxconfig-processed
124           emptyDir:
125             medium: Memory
126       imagePullSecrets:
127       - name: "{{ include "common.namespace" . }}-docker-registry-key"