d6ea50e84e8f5db747a4276ca0e213b530158b46
[oom.git] / kubernetes / sdc / components / sdc-be / templates / deployment.yaml
1 {{/*
2 # Copyright © 2017 Amdocs, AT&T, Bell Canada
3 # Modifications Copyright © 2018 ZTE
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: {{- include "common.resourceMetadata" . | nindent 2 }}
21 spec:
22   selector: {{- include "common.selectors" . | nindent 4 }}
23   replicas: {{ .Values.replicaCount }}
24   template:
25     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
26     spec:
27       initContainers:
28       - name: {{ include "common.name" . }}-readiness
29         command:
30         - /app/ready.py
31         args:
32         - --container-name
33         - "sdc-onboarding-be"
34         {{- if not .Values.global.kafka.useKafka }}
35         - --container-name
36         - "message-router"
37         {{- end }}
38         env:
39         - name: NAMESPACE
40           valueFrom:
41             fieldRef:
42               apiVersion: v1
43               fieldPath: metadata.namespace
44         image: {{ include "repositoryGenerator.image.readiness" . }}
45         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
46         resources:
47           limits:
48             cpu: 100m
49             memory: 100Mi
50           requests:
51             cpu: 3m
52             memory: 20Mi
53       - name: {{ include "common.name" . }}-job-completion
54         image: {{ include "repositoryGenerator.image.readiness" . }}
55         imagePullPolicy: "{{ .Values.global.pullPolicy | default .Values.pullPolicy }}"
56         command:
57         - /app/ready.py
58         args:
59         - --job-name
60         - {{ include "common.release" . }}-sdc-onboarding-be
61         env:
62         - name: NAMESPACE
63           valueFrom:
64             fieldRef:
65               apiVersion: v1
66               fieldPath: metadata.namespace
67         resources:
68           limits:
69             cpu: 100m
70             memory: 100Mi
71           requests:
72             cpu: 3m
73             memory: 20Mi
74       containers:
75         - name: {{ include "common.name" . }}
76           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
77           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
78           ports: {{ include "common.containerPorts" . | nindent 12  }}
79           {{ if eq .Values.liveness.enabled true }}
80           livenessProbe:
81             httpGet:
82               path: /sdc2/rest/healthCheck
83               port: {{ .Values.service.internalPort }}
84             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
85             periodSeconds: {{ .Values.liveness.periodSeconds }}
86             timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
87             successThreshold: {{ .Values.liveness.successThreshold }}
88             failureThreshold: {{ .Values.liveness.failureThreshold }}
89           {{ end }}
90           readinessProbe:
91             httpGet:
92               path: /sdc2/rest/healthCheck
93               port: {{ .Values.service.internalPort }}
94             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
95             periodSeconds: {{ .Values.readiness.periodSeconds }}
96             timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
97             successThreshold: {{ .Values.readiness.successThreshold }}
98             failureThreshold: {{ .Values.readiness.failureThreshold }}
99           resources: {{ include "common.resources" . | nindent 12 }}
100           startupProbe:
101             httpGet:
102               path: /sdc2/rest/healthCheck
103               port: {{ .Values.service.internalPort }}
104             initialDelaySeconds: {{ .Values.startup.initialDelaySeconds }}
105             periodSeconds: {{ .Values.startup.periodSeconds }}
106             timeoutSeconds: {{ .Values.startup.timeoutSeconds }}
107             successThreshold: {{ .Values.startup.successThreshold }}
108             failureThreshold: {{ .Values.startup.failureThreshold }}
109           resources: {{ include "common.resources" . | nindent 12 }}
110           env:
111           - name: ENVNAME
112             value: {{ .Values.env.name }}
113           - name: JAVA_OPTIONS
114             value: {{ .Values.config.javaOptions }}
115           - name: cassandra_ssl_enabled
116             value: {{ .Values.config.cassandraSslEnabled | quote }}
117           - name: HOST_IP
118             valueFrom:
119               fieldRef:
120                 fieldPath: status.podIP
121           {{- if .Values.global.kafka.useKafka }}
122           - name: SASL_JAAS_CONFIG
123             valueFrom:
124               secretKeyRef:
125                 name: {{ include "common.name" . }}-ku
126                 key: sasl.jaas.config
127           - name: USE_KAFKA
128             value: {{ .Values.global.kafka.useKafka | quote }}
129           {{- end }}
130           volumeMounts:
131           - name: sdc-environments
132             mountPath: /app/jetty/chef-solo/environments/
133           - name: localtime
134             mountPath: /etc/localtime
135             readOnly: true
136           - name: logs
137             mountPath: /var/log/onap
138           - name: logback
139             mountPath: /tmp/logback.xml
140             subPath: logback.xml
141           lifecycle:
142             postStart:
143               exec:
144                 command: ["/bin/sh", "-c", "export LOG=wait_logback.log; touch $LOG; export SRC=/tmp/logback.xml; export DST=/app/jetty/config/catalog-be/; while [ ! -e $DST ]; do echo 'Waiting for $DST...' >> $LOG; sleep 5; done; sleep 2; /bin/cp -f $SRC $DST; echo 'Done' >> $LOG"]
145         # side car containers
146         {{ include "common.log.sidecar" . | nindent 8 }}
147       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
148       volumes:
149       - name: localtime
150         hostPath:
151           path: /etc/localtime
152       {{ include "common.log.volumes" (dict "dot" . "configMapNamePrefix" (tpl .Values.logConfigMapNamePrefix .)) | nindent 6 }}
153       - name: logback
154         configMap:
155           name : {{ include "common.fullname" . }}-logging-configmap
156       - name: sdc-environments
157         configMap:
158           name: {{ include "common.release" . }}-sdc-environments-configmap
159           defaultMode: 0755
160       - name: logs
161         emptyDir: {}
162       imagePullSecrets:
163       - name: "{{ include "common.namespace" . }}-docker-registry-key"