Merge "[DMAAP] DMaaP ServiceMesh compatibility"
[oom.git] / kubernetes / portal / components / portal-mariadb / templates / deployment.yaml
1 {{/*
2 # Copyright © 2017 Amdocs, Bell Canada
3 # Modifications Copyright © 2018 AT&T
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
18 apiVersion: apps/v1
19 kind: Deployment
20 metadata:
21   name: {{ include "common.fullname" . }}
22   namespace: {{ include "common.namespace" . }}
23   labels:
24     app: {{ include "common.name" . }}
25     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
26     release: {{ include "common.release" . }}
27     heritage: {{ .Release.Service }}
28 spec:
29   selector:
30     matchLabels:
31       app: {{ include "common.name" . }}
32   replicas: {{ .Values.replicaCount }}
33   template:
34     metadata:
35       labels:
36         app: {{ include "common.name" . }}
37         release: {{ include "common.release" . }}
38     spec:
39       initContainers:
40       - name: volume-permissions
41         image: {{ include "repositoryGenerator.image.busybox" . }}
42         command: ['sh', '-c', 'chmod -R 777 /var/lib/mysql']
43         volumeMounts:
44         - mountPath: /var/lib/mysql
45           name: mariadb-data
46       containers:
47         - name: {{ include "common.name" . }}
48           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
49           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
50           ports:
51           - containerPort: {{ .Values.service.internalPort }}
52           # disable liveness probe when breakpoints set in debugger
53           # so K8s doesn't restart unresponsive container
54           {{- if eq .Values.liveness.enabled true }}
55           livenessProbe:
56             tcpSocket:
57               port: {{ .Values.service.internalPort }}
58             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
59             periodSeconds: {{ .Values.liveness.periodSeconds }}
60           {{end -}}
61           readinessProbe:
62             tcpSocket:
63               port: {{ .Values.service.internalPort }}
64             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
65             periodSeconds: {{ .Values.readiness.periodSeconds }}
66           env:
67             - name: MYSQL_HOST
68               value: "{{ include "common.servicename" . }}"
69             - name: MYSQL_ROOT_PASSWORD
70               valueFrom:
71                 secretKeyRef:
72                   name: {{ template "common.fullname" . }}
73                   key: db-root-password
74             - name: MYSQL_USER
75               valueFrom:
76                 secretKeyRef:
77                   name: {{ template "common.fullname" . }}
78                   key: backend-db-user
79             - name: MYSQL_PASSWORD
80               valueFrom:
81                 secretKeyRef:
82                   name: {{ template "common.fullname" . }}
83                   key: backend-db-password
84             - name: PORTAL_DB_TABLES
85               value: {{ .Values.config.backend_portal_tables }}
86           volumeMounts:
87           - mountPath: /var/lib/mysql
88             name: mariadb-data
89           - mountPath: /etc/localtime
90             name: localtime
91             readOnly: true
92           - mountPath: /usr/local/bin/docker-entrypoint.sh
93             subPath: docker-entrypoint.sh
94             name: docker-entry
95           resources:
96 {{ include "common.resources" . | indent 12 }}
97         {{- if .Values.nodeSelector }}
98         nodeSelector:
99 {{ toYaml .Values.nodeSelector | indent 10 }}
100         {{- end -}}
101         {{- if .Values.affinity }}
102         affinity:
103 {{ toYaml .Values.affinity | indent 10 }}
104         {{- end }}
105       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
106       volumes:
107       {{- if .Values.persistence.enabled }}
108         - name: mariadb-data
109           persistentVolumeClaim:
110             claimName: {{ include "common.fullname" . }}
111       {{- else }}
112           emptyDir: {}
113       {{- end }}
114         - name: localtime
115           hostPath:
116             path: /etc/localtime
117         - name: docker-entry
118           configMap:
119             name: {{ include "common.fullname" . }}-mariadb
120             defaultMode: 0755
121       imagePullSecrets:
122       - name: "{{ include "common.namespace" . }}-docker-registry-key"