Merge "[AAI] Kyverno - disallow-host-path policy"
[oom.git] / kubernetes / aai / components / aai-graphadmin / templates / deployment.yaml
1 {{/*
2 #
3 # ============LICENSE_START=======================================================
4 # org.onap.aai
5 # ================================================================================
6 # Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
7 # Copyright (c) 2020 Nokia Intellectual Property. All rights reserved.
8 # Copyright (c) 2020-2021 Orange Intellectual Property. All rights reserved.
9 # Modifications Copyright © 2023 Nordix Foundation
10 # ================================================================================
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
14 #
15 #    http://www.apache.org/licenses/LICENSE-2.0
16 #
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
22 # ============LICENSE_END=========================================================
23 */}}
24 apiVersion: apps/v1
25 kind: Deployment
26 metadata:
27   name: {{ include "common.fullname" . }}
28   namespace: {{ include "common.namespace" . }}
29   labels:
30     app: {{ include "common.name" . }}
31     app.kubernetes.io/name: {{ include "common.name" . }}
32     {{- if .Chart.AppVersion }}
33     version: "{{ .Chart.AppVersion | replace "+" "_" }}"
34     {{- else }}
35     version: "{{ .Chart.Version | replace "+" "_" }}"
36     {{- end }}
37     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
38     release: {{ include "common.release" . }}
39     heritage: {{ .Release.Service }}
40 spec:
41   replicas: {{ .Values.replicaCount }}
42   minReadySeconds: {{ .Values.minReadySeconds }}
43   strategy:
44     type: {{ .Values.updateStrategy.type }}
45     rollingUpdate:
46       maxUnavailable: {{ .Values.updateStrategy.maxUnavailable }}
47       maxSurge: {{ .Values.updateStrategy.maxSurge }}
48   selector:
49     matchLabels:
50       app: {{ include "common.name" . }}
51   template:
52     metadata:
53       labels:
54         app: {{ include "common.name" . }}
55         release: {{ include "common.release" . }}
56         app.kubernetes.io/name: {{ include "common.name" . }}
57         {{- if .Chart.AppVersion }}
58         version: "{{ .Chart.AppVersion | replace "+" "_" }}"
59         {{- else }}
60         version: "{{ .Chart.Version | replace "+" "_" }}"
61         {{- end }}
62       name: {{ include "common.name" . }}
63       annotations:
64         checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
65     spec:
66       hostname: aai-graphadmin
67       terminationGracePeriodSeconds: {{ .Values.service.terminationGracePeriodSeconds }}
68     {{ if .Values.global.initContainers.enabled }}
69       initContainers:
70       - command:
71       {{ if .Values.global.jobs.migration.enabled }}
72         - /app/ready.py
73         args:
74         - --job-name
75         - {{ include "common.release" . }}-aai-graphadmin-migration
76       {{  else if .Values.global.jobs.createSchema.enabled  }}
77         - /app/ready.py
78         args:
79         - --job-name
80         - {{ include "common.release" . }}-aai-graphadmin-create-db-schema
81       {{  else }}
82         - /app/ready.py
83         args:
84         - --app-name
85         {{- if .Values.global.cassandra.localCluster }}
86         - aai-cassandra
87         {{- else }}
88         - cassandra
89         {{- end }}
90         - --container-name
91         - aai-schema-service
92       {{  end  }}
93         env:
94         - name: NAMESPACE
95           valueFrom:
96             fieldRef:
97               apiVersion: v1
98               fieldPath: metadata.namespace
99         image: {{ include "repositoryGenerator.image.readiness" . }}
100         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
101         name: {{ include "common.name" . }}-readiness
102         resources:
103           limits:
104             cpu: "100m"
105             memory: "500Mi"
106           requests:
107             cpu: "3m"
108             memory: "20Mi"
109       {{  end  }}
110       containers:
111       - name: {{ include "common.name" . }}
112         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
113         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
114         env:
115         - name: LOCAL_USER_ID
116           value: {{ .Values.securityContext.user_id | quote }}
117         - name: LOCAL_GROUP_ID
118           value: {{ .Values.securityContext.group_id | quote }}
119         - name: INTERNAL_PORT_1
120           value: {{ .Values.service.internalPort | quote }}
121         - name: INTERNAL_PORT_2
122           value: {{ .Values.service.internalPort2 | quote }}
123         - name: INTERNAL_PORT_3
124           value: {{ .Values.service.internalPort3 | quote }}
125         volumeMounts:
126         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-realtime.properties
127           name: config
128           subPath: janusgraph-realtime.properties
129         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/janusgraph-cached.properties
130           name: config
131           subPath: janusgraph-cached.properties
132         - mountPath: /opt/app/aai-graphadmin/resources/etc/appprops/aaiconfig.properties
133           name: properties
134           subPath: aaiconfig.properties
135         - mountPath: /opt/aai/logroot/AAI-RES
136           name: logs
137         - mountPath: /opt/app/aai-graphadmin/resources/logback.xml
138           name: config
139           subPath: logback.xml
140         - mountPath: /opt/app/aai-graphadmin/resources/localhost-access-logback.xml
141           name: config
142           subPath: localhost-access-logback.xml
143         - mountPath: /opt/app/aai-graphadmin/resources/etc/auth/realm.properties
144           name: config
145           subPath: realm.properties
146         - mountPath: /opt/app/aai-graphadmin/resources/application.properties
147           name: properties
148           subPath: application.properties
149         ports:
150         - containerPort: {{ .Values.service.internalPort }}
151           name: {{ .Values.service.portName }}
152         - containerPort: {{ .Values.service.internalPort2 }}
153           name: {{ .Values.service.portName2 }}
154         - containerPort: {{ .Values.service.internalPort3 }}
155           name: {{ .Values.service.portName3 }}
156         lifecycle:
157           # wait for active requests (long-running tasks) to be finished
158           # Before the SIGTERM is invoked, Kubernetes exposes a preStop hook in the Pod.
159           preStop:
160             exec:
161               command:
162                 - sh
163                 - -c
164                 - |
165                   while (netstat -an | grep ESTABLISHED | grep -e $INTERNAL_PORT_1 -e $INTERNAL_PORT_2)
166                   do sleep 10
167                   done
168         # disable liveness probe when breakpoints set in debugger
169         # so K8s doesn't restart unresponsive container
170         {{ if .Values.liveness.enabled }}
171         livenessProbe:
172           tcpSocket:
173             port: {{ .Values.service.internalPort }}
174           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
175           periodSeconds: {{ .Values.liveness.periodSeconds }}
176         {{ end }}
177         readinessProbe:
178           tcpSocket:
179             port: {{ .Values.service.internalPort }}
180           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
181           periodSeconds: {{ .Values.readiness.periodSeconds }}
182         resources: {{ include "common.resources" . | nindent 10 }}
183       {{- if .Values.nodeSelector }}
184       nodeSelector:
185 {{ toYaml .Values.nodeSelector | indent 8 }}
186       {{- end -}}
187       {{- if .Values.affinity }}
188       affinity:
189 {{ toYaml .Values.affinity | indent 8 }}
190       {{- end }}
191
192       # side car containers
193       {{ include "common.log.sidecar" . | nindent 6 }}
194       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
195       volumes:
196       - name: logs
197         emptyDir: {}
198       {{ include "common.log.volumes" (dict "dot" . "configMapNamePrefix" (tpl .Values.logConfigMapNamePrefix .)) | nindent 6 }}
199       - name: config
200         configMap:
201           name: {{ include "common.fullname" . }}
202       - name: properties
203         configMap:
204           name: {{ include "common.fullname" . }}-properties
205       restartPolicy: {{ .Values.restartPolicy }}
206       {{- include "common.imagePullSecrets" . | nindent 6 }}