[GENERAL] Use readiness container v3.0.1
[oom.git] / kubernetes / oof / charts / oof-has / charts / oof-has-reservation / templates / deployment.yaml
1 # Copyright © 2017 Amdocs, Bell Canada
2 # Modifications Copyright © 2018 AT&T,VMware
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 apiVersion: apps/v1
17 kind: Deployment
18 metadata:
19   name: {{ include "common.fullname" . }}
20   namespace: {{ include "common.namespace" . }}
21   labels:
22     app: {{ include "common.name" . }}
23     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
24     release: {{ include "common.release" . }}
25     heritage: {{ .Release.Service }}
26 spec:
27   selector:
28     matchLabels:
29       app: {{ include "common.name" . }}
30   replicas: {{ .Values.replicaCount }}
31   template:
32     metadata:
33       labels:
34         app: {{ include "common.name" . }}
35         release: {{ include "common.release" . }}
36     spec:
37       initContainers:
38       - name: {{ include "common.name" . }}-readiness
39         command:
40         - /app/ready.py
41         args:
42         - --container-name
43         - music-springboot
44         env:
45         - name: NAMESPACE
46           valueFrom:
47             fieldRef:
48               apiVersion: v1
49               fieldPath: metadata.namespace
50         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
51         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
52
53       - name: {{ include "common.name" . }}-onboard-readiness
54         command:
55         - /app/ready.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: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
66         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
67
68       - name: {{ include "common.name" . }}-health-readiness
69         command:
70         - /app/ready.py
71         args:
72         - -j
73         - "{{ include "common.release" . }}-oof-has-healthcheck"
74         env:
75         - name: NAMESPACE
76           valueFrom:
77             fieldRef:
78               apiVersion: v1
79               fieldPath: metadata.namespace
80         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
81         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
82
83       - name: {{ include "common.name" . }}-resrv-sms-readiness
84         command:
85         - sh
86         - -c
87         - resp="FAILURE";
88           until [ $resp = "200" ]; do
89           resp=$(curl -s -o /dev/null -k --write-out %{http_code} https://aaf-sms.{{ include "common.namespace" .}}:10443/v1/sms/domain/has/secret);
90           echo $resp;
91           sleep 2;
92           done
93         env:
94         - name: NAMESPACE
95           valueFrom:
96             fieldRef:
97               apiVersion: v1
98               fieldPath: metadata.namespace
99         image: "{{ .Values.global.dockerHubRepository }}/{{ .Values.global.curlImage }}"
100         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
101
102       containers:
103         - name: {{ include "common.name" . }}
104           image: "{{ include "common.repository" . }}/{{ .Values.global.image.optf_has }}"
105           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
106           command:
107           - python
108           args:
109           - /usr/local/bin/conductor-reservation
110           - --config-file=/usr/local/bin/conductor.conf
111           # disable liveness probe when breakpoints set in debugger
112           # so K8s doesn't restart unresponsive container
113           {{- if .Values.liveness.enabled }}
114           livenessProbe:
115             exec:
116               command:
117               - cat
118               - /usr/local/bin/healthy.sh
119             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
120             periodSeconds: {{ .Values.liveness.periodSeconds }}
121           readinessProbe:
122             exec:
123               command:
124               - cat
125               - /usr/local/bin/healthy.sh
126             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
127             periodSeconds: {{ .Values.readiness.periodSeconds }}
128           {{ end -}}
129           env:
130           volumeMounts:
131           - mountPath: /etc/localtime
132             name: localtime
133             readOnly: true
134           - mountPath: /usr/local/bin/conductor.conf
135             name: {{ .Values.global.commonConfigPrefix }}-config
136             subPath: conductor.conf
137           - mountPath: /usr/local/bin/log.conf
138             name: {{ .Values.global.commonConfigPrefix }}-config
139             subPath: log.conf
140           - mountPath: /usr/local/bin/healthy.sh
141             name: {{ .Values.global.commonConfigPrefix }}-config
142             subPath: healthy.sh
143           - mountPath: /usr/local/bin/AAF_RootCA.cer
144             name: {{ .Values.global.commonConfigPrefix }}-config
145             subPath: AAF_RootCA.cer
146           resources:
147 {{ include "common.resources" . | indent 12 }}
148         {{- if .Values.nodeSelector }}
149         nodeSelector:
150 {{ toYaml .Values.nodeSelector | indent 10 }}
151         {{- end -}}
152         {{- if .Values.affinity }}
153         affinity:
154 {{ toYaml .Values.affinity | indent 10 }}
155         {{- end }}
156       volumes:
157         - name: localtime
158           hostPath:
159             path: /etc/localtime
160         - name: {{ .Values.global.commonConfigPrefix }}-config
161           configMap:
162             name: {{ .Values.global.commonConfigPrefix }}-configmap
163             items:
164             - key: conductor.conf
165               path: conductor.conf
166             - key: log.conf
167               path: log.conf
168             - key: healthy.sh
169               path: healthy.sh
170             - key: AAF_RootCA.cer
171               path: AAF_RootCA.cer
172
173       imagePullSecrets:
174       - name: "{{ include "common.namespace" . }}-docker-registry-key"