[AAI] Make AAI compatible with Kubernetes v1.17
[aai/oom.git] / templates / deployment.yaml
1 # Copyright © 2018 Amdocs, Bell Canada, AT&T
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
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       name: {{ include "common.release" . }}
37       annotations:
38         checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
39     spec:
40       initContainers:
41       - command:
42         - /root/ready.py
43         args:
44         - --container-name
45         - aai-resources
46         - --container-name
47         - aai-traversal
48         - --container-name
49         - aai-graphadmin
50         env:
51         - name: NAMESPACE
52           valueFrom:
53             fieldRef:
54               apiVersion: v1
55               fieldPath: metadata.namespace
56         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
57         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
58         name: {{ include "common.name" . }}-readiness
59       containers:
60       - name: {{ include "common.name" . }}
61         image: "{{ .Values.global.dockerhubRepository | default .Values.dockerhubRepository }}/{{ .Values.image }}"
62         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
63         volumeMounts:
64         - mountPath: /etc/localtime
65           name: localtime
66           readOnly: true
67         - mountPath: /dev/log
68           name: aai-service-log
69         - mountPath: /usr/local/etc/haproxy/haproxy.cfg
70         {{ if .Values.global.installSidecarSecurity }}
71           subPath: haproxy-pluggable-security.cfg
72         {{ else }}
73           subPath: haproxy.cfg
74         {{ end }}
75           name: haproxy-cfg
76         - mountPath: /etc/ssl/private/aai.pem
77           name: aai-pem
78           subPath: aai.pem
79         ports:
80         - containerPort: {{ .Values.service.internalPort }}
81         # disable liveness probe when breakpoints set in debugger
82         # so K8s doesn't restart unresponsive container
83         {{- if eq .Values.liveness.enabled true }}
84         livenessProbe:
85           tcpSocket:
86             port: {{ .Values.service.internalPort }}
87           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
88           periodSeconds: {{ .Values.liveness.periodSeconds }}
89         {{ end -}}
90         readinessProbe:
91           httpGet:
92             path: /aai/util/echo
93             port: {{ .Values.service.internalPort }}
94             scheme: HTTPS
95             httpHeaders:
96             - name: X-FromAppId
97               value: OOM_ReadinessCheck
98       {{ if .Values.global.installSidecarSecurity }}
99             - name: Authorization
100               value: Basic YWFpQGFhaS5vbmFwLm9yZzpkZW1vMTIzNDU2IQ==
101       {{ end }}
102             - name: X-TransactionId
103               value: OOM_ReadinessCheck_TID
104             - name: Accept
105               value: application/json
106           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
107           periodSeconds: {{ .Values.readiness.periodSeconds }}
108         resources:
109 {{ include "common.resources" . }}
110       {{- if .Values.nodeSelector }}
111       nodeSelector:
112 {{ toYaml .Values.nodeSelector | indent 8 }}
113       {{- end -}}
114       {{- if .Values.affinity }}
115       affinity:
116 {{ toYaml .Values.affinity | indent 8 }}
117       {{- end }}
118
119       volumes:
120         - name: localtime
121           hostPath:
122             path: /etc/localtime
123         - name: aai-service-log
124           hostPath:
125             path: "/dev/log"
126         - name: haproxy-cfg
127           configMap:
128             name: aai-deployment-configmap
129         - name: aai-pem
130           secret:
131             secretName: aai-haproxy-secret
132       imagePullSecrets:
133       - name: "{{ include "common.namespace" . }}-docker-registry-key"