db0eb160924731ce60b908eb2e5b31b38373c4d0
[oom.git] / kubernetes / holmes / components / holmes-rule-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/rules/*"}}
25 {{- $sum = $.Files.Get $path | sha256sum | print $sum }}
26 {{- end }}
27   annotations:
28     checksum/rules: {{ $sum | sha256sum }}
29 spec:
30   replicas: 1
31   selector: {{- include "common.selectors" . | nindent 4 }}
32   template:
33     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
34     spec:
35       initContainers:
36       {{- if .Values.global.postgres.localCluster }}
37       {{ include "common.readinessCheck.waitFor" (dict "dot" . "wait_for" .Values.readinessCheck.wait_for_local ) | indent 6 | trim }}
38       {{ else }}
39       {{ include "common.readinessCheck.waitFor" (dict "dot" . "wait_for" .Values.readinessCheck.wait_for_global ) | indent 6 | trim }}
40       {{- end }}
41       - name: {{ include "common.name" . }}-env-config
42         image: {{ include "repositoryGenerator.image.envsubst" . }}
43         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
44         command:
45         - sh
46         args:
47         - -c
48         - "cd /hrmconfig && for PFILE in `find . -type f -not -name '*.json'`; do envsubst < ${PFILE} > /config/${PFILE##*/}; done"
49         env:
50         - name: JDBC_USERNAME
51           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "login") | indent 10 }}
52         - name: JDBC_PASSWORD
53           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 10 }}
54         - name: DB_NAME
55           value: {{ .Values.config.pgConfig.dbName }}
56         - name: URL_JDBC
57           value: {{ .Values.config.pgConfig.dbHost }}
58         - name: DB_PORT
59           value: "{{ .Values.config.pgConfig.dbPort }}"
60         - name: NAMESPACE
61           value: {{ include "common.namespace" . }}
62         volumeMounts:
63         - mountPath: /hrmconfig
64           name: {{ include "common.fullname" . }}-general-config
65         - mountPath: /config
66           name: {{ include "common.fullname" . }}-env-config
67       containers:
68       - name: {{ include "common.name" . }}
69         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
70         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
71         ports: {{ include "common.containerPorts" . | nindent 8  }}
72         volumeMounts:
73         - name: {{ include "common.fullname" . }}-env-config
74           mountPath: /opt/hrmconfig
75         - name: {{ include "common.fullname" . }}-rule-config
76           mountPath: /opt/hrmrules
77         # disable liveness probe when breakpoints set in debugger
78         # so K8s doesn't restart unresponsive container
79         {{- if eq .Values.liveness.enabled true }}
80         livenessProbe:
81           httpGet:
82             path: {{ .Values.liveness.path }}
83             port: {{ .Values.liveness.port }}
84             scheme: {{ .Values.liveness.scheme }}
85           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
86           periodSeconds: {{ .Values.liveness.periodSeconds }}
87         {{- end }}
88         readinessProbe:
89           httpGet:
90             path: {{ .Values.readiness.path }}
91             port: {{ .Values.readiness.port }}
92             scheme: {{ .Values.readiness.scheme }}
93           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
94           periodSeconds: {{ .Values.readiness.periodSeconds }}
95           failureThreshold: 1
96           successThreshold: 1
97           timeoutSeconds: 1
98         env:
99         - name: CONSUL_HOST
100           value: consul-server.{{ include "common.namespace" . }}
101         - name: CONFIG_BINDING_SERVICE
102           value: config-binding-service
103         - name: MSB_IAG_SERVICE_PROTOCOL
104           value: {{ .Values.global.msbProtocol }}
105         - name: MSB_IAG_SERVICE_HOST
106           value: {{ .Values.global.msbServiceName }}.{{ include "common.namespace" . }}
107         - name: MSB_IAG_SERVICE_PORT
108           value: {{ .Values.global.msbPort | quote}}
109         - name: POD_IP
110           valueFrom:
111             fieldRef:
112               apiVersion: v1
113               fieldPath: status.podIP
114         - name: PGPASSWORD
115           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 10 }}
116         - name: JDBC_USERNAME
117           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "login") | indent 10 }}
118         - name: JDBC_PASSWORD
119           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 10 }}
120         - name: DB_NAME
121           value: {{ .Values.config.pgConfig.dbName }}
122         - name: URL_JDBC
123           value: {{ .Values.config.pgConfig.dbHost }}
124         - name: DB_PORT
125           value: "{{ .Values.config.pgConfig.dbPort }}"
126       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
127       volumes:
128       - name: {{ include "common.fullname" . }}-general-config
129         configMap:
130           defaultMode: 422
131           name: {{ include "common.fullname" . }}-general-config
132       - name: {{ include "common.fullname" . }}-rule-config
133         configMap:
134           defaultMode: 422
135           name: {{ include "common.fullname" . }}-rule-config
136       - name: {{ include "common.fullname" . }}-env-config
137         emptyDir:
138           medium: Memory
139       imagePullSecrets:
140       - name: "{{ include "common.namespace" . }}-docker-registry-key"