[PORTAL ] Non-root user DB access from WMS
[oom.git] / kubernetes / portal / components / portal-widget / templates / deployment.yaml
1 # Copyright © 2017 Amdocs, Bell Canada
2 # Modifications Copyright © 2018 AT&T
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 apiVersion: apps/v1
17 kind: Deployment
18 metadata:
19   name: {{ include "common.fullname" . }}
20   namespace: {{ include "common.namespace" . }}
21   labels:
22     app: {{ include "common.name" . }}
23     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
24     release: {{ include "common.release" . }}
25     heritage: {{ .Release.Service }}
26 spec:
27   selector:
28     matchLabels:
29       app: {{ include "common.name" . }}
30   replicas: {{ .Values.replicaCount }}
31   template:
32     metadata:
33       labels:
34         app: {{ include "common.name" . }}
35         release: {{ include "common.release" . }}
36     spec:
37       initContainers:
38       - name: {{ include "common.name" . }}-readiness
39         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
40         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
41         command:
42         - /app/ready.py
43         args:
44         - --container-name
45         - "portal-db"
46         env:
47         - name: NAMESPACE
48           valueFrom:
49             fieldRef:
50               apiVersion: v1
51               fieldPath: metadata.namespace
52       - name: {{ include "common.name" . }}-portal-widget-config
53         image: "{{ .Values.global.envsubstImage }}"
54         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
55         command:
56         - sh
57         args:
58         - "-c"
59         - |
60           cd /config-input && \
61           for PFILE in `ls -1 *.*`
62           do
63             envsubst <${PFILE} >/config/${PFILE}
64             chmod 0755 /config/${PFILE}
65           done
66         env:
67           - name: PORTAL_DB_USER
68             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "portal-backend-db" "key" "login") | indent 12 }}
69           - name: PORTAL_DB_PASSWORD
70             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "portal-backend-db" "key" "password") | indent 12 }}
71           - name: WIDGET_USER
72             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "portal-widget" "key" "login") | indent 12 }}
73           - name: WIDGET_PASSWORD
74             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "portal-widget" "key" "password") | indent 12 }}
75           - name: ACC_USER
76             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "portal-account" "key" "login") | indent 12 }}
77           - name: ACC_PASSWORD
78             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "portal-account" "key" "password") | indent 12 }}
79           - name: JASYPT_ENC_KEY
80             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "jasypt-enc-key" "key" "password") | indent 12 }}
81         volumeMounts:
82         - mountPath: /config-input
83           name: properties-onapwidgetms-scrubbed
84         - mountPath: /config
85           name: properties-onapwidgetms
86       containers:
87       - name: {{ include "common.name" . }}
88         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
89         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
90         command:
91           - /start-wms.sh
92         ports:
93         - containerPort: {{ .Values.service.internalPort }}
94         {{- if eq .Values.liveness.enabled true }}
95         livenessProbe:
96           tcpSocket:
97             port: {{ .Values.service.internalPort }}
98           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
99           periodSeconds: {{ .Values.liveness.periodSeconds }}
100         {{ end -}}
101         readinessProbe:
102           tcpSocket:
103             port: {{ .Values.service.internalPort }}
104           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
105           periodSeconds: {{ .Values.readiness.periodSeconds }}
106         volumeMounts:
107         - mountPath: /etc/localtime
108           name: localtime
109           readOnly: true
110         - name: properties-onapwidgetms
111           mountPath: "/application.properties"
112           subPath: application.properties
113         - name: properties-onapwidgetms
114           mountPath: "/application.yml"
115           subPath: application.yml
116         resources:
117 {{ include "common.resources" . | indent 12 }}
118       {{- if .Values.nodeSelector }}
119       nodeSelector:
120 {{ toYaml .Values.nodeSelector | indent 10 }}
121       {{- end -}}
122       {{- if .Values.affinity }}
123       affinity:
124 {{ toYaml .Values.affinity | indent 10 }}
125       {{- end }}
126       volumes:
127         - name: localtime
128           hostPath:
129             path: /etc/localtime
130         - name: properties-onapwidgetms
131           emptyDir:
132             medium: Memory
133         - name: properties-onapwidgetms-scrubbed
134           configMap:
135             name: {{ include "common.fullname" . }}-onapwidgetms
136             defaultMode: 0755
137       imagePullSecrets:
138       - name: "{{ include "common.namespace" . }}-docker-registry-key"