[GENERAL] Use readiness container v3.0.1
[oom.git] / kubernetes / oof / charts / oof-has / charts / oof-has-api / templates / deployment.yaml
1 # Copyright © 2017 Amdocs, Bell Canada
2 # Copyright (C) 2020 Wipro Limited.
3 # Modifications Copyright © 2018 AT&T,VMware
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 apiVersion: apps/v1
18 kind: Deployment
19 metadata:
20   name: {{ include "common.fullname" . }}
21   namespace: {{ include "common.namespace" . }}
22   labels:
23     app: {{ include "common.name" . }}
24     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
25     release: {{ include "common.release" . }}
26     heritage: {{ .Release.Service }}
27 spec:
28   selector:
29     matchLabels:
30       app: {{ include "common.name" . }}
31   replicas: {{ .Values.replicaCount }}
32   template:
33     metadata:
34       labels:
35         app: {{ include "common.name" . }}
36         release: {{ include "common.release" . }}
37     spec:
38       initContainers:
39       - name: {{ include "common.name" . }}-readiness
40         command:
41         - /app/ready.py
42         args:
43         - --container-name
44         - oof-has-controller
45         - --container-name
46         - aaf-service
47         env:
48         - name: NAMESPACE
49           valueFrom:
50             fieldRef:
51               apiVersion: v1
52               fieldPath: metadata.namespace
53         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
54         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
55
56       - name: {{ include "common.name" . }}-onboard-readiness
57         command:
58         - /app/ready.py
59         args:
60         - -j
61         - "{{ include "common.release" . }}-oof-has-onboard"
62         env:
63         - name: NAMESPACE
64           valueFrom:
65             fieldRef:
66               apiVersion: v1
67               fieldPath: metadata.namespace
68         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
69         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
70
71       - name: {{ include "common.name" . }}-has-sms-readiness
72         command:
73         - sh
74         - -c
75         - resp="FAILURE";
76           until [ $resp = "200" ]; do
77           resp=$(curl -s -o /dev/null -k --write-out %{http_code} https://aaf-sms.{{ include "common.namespace" . }}:10443/v1/sms/domain/has/secret);
78           echo $resp;
79           sleep 2;
80           done
81         env:
82         - name: NAMESPACE
83           valueFrom:
84             fieldRef:
85               apiVersion: v1
86               fieldPath: metadata.namespace
87         image: "{{ .Values.global.dockerHubRepository }}/{{ .Values.global.curlImage }}"
88         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
89
90       containers:
91         - name: {{ include "common.name" . }}
92           image: "{{ include "common.repository" . }}/{{ .Values.global.image.optf_has }}"
93           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
94           command: ["/bin/bash","-c"]
95           args: ["/usr/local/bin/uwsgi -s /run/conductor/uwsgi.sock --chmod-socket=777 --wsgi-file /etc/nginx/conductor.wsgi --callable application --set port={{ .Values.uwsgi.internalPort }} --die-on-term --exit-on-reload --logto /var/log/conductor/conductor-uwsgi.log --pidfile /run/conductor/conductor-uwsgi.pid --enable-threads --workers 6 --master --vacuum --single-interpreter --socket-timeout 10 --max-worker-lifetime 300 --max-requests 100 --no-defer-accept --logfile-chown --logfile-chmod 664 --protocol=uwsgi --socket 0.0.0.0:{{ .Values.uwsgi.internalPort }}"]
96           ports:
97           - containerPort: {{ .Values.uwsgi.internalPort }}
98           # disable liveness probe when breakpoints set in debugger
99           # so K8s doesn't restart unresponsive container
100           {{- if .Values.liveness.enabled }}
101           livenessProbe:
102             tcpSocket:
103               port: {{ .Values.uwsgi.internalPort }}
104             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
105             periodSeconds: {{ .Values.liveness.periodSeconds }}
106           {{ end -}}
107           readinessProbe:
108             tcpSocket:
109               port: {{ .Values.uwsgi.internalPort }}
110             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
111             periodSeconds: {{ .Values.readiness.periodSeconds }}
112           env:
113           volumeMounts:
114           - mountPath: /etc/localtime
115             name: localtime
116             readOnly: true
117           - mountPath: /usr/local/etc/conductor/conductor.conf
118             name: {{ .Values.global.commonConfigPrefix }}-config
119             subPath: conductor.conf
120           - mountPath: /usr/local/bin/log.conf
121             name: {{ .Values.global.commonConfigPrefix  }}-config
122             subPath: log.conf
123           - mountPath: /usr/local/bin/AAF_RootCA.cer
124             name: {{ .Values.global.commonConfigPrefix }}-config
125             subPath: AAF_RootCA.cer
126           resources:
127 {{ include "common.resources" . | indent 12 }}
128         - name: {{ include "common.name" . }}-nginx
129           image: "{{ .Values.global.dockerHubRepository }}/{{ .Values.nginx.image }}"
130           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
131           ports:
132           - containerPort: {{ .Values.service.internalPort }}
133           {{- if .Values.liveness.enabled }}
134           livenessProbe:
135             tcpSocket:
136               port: {{ .Values.service.internalPort }}
137             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
138             periodSeconds: {{ .Values.liveness.periodSeconds }}
139           {{ end -}}
140           readinessProbe:
141             tcpSocket:
142               port: {{ .Values.service.internalPort }}
143             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
144             periodSeconds: {{ .Values.readiness.periodSeconds }}
145           volumeMounts:
146           - mountPath: /etc/localtime
147             name: localtime
148             readOnly: true
149           - mountPath: /opt/bitnami/nginx/conf/nginx.conf
150             name: {{ .Values.global.commonConfigPrefix  }}-config
151             subPath: nginx.conf
152           - mountPath: /opt/bitnami/nginx/ssl/org.onap.oof.crt
153             name: {{ .Values.global.commonConfigPrefix }}-config
154             subPath: org.onap.oof.crt
155           - mountPath: /opt/bitnami/nginx/ssl/org.onap.oof.key
156             name: {{ .Values.global.commonConfigPrefix }}-config
157             subPath: org.onap.oof.key
158           resources:
159 {{ include "common.resources" . | indent 12 }}
160         {{- if .Values.nodeSelector }}
161         nodeSelector:
162 {{ toYaml .Values.nodeSelector | indent 10 }}
163         {{- end -}}
164         {{- if .Values.affinity }}
165         affinity:
166 {{ toYaml .Values.affinity | indent 10 }}
167         {{- end }}
168       volumes:
169         - name: localtime
170           hostPath:
171             path: /etc/localtime
172         - name: {{ .Values.global.commonConfigPrefix }}-config
173           configMap:
174             name: {{ .Values.global.commonConfigPrefix  }}-configmap
175             items:
176             - key: nginx.conf
177               path: nginx.conf
178             - key: conductor.conf
179               path: conductor.conf
180             - key: log.conf
181               path: log.conf
182             - key: AAF_RootCA.cer
183               path: AAF_RootCA.cer
184             - key: org.onap.oof.key
185               path: org.onap.oof.key
186             - key: org.onap.oof.crt
187               path: org.onap.oof.crt
188       imagePullSecrets:
189       - name: "{{ include "common.namespace" . }}-docker-registry-key"