[CONSUL] Add limits to consul chart.
[oom.git] / kubernetes / oof / components / oof-has / components / 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 {{ include "common.certInitializer.initContainer" . | indent 6 }}
90
91       containers:
92         - name: {{ include "common.name" . }}
93           image: "{{ include "common.repository" . }}/{{ .Values.global.image.optf_has }}"
94           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
95           command: ["/bin/bash","-c"]
96           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 --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 --protocol=uwsgi --socket 0.0.0.0:{{ .Values.uwsgi.internalPort }}"]
97           ports:
98           - containerPort: {{ .Values.uwsgi.internalPort }}
99           # disable liveness probe when breakpoints set in debugger
100           # so K8s doesn't restart unresponsive container
101           {{- if .Values.liveness.enabled }}
102           livenessProbe:
103             tcpSocket:
104               port: {{ .Values.uwsgi.internalPort }}
105             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
106             periodSeconds: {{ .Values.liveness.periodSeconds }}
107           {{ end -}}
108           readinessProbe:
109             tcpSocket:
110               port: {{ .Values.uwsgi.internalPort }}
111             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
112             periodSeconds: {{ .Values.readiness.periodSeconds }}
113           env:
114           volumeMounts:
115           - mountPath: /etc/localtime
116             name: localtime
117             readOnly: true
118           - mountPath: /usr/local/etc/conductor/conductor.conf
119             name: {{ .Values.global.commonConfigPrefix }}-config
120             subPath: conductor.conf
121           - mountPath: /usr/local/bin/log.conf
122             name: {{ .Values.global.commonConfigPrefix  }}-config
123             subPath: log.conf
124           - mountPath: /usr/local/bin/AAF_RootCA.cer
125             name: {{ .Values.global.commonConfigPrefix }}-config
126             subPath: AAF_RootCA.cer
127           resources:
128 {{ include "common.resources" . | indent 12 }}
129         - name: {{ include "common.name" . }}-nginx
130           image: "{{ .Values.global.dockerHubRepository }}/{{ .Values.nginx.image }}"
131           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
132           ports:
133           - containerPort: {{ .Values.service.internalPort }}
134           {{- if .Values.liveness.enabled }}
135           livenessProbe:
136             tcpSocket:
137               port: {{ .Values.service.internalPort }}
138             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
139             periodSeconds: {{ .Values.liveness.periodSeconds }}
140           {{ end -}}
141           readinessProbe:
142             tcpSocket:
143               port: {{ .Values.service.internalPort }}
144             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
145             periodSeconds: {{ .Values.readiness.periodSeconds }}
146           volumeMounts:
147 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
148           - mountPath: /etc/localtime
149             name: localtime
150             readOnly: true
151           - mountPath: /opt/bitnami/nginx/conf/nginx.conf
152             name: {{ .Values.global.commonConfigPrefix  }}-config
153             subPath: nginx.conf
154           resources:
155 {{ include "common.resources" . | indent 12 }}
156         {{- if .Values.nodeSelector }}
157         nodeSelector:
158 {{ toYaml .Values.nodeSelector | indent 10 }}
159         {{- end -}}
160         {{- if .Values.affinity }}
161         affinity:
162 {{ toYaml .Values.affinity | indent 10 }}
163         {{- end }}
164       volumes:
165         {{ include "common.certInitializer.volumes" . | nindent 8 }}
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       imagePullSecrets:
182       - name: "{{ include "common.namespace" . }}-docker-registry-key"