7e0a88f94db315e1abde017c50165a0d877e5fdc
[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: extensions/v1beta1
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   replicas: {{ .Values.replicaCount }}
29   template:
30     metadata:
31       labels:
32         app: {{ include "common.name" . }}
33         release: {{ include "common.release" . }}
34     spec:
35       initContainers:
36       - name: {{ include "common.name" . }}-readiness
37         command:
38         - /root/ready.py
39         args:
40         - --container-name
41         - oof-has-controller
42         - --container-name
43         - aaf-service
44         env:
45         - name: NAMESPACE
46           valueFrom:
47             fieldRef:
48               apiVersion: v1
49               fieldPath: metadata.namespace
50         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
51         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
52
53       - name: {{ include "common.name" . }}-onboard-readiness
54         command:
55         - /root/job_complete.py
56         args:
57         - -j
58         - "{{ include "common.release" . }}-oof-has-onboard"
59         env:
60         - name: NAMESPACE
61           valueFrom:
62             fieldRef:
63               apiVersion: v1
64               fieldPath: metadata.namespace
65         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
66         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
67
68       - name: {{ include "common.name" . }}-has-sms-readiness
69         command:
70         - sh
71         - -c
72         - resp="FAILURE";
73           until [ $resp = "200" ]; do
74           resp=$(curl -s -o /dev/null -k --write-out %{http_code} https://aaf-sms.{{ include "common.namespace" . }}:10443/v1/sms/domain/has/secret);
75           echo $resp;
76           sleep 2;
77           done
78         env:
79         - name: NAMESPACE
80           valueFrom:
81             fieldRef:
82               apiVersion: v1
83               fieldPath: metadata.namespace
84         image: "{{ .Values.global.dockerHubRepository }}/{{ .Values.global.curlImage }}"
85         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
86
87       containers:
88         - name: {{ include "common.name" . }}
89           image: "{{ include "common.repository" . }}/{{ .Values.global.image.optf_has }}"
90           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
91           command: ["/bin/bash","-c"]
92           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 }}"]
93           ports:
94           - containerPort: {{ .Values.uwsgi.internalPort }}
95           # disable liveness probe when breakpoints set in debugger
96           # so K8s doesn't restart unresponsive container
97           {{- if .Values.liveness.enabled }}
98           livenessProbe:
99             tcpSocket:
100               port: {{ .Values.uwsgi.internalPort }}
101             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
102             periodSeconds: {{ .Values.liveness.periodSeconds }}
103           {{ end -}}
104           readinessProbe:
105             tcpSocket:
106               port: {{ .Values.uwsgi.internalPort }}
107             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
108             periodSeconds: {{ .Values.readiness.periodSeconds }}
109           env:
110           volumeMounts:
111           - mountPath: /etc/localtime
112             name: localtime
113             readOnly: true
114           - mountPath: /usr/local/etc/conductor/conductor.conf
115             name: {{ .Values.global.commonConfigPrefix }}-config
116             subPath: conductor.conf
117           - mountPath: /usr/local/bin/log.conf
118             name: {{ .Values.global.commonConfigPrefix  }}-config
119             subPath: log.conf
120           - mountPath: /usr/local/bin/AAF_RootCA.cer
121             name: {{ .Values.global.commonConfigPrefix }}-config
122             subPath: AAF_RootCA.cer
123           resources:
124 {{ include "common.resources" . | indent 12 }}
125         - name: {{ include "common.name" . }}-nginx
126           image: "{{ .Values.global.dockerHubRepository }}/{{ .Values.nginx.image }}"
127           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
128           ports:
129           - containerPort: {{ .Values.service.internalPort }}
130           {{- if .Values.liveness.enabled }}
131           livenessProbe:
132             tcpSocket:
133               port: {{ .Values.service.internalPort }}
134             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
135             periodSeconds: {{ .Values.liveness.periodSeconds }}
136           {{ end -}}
137           readinessProbe:
138             tcpSocket:
139               port: {{ .Values.service.internalPort }}
140             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
141             periodSeconds: {{ .Values.readiness.periodSeconds }}
142           volumeMounts:
143           - mountPath: /etc/localtime
144             name: localtime
145             readOnly: true
146           - mountPath: /opt/bitnami/nginx/conf/nginx.conf
147             name: {{ .Values.global.commonConfigPrefix  }}-config
148             subPath: nginx.conf
149           - mountPath: /opt/bitnami/nginx/ssl/org.onap.oof.crt
150             name: {{ .Values.global.commonConfigPrefix }}-config
151             subPath: org.onap.oof.crt
152           - mountPath: /opt/bitnami/nginx/ssl/org.onap.oof.key
153             name: {{ .Values.global.commonConfigPrefix }}-config
154             subPath: org.onap.oof.key
155           resources:
156 {{ include "common.resources" . | indent 12 }}
157         {{- if .Values.nodeSelector }}
158         nodeSelector:
159 {{ toYaml .Values.nodeSelector | indent 10 }}
160         {{- end -}}
161         {{- if .Values.affinity }}
162         affinity:
163 {{ toYaml .Values.affinity | indent 10 }}
164         {{- end }}
165       volumes:
166         - name: localtime
167           hostPath:
168             path: /etc/localtime
169         - name: {{ .Values.global.commonConfigPrefix }}-config
170           configMap:
171             name: {{ .Values.global.commonConfigPrefix  }}-configmap
172             items:
173             - key: nginx.conf
174               path: nginx.conf
175             - key: conductor.conf
176               path: conductor.conf
177             - key: log.conf
178               path: log.conf
179             - key: AAF_RootCA.cer
180               path: AAF_RootCA.cer
181             - key: org.onap.oof.key
182               path: org.onap.oof.key
183             - key: org.onap.oof.crt
184               path: org.onap.oof.crt
185       imagePullSecrets:
186       - name: "{{ include "common.namespace" . }}-docker-registry-key"