1b71c07bcb38eb3682c281fd76d37ea721140f22
[oom.git] / kubernetes / aai / templates / deployment.yaml
1 {{/*
2 # Copyright (c) 2018 Amdocs, Bell Canada, AT&T
3 # Modifications Copyright (c) 2020 Nokia, Orange
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
18 apiVersion: apps/v1
19 kind: Deployment
20 metadata:
21   name: {{ include "common.fullname" . }}
22   namespace: {{ include "common.namespace" . }}
23   labels:
24     app: {{ include "common.name" . }}
25     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
26     release: {{ include "common.release" . }}
27     heritage: {{ .Release.Service }}
28 spec:
29   selector:
30     matchLabels:
31       app: {{ include "common.name" . }}
32   replicas: {{ .Values.replicaCount }}
33   template:
34     metadata:
35       labels:
36         app: {{ include "common.name" . }}
37         release: {{ include "common.release" . }}
38       name: {{ include "common.release" . }}
39       annotations:
40         checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
41     spec:
42       initContainers: {{ include "common.certInitializer.initContainer" . | nindent 6 }}
43       - command:
44         - /app/ready.py
45         args:
46         - --container-name
47         - aai-resources
48         - --container-name
49         - aai-traversal
50         - --container-name
51         - aai-graphadmin
52         env:
53         - name: NAMESPACE
54           valueFrom:
55             fieldRef:
56               apiVersion: v1
57               fieldPath: metadata.namespace
58         image: {{ include "repositoryGenerator.image.readiness" . }}
59         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
60         name: {{ include "common.name" . }}-readiness
61         resources:
62           requests:
63             memory: {{ .Values.haproxy.initContainers.resources.memory }}
64             cpu: {{ .Values.haproxy.initContainers.resources.cpu }}
65           limits:
66             memory: {{ .Values.haproxy.initContainers.resources.memory }}
67             cpu: {{ .Values.haproxy.initContainers.resources.cpu }}
68       containers:
69       - name: {{ include "common.name" . }}
70         image: "{{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }}"
71         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
72         volumeMounts:
73         - mountPath: /etc/localtime
74           name: localtime
75           readOnly: true
76         - mountPath: /dev/log
77           name: aai-service-log
78         - mountPath: /usr/local/etc/haproxy/haproxy.cfg
79         {{ if .Values.global.installSidecarSecurity }}
80           subPath: haproxy-pluggable-security.cfg
81         {{ else }}
82           subPath: haproxy.cfg
83         {{ end }}
84           name: haproxy-cfg
85         {{- include "common.certInitializer.volumeMount" . | nindent 8 }}
86         ports:
87         - containerPort: {{ .Values.service.internalPort }}
88         - containerPort: {{ .Values.service.internalPlainPort }}
89         - containerPort: {{ .Values.metricsService.internalPort }}
90         # disable liveness probe when breakpoints set in debugger
91         # so K8s doesn't restart unresponsive container
92         {{- if eq .Values.liveness.enabled true }}
93         livenessProbe:
94           tcpSocket:
95             port: {{ (eq "true" (include "common.needTLS" .)) | ternary .Values.service.internalPort .Values.service.internalPlainPort }}
96           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
97           periodSeconds: {{ .Values.liveness.periodSeconds }}
98         {{ end -}}
99         readinessProbe:
100           httpGet:
101             path: /aai/util/echo
102             port: {{ (eq "true" (include "common.needTLS" .)) | ternary .Values.service.internalPort .Values.service.internalPlainPort }}
103             #scheme: HTTPS
104             scheme: {{ (eq "true" (include "common.needTLS" .)) | ternary "HTTPS" "HTTP" }}
105             httpHeaders:
106             - name: X-FromAppId
107               value: OOM_ReadinessCheck
108       {{ if .Values.global.installSidecarSecurity }}
109             - name: Authorization
110               value: Basic YWFpQGFhaS5vbmFwLm9yZzpkZW1vMTIzNDU2IQ==
111       {{ end }}
112             - name: X-TransactionId
113               value: OOM_ReadinessCheck_TID
114             - name: Accept
115               value: application/json
116           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
117           periodSeconds: {{ .Values.readiness.periodSeconds }}
118         resources:
119 {{ include "common.resources" . }}
120       {{- if .Values.nodeSelector }}
121       nodeSelector:
122 {{ toYaml .Values.nodeSelector | indent 8 }}
123       {{- end -}}
124       {{- if .Values.affinity }}
125       affinity:
126 {{ toYaml .Values.affinity | indent 8 }}
127       {{- end }}
128       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
129       volumes:
130         - name: localtime
131           hostPath:
132             path: /etc/localtime
133         - name: aai-service-log
134           hostPath:
135             path: "/dev/log"
136         - name: haproxy-cfg
137           configMap:
138             name: aai-deployment-configmap
139         {{ include "common.certInitializer.volumes" . | nindent 8 }}
140       imagePullSecrets:
141       - name: "{{ include "common.namespace" . }}-docker-registry-key"