Merge "Add Standardized Configuration to SDN-C Chart"
[oom.git] / kubernetes / sdc / charts / sdc-be / templates / deployment.yaml
1 # Copyright © 2017 Amdocs, AT&T, Bell Canada
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 apiVersion: extensions/v1beta1
16 kind: Deployment
17 metadata:
18   name: {{ include "common.fullname" . }}
19   namespace: {{ include "common.namespace" . }}
20   labels:
21     app: {{ include "common.name" . }}
22     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
23     release: {{ .Release.Name }}
24     heritage: {{ .Release.Service }}
25 spec:
26   replicas: {{ .Values.replicaCount }}
27   template:
28     metadata:
29       labels:
30         app: {{ include "common.name" . }}
31         release: {{ .Release.Name }}
32     spec:
33       initContainers:
34       - name: {{ include "common.name" . }}-readiness
35         command:
36         - /root/ready.py
37         args:
38         - --container-name
39         - "sdc-es"
40         - --container-name
41         - "sdc-cs"
42         env:
43         - name: NAMESPACE
44           valueFrom:
45             fieldRef:
46               apiVersion: v1
47               fieldPath: metadata.namespace
48         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
49         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
50       - name: {{ include "common.name" . }}-job-completion
51         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
52         imagePullPolicy: "{{ .Values.global.pullPolicy | default .Values.pullPolicy }}"
53         command:
54         - /root/job_complete.py
55         args:
56         - --job-name
57         - {{ .Release.Name }}-sdc-cs-config-cassandra
58         env:
59         - name: NAMESPACE
60           valueFrom:
61             fieldRef:
62               apiVersion: v1
63               fieldPath: metadata.namespace
64       containers:
65         - name: {{ include "common.name" . }}
66           image: "{{ .Values.global.repository | default .Values.repository }}/{{ .Values.image }}"
67           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
68           ports:
69           - containerPort: {{ .Values.service.internalPort }}
70           - containerPort: {{ .Values.service.internalPort2 }}
71           # disable liveness probe when breakpoints set in debugger
72           # so K8s doesn't restart unresponsive container
73           {{- if eq .Values.liveness.enabled true }}
74           livenessProbe:
75             tcpSocket:
76               port: {{ .Values.service.internalPort }}
77             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
78             periodSeconds: {{ .Values.liveness.periodSeconds }}
79           {{ end -}}
80           readinessProbe:
81             tcpSocket:
82               port: {{ .Values.service.internalPort }}
83             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
84             periodSeconds: {{ .Values.readiness.periodSeconds }}
85           env:
86           - name: ENVNAME
87             value: {{ .Values.global.env.name }}
88           - name: JAVA_OPTIONS
89             value: ""
90           - name: HOST_IP
91             valueFrom:
92               fieldRef:
93                 fieldPath: status.podIP
94           volumeMounts:
95           - name: {{ include "common.fullname" . }}-environments
96             mountPath: /root/chef-solo/environments/
97           - name: {{ include "common.fullname" . }}-localtime
98             mountPath: /etc/localtime
99             readOnly: true
100           - name: {{ include "common.fullname" . }}-logs
101             mountPath: /var/log/onap
102           - name: {{ include "common.fullname" . }}-logback
103             mountPath: /tmp/logback.xml
104           lifecycle:
105             postStart:
106               exec:
107                 command: ["/bin/sh", "-c", "export LOG=wait_logback.log; touch $LOG; export SRC=/tmp/logback.xml; export DST=/var/lib/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"]
108           resources:
109 {{ toYaml .Values.resources | indent 12 }}
110         {{- if .Values.nodeSelector }}
111         nodeSelector:
112 {{ toYaml .Values.nodeSelector | indent 10 }}
113         {{- end -}}
114         {{- if .Values.affinity }}
115         affinity:
116 {{ toYaml .Values.affinity | indent 10 }}
117         {{- end }}
118
119         # side car containers
120         - name: {{ include "common.name" . }}-filebeat-onap
121           image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
122           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
123           volumeMounts:
124           - name: {{ include "common.fullname" . }}-filebeat-conf
125             mountPath: /usr/share/filebeat/filebeat.yml
126             subPath: filebeat.yml
127           - name: {{ include "common.fullname" . }}-logs
128             mountPath: /var/log/onap
129           - name: {{ include "common.fullname" . }}-data-filebeat
130             mountPath: /usr/share/filebeat/data
131       volumes:
132         - name: {{ include "common.fullname" . }}-localtime
133           hostPath:
134             path: /etc/localtime
135         - name: {{ include "common.fullname" . }}-filebeat-conf
136           configMap:
137            name: {{ .Release.Name }}-sdc-filebeat-configmap
138         - name: {{ include "common.fullname" . }}-data-filebeat
139           emptyDir: {}
140         - name: {{ include "common.fullname" . }}-logback
141           configMap:
142             name : {{ include "common.fullname" . }}-logging-configmap
143         - name: {{ include "common.fullname" . }}-environments
144           configMap:
145             name: {{ .Release.Name }}-sdc-environments-configmap
146             defaultMode: 0755
147         - name:  {{ include "common.fullname" . }}-logs
148           emptyDir: {}
149       imagePullSecrets:
150       - name: "{{ include "common.namespace" . }}-docker-registry-key"