Merge "[DMAAP] DMaaP ServiceMesh compatibility"
[oom.git] / kubernetes / contrib / components / awx / templates / statefulset.yaml
1 {{/*
2 # Copyright © 2019 Bell Canada
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
17 apiVersion: apps/v1
18 kind: StatefulSet
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   podManagementPolicy: OrderedReady
29   replicas: {{ .Values.replicaCount }}
30   serviceName: {{ include "common.fullname" . }}
31   selector:
32     matchLabels:
33       app: {{ include "common.fullname" . }}
34       name: {{ include "common.name" . }}-web-deploy
35       service: django
36   template:
37     metadata:
38       labels:
39         app: {{ include "common.fullname" . }}
40         name: {{ include "common.name" . }}-web-deploy
41         release: {{ include "common.release" . }}
42         service: django
43     spec:
44
45       initContainers:
46       - name: {{ include "common.name" . }}-init-readiness
47         image: {{ include "repositoryGenerator.image.readiness" . }}
48         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
49         command:
50         - /app/ready.py
51         args:
52         - --container-name
53         - {{ include "common.name" . }}-mgnt
54         env:
55         - name: NAMESPACE
56           valueFrom:
57             fieldRef:
58               apiVersion: v1
59               fieldPath: metadata.namespace
60
61       containers:
62
63       - image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image.web }}
64         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
65         name: {{ include "common.name" . }}-web
66         ports:
67         - containerPort: {{ .Values.service.web.internalPort }}
68           protocol: TCP
69         resources:
70           requests:
71             cpu: 500m
72             memory: 1Gi
73         volumeMounts:
74         - mountPath: /etc/tower/settings.py
75           name: awx-application-config
76           readOnly: true
77           subPath: settings.py
78         - mountPath: /etc/tower/conf.d/
79           name: awx-application-credentials
80           readOnly: true
81         - mountPath: /etc/tower/SECRET_KEY
82           name: awx-secret-key
83           readOnly: true
84           subPath: SECRET_KEY
85         - mountPath: /etc/nginx/nginx.conf
86           name: awx-nginx-conf
87           subPath: "nginx.conf"
88
89       - command: ["/bin/sh","-c"]
90         args: ["/usr/bin/launch_awx_task.sh"]
91         env:
92         - name: AWX_SKIP_MIGRATIONS
93           value: "1"
94
95         image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image.task }}
96         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
97         name: {{ include "common.name" . }}-celery
98         resources:
99           requests:
100             cpu: 1500m
101             memory: 2Gi
102         securityContext:
103           privileged: true
104         volumeMounts:
105         - mountPath: /etc/tower/settings.py
106           name: awx-application-config
107           readOnly: true
108           subPath: settings.py
109         - mountPath: /etc/tower/conf.d/
110           name: awx-application-credentials
111           readOnly: true
112         - mountPath: /etc/tower/SECRET_KEY
113           name: awx-secret-key
114           readOnly: true
115           subPath: SECRET_KEY
116         - mountPath: /etc/nginx/nginx.conf
117           name: awx-nginx-conf
118           subPath: "nginx.conf"
119       - env:
120         - name: MY_POD_IP
121           valueFrom:
122             fieldRef:
123               apiVersion: v1
124               fieldPath: status.podIP
125         - name: RABBITMQ_USE_LONGNAME
126           value: "true"
127         - name: RABBITMQ_NODENAME
128           value: rabbit@$(MY_POD_IP)
129         - name: RABBITMQ_ERLANG_COOKIE
130           valueFrom:
131             secretKeyRef:
132               key: rabbitmq_erlang_cookie
133               name: {{ include "common.fullname" . }}-secrets
134         - name: K8S_SERVICE_NAME
135           value: {{ include "common.servicename" . }}-rabbitmq
136
137         image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image.rabbitmq }}
138         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
139         name: {{ include "common.name" . }}-rabbit
140         livenessProbe:
141           exec:
142             command:
143             - rabbitmqctl
144             - status
145           failureThreshold: 3
146           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
147           periodSeconds: {{ .Values.liveness.periodSeconds }}
148           successThreshold: 1
149           timeoutSeconds: 10
150         ports:
151         - containerPort: {{ .Values.service.rabbitmq.http.internalPort }}
152           name: {{ .Values.service.rabbitmq.http.portName }}
153           protocol: TCP
154         - containerPort: {{ .Values.service.rabbitmq.amqp.internalPort }}
155           name: {{ .Values.service.rabbitmq.amqp.portName }}
156           protocol: TCP
157         readinessProbe:
158           exec:
159             command:
160             - rabbitmqctl
161             - status
162           failureThreshold: 3
163           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
164           periodSeconds: {{ .Values.liveness.periodSeconds }}
165           successThreshold: 1
166           timeoutSeconds: 10
167         resources:
168           requests:
169             cpu: 500m
170             memory: 2Gi
171         volumeMounts:
172         - mountPath: /etc/rabbitmq
173           name: rabbitmq-config
174
175       - image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image.memcached }}
176         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
177         name: {{ include "common.name" . }}-memcached
178         resources:
179           requests:
180             cpu: 500m
181             memory: 1Gi
182       serviceAccount: {{ include "common.fullname" . }}
183       serviceAccountName: {{ include "common.fullname" . }}
184       volumes:
185       - configMap:
186           defaultMode: 420
187           items:
188           - key: awx_settings
189             path: settings.py
190           name: {{ include "common.fullname" . }}-settings
191         name: awx-application-config
192       - name: awx-application-credentials
193         secret:
194           defaultMode: 420
195           items:
196           - key: credentials_py
197             path: credentials.py
198           - key: environment_sh
199             path: environment.sh
200           secretName: {{ include "common.fullname" . }}-secrets
201       - name: awx-secret-key
202         secret:
203           defaultMode: 420
204           items:
205           - key: secret_key
206             path: SECRET_KEY
207           secretName: {{ include "common.fullname" . }}-secrets
208       - configMap:
209           defaultMode: 420
210           items:
211           - key: rabbitmq.conf
212             path: rabbitmq.conf
213           - key: enabled_plugins
214             path: enabled_plugins
215           - key: rabbitmq_definitions.json
216             path: rabbitmq_definitions.json
217           name: {{ include "common.fullname" . }}-rabbitmq
218         name: rabbitmq-config
219       - configMap:
220           defaultMode: 420
221           items:
222           - key: nginx.conf
223             path: nginx.conf
224           name: {{ include "common.fullname" . }}-nginx-conf
225         name: awx-nginx-conf
226       imagePullSecrets:
227       - name: "{{ include "common.namespace" . }}-docker-registry-key"