Merge "[HOLMES] Remove AAF dependency and support SM"
[oom.git] / kubernetes / holmes / components / holmes-engine-mgmt / templates / deployment.yaml
1 {{/*
2 #============LICENSE_START========================================================
3 # ================================================================================
4 # Copyright (c) 2021 ZTE Intellectual Property. All rights reserved.
5 # ================================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END=========================================================
18 */}}
19
20 apiVersion: apps/v1
21 kind: Deployment
22 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
23 {{- $sum := "" }}
24 {{- range $path, $bytes := .Files.Glob "resources/config/*.json"}}
25 {{- $sum = $.Files.Get $path | sha256sum | print $sum }}
26 {{- end }}
27   annotations:
28     checksum/config: {{ $sum | sha256sum }}
29
30 spec:
31   replicas: 1
32   selector: {{- include "common.selectors" . | nindent 4 }}
33   template:
34     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
35     spec:
36       initContainers:
37       {{- if not .Values.global.postgres.localCluster }}
38       {{ include "common.readinessCheck.waitFor" . | indent 6 | trim }}
39       {{- end }}
40       - name: {{ include "common.name" . }}-env-config
41         image: {{ include "repositoryGenerator.image.envsubst" . }}
42         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
43         command:
44         - sh
45         args:
46         - -c
47         - "cd /hemconfig && for PFILE in `find . -type f -not -name '*.json'`; do envsubst < ${PFILE} > /config/${PFILE##*/}; done"
48         env:
49         - name: JDBC_USERNAME
50           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "login") | indent 10 }}
51         - name: JDBC_PASSWORD
52           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 10 }}
53         - name: DB_NAME
54           value: {{ .Values.config.pgConfig.dbName }}
55         - name: URL_JDBC
56           value: {{ .Values.config.pgConfig.dbHost }}
57         - name: DB_PORT
58           value: "{{ .Values.config.pgConfig.dbPort }}"
59         volumeMounts:
60         - mountPath: /hemconfig
61           name: {{ include "common.fullname" . }}-config
62         - mountPath: /config
63           name: {{ include "common.fullname" . }}-env-config
64       containers:
65       - name: {{ include "common.name" . }}
66         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
67         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
68         resources: {{ include "common.resources" . | nindent 10 }}
69         ports: {{ include "common.containerPorts" . | nindent 10  }}
70         volumeMounts:
71         - name: {{ include "common.fullname" . }}-env-config
72           mountPath: /opt/hemconfig
73         - name: {{ include "common.fullname" . }}-config
74           mountPath: /opt/hemtopics
75         # disable liveness probe when breakpoints set in debugger
76         # so K8s doesn't restart unresponsive container
77         {{- if eq .Values.liveness.enabled true }}
78         livenessProbe:
79           httpGet:
80             path: {{ .Values.liveness.path }}
81             port: {{ .Values.liveness.port }}
82             scheme: {{ .Values.liveness.scheme }}
83           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
84           periodSeconds: {{ .Values.liveness.periodSeconds }}
85         {{- end }}
86         readinessProbe:
87           httpGet:
88             path: {{ .Values.readiness.path }}
89             port: {{ .Values.readiness.port }}
90             scheme: {{ .Values.readiness.scheme }}
91           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
92           periodSeconds: {{ .Values.readiness.periodSeconds }}
93           failureThreshold: 1
94           successThreshold: 1
95           timeoutSeconds: 1
96         env:
97         - name: CONSUL_HOST
98           value: consul-server.{{ include "common.namespace" . }}
99         - name: CONFIG_BINDING_SERVICE
100           value: config-binding-service
101         - name: MSB_IAG_SERVICE_PROTOCOL
102           value: {{ .Values.global.msbProtocol }}
103         - name: MSB_IAG_SERVICE_HOST
104           value: {{ .Values.global.msbServiceName }}.{{ include "common.namespace" . }}
105         - name: MSB_IAG_SERVICE_PORT
106           value: {{ .Values.global.msbPort | quote }}
107         - name: POD_IP
108           valueFrom:
109             fieldRef:
110               apiVersion: v1
111               fieldPath: status.podIP
112         - name: PGPASSWORD
113           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 10 }}
114         - name: JDBC_USERNAME
115           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "login") | indent 10 }}
116         - name: JDBC_PASSWORD
117           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 10 }}
118         - name: DB_NAME
119           value: {{ .Values.config.pgConfig.dbName }}
120         - name: URL_JDBC
121           value: {{ .Values.config.pgConfig.dbHost }}
122         - name: DB_PORT
123           value: "{{ .Values.config.pgConfig.dbPort }}"
124       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
125       volumes:
126       - name: {{ include "common.fullname" . }}-config
127         configMap:
128           defaultMode: 422
129           name: {{ include "common.fullname" . }}
130       - name: {{ include "common.fullname" . }}-env-config
131         emptyDir:
132           medium: Memory
133       imagePullSecrets:
134       - name: "{{ include "common.namespace" . }}-docker-registry-key"