Merge "[HV-VES-STRIMZI] Migrate hv-ves to use strimzi kafka"
[oom.git] / kubernetes / dmaap / components / message-router / components / message-router-zookeeper / templates / statefulset.yaml
1 {{/*
2 # Copyright © 2017 Amdocs, Bell Canada
3 # Modifications Copyright © 2018 AT&T
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: StatefulSet
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   serviceName: {{ .Values.service.name }}
33   replicas: {{ .Values.replicaCount }}
34   updateStrategy:
35     type: RollingUpdate
36     rollingUpdate:
37       maxUnavailable: {{ .Values.maxUnavailable }}
38   podManagementPolicy: Parallel
39   template:
40     metadata:
41       labels:
42         app: {{ include "common.name" . }}
43         release: {{ include "common.release" . }}
44       {{- if .Values.prometheus.jmx.enabled }}
45       annotations:
46         prometheus.io/scrape: "true"
47         prometheus.io/port: {{ .Values.prometheus.jmx.port | quote }}
48       {{- end }}
49     spec:
50       {{- if .Values.nodeAffinity }}
51       nodeAffinity:
52         {{ toYaml .Values.nodeAffinity | indent 10 }}
53       {{- end }}
54       imagePullSecrets:
55       - name: "{{ include "common.namespace" . }}-docker-registry-key"
56       initContainers:
57       - name: {{ include "common.name" . }}-permission-fixer
58         command:
59         - sh
60         - -exec
61         - >
62           chown -R 1000:0 /tmp/zookeeper/apikeys;
63         image: {{ include "repositoryGenerator.image.busybox" . }}
64         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
65         volumeMounts:
66         - mountPath: /tmp/zookeeper/apikeys
67           name: zookeeper-data
68       - command:
69         - sh
70         args:
71         - -c
72         - "cd /config-input && for PFILE in `ls -1 .`; do envsubst <${PFILE} >/etc/zookeeper/secrets/jaas/${PFILE}; done"
73         env:
74         - name: ZK_ADMIN
75           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "zk-admin" "key" "login") | indent 10 }}
76         - name: ZK_PSWD
77           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "zk-admin" "key" "password") | indent 10 }}
78         volumeMounts:
79         - mountPath: /etc/zookeeper/secrets/jaas
80           name: jaas-config
81         - mountPath: /config-input
82           name: jaas
83         image: {{ include "repositoryGenerator.image.envsubst" . }}
84         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
85         name: {{ include "common.name" . }}-update-config
86       containers:
87       {{- if .Values.prometheus.jmx.enabled }}
88       - name: prometheus-jmx-exporter
89         image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.prometheus.jmx.image }}:{{ .Values.prometheus.jmx.imageTag }}"
90         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
91         command:
92         - java
93         - -XX:+UnlockExperimentalVMOptions
94         - -XX:+UseCGroupMemoryLimitForHeap
95         - -XX:MaxRAMFraction=1
96         - -XshowSettings:vm
97         - -jar
98         - jmx_prometheus_httpserver.jar
99         - {{ .Values.prometheus.jmx.port | quote }}
100         - /etc/jmx-zookeeper/jmx-zookeeper-prometheus.yml
101         ports:
102         - containerPort: {{ .Values.prometheus.jmx.port }}
103         resources:
104 {{ toYaml .Values.prometheus.jmx.resources | indent 10 }}
105         volumeMounts:
106         - name: jmx-config
107           mountPath: /etc/jmx-zookeeper
108       {{- end }}
109       - name: {{ include "common.name" . }}
110         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
111         imagePullPolicy:  {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
112         resources:
113 {{ include "common.resources" . | indent 12 }}
114         ports:
115         - containerPort: {{ .Values.service.clientPort }}
116           name: {{ .Values.service.clientPortName }}
117         - containerPort: {{ .Values.service.serverPort }}
118           name: {{ .Values.service.serverPortName }}
119         - containerPort: {{ .Values.service.leaderElectionPort }}
120           name: {{ .Values.service.leaderElectionPortName }}
121         {{- if .Values.prometheus.jmx.enabled }}
122         - containerPort: {{ .Values.jmx.port }}
123           name: jmx
124         {{- end }}
125         {{ if eq .Values.liveness.enabled true }}
126         livenessProbe:
127           exec:
128             command:  ['/bin/bash', '-c', 'echo "ruok" | nc -w 2 localhost 2181 | grep imok']
129           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
130           periodSeconds: {{ .Values.liveness.periodSeconds }}
131           timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
132         {{ end }}
133         readinessProbe:
134           exec:
135             command: ['/bin/bash', '-c', 'echo "ruok" | nc -w 2 localhost 2181 | grep imok']
136           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
137           periodSeconds: {{ .Values.readiness.periodSeconds }}
138           timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
139         resources:
140 {{ include "common.resources" . | indent 10 }}
141         env:
142         - name : KAFKA_HEAP_OPTS
143           value: "{{ .Values.zkConfig.heapOptions }}"
144         {{- if .Values.jmx.port }}
145         - name : KAFKA_JMX_PORT
146           value: "{{ .Values.jmx.port }}"
147         {{- end }}
148         - name : ZOOKEEPER_REPLICAS
149           value: "{{ .Values.replicaCount }}"
150         - name : ZOOKEEPER_TICK_TIME
151           value: "{{ .Values.zkConfig.tickTime }}"
152         - name : ZOOKEEPER_SYNC_LIMIT
153           value: "{{ .Values.zkConfig.syncLimit }}"
154         - name : ZOOKEEPER_INIT_LIMIT
155           value: "{{ .Values.zkConfig.initLimit }}"
156         - name : ZOOKEEPER_MAX_CLIENT_CNXNS
157           value: "{{ .Values.zkConfig.maxClientCnxns }}"
158         - name : ZOOKEEPER_AUTOPURGE_SNAP_RETAIN_COUNT
159           value: "{{ .Values.zkConfig.autoPurgeSnapRetainCount}}"
160         - name : ZOOKEEPER_AUTOPURGE_PURGE_INTERVAL
161           value: "{{ .Values.zkConfig.autoPurgePurgeInterval}}"
162         - name: ZOOKEEPER_CLIENT_PORT
163           value: "{{ .Values.zkConfig.clientPort }}"
164         - name: KAFKA_OPTS
165           value: "{{ .Values.zkConfig.kafkaOpts }}"
166         - name: ZOOKEEPER_QUORUM_LISTEN_ON_ALL_IPS
167           value: "true"
168         - name: ZOOKEEPER_SERVERS
169           value: {{ template "zookeeper.serverlist" . }}
170         - name: ZOOKEEPER_SERVER_ID
171           valueFrom:
172             fieldRef:
173               fieldPath: metadata.name
174         command:
175         - "bash"
176         - "-c"
177         - |
178           ZOOKEEPER_SERVER_ID=$((${HOSTNAME##*-}+1)) \
179           /etc/confluent/docker/run
180         volumeMounts:
181         - mountPath: /etc/localtime
182           name: localtime
183           readOnly: true
184         - mountPath: /var/lib/zookeeper/data
185           name: zookeeper-data
186         - name: jaas-config
187           mountPath: /etc/zookeeper/secrets/jaas
188       {{- if .Values.tolerations }}
189       tolerations:
190         {{ toYaml .Values.tolerations | indent 10 }}
191       {{- end }}
192       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
193       volumes:
194       - name: localtime
195         hostPath:
196           path: /etc/localtime
197       - name: jaas-config
198         emptyDir:
199           medium: Memory
200       - name: docker-socket
201         hostPath:
202           path: /var/run/docker.sock
203       - name: jaas
204         configMap:
205           name: {{ include "common.fullname" . }}-jaas-configmap
206        {{- if .Values.prometheus.jmx.enabled }}
207       - name: jmx-config
208         configMap:
209            name: {{ include "common.fullname" . }}-prometheus-configmap
210        {{- end }}
211 {{ if not .Values.persistence.enabled }}
212       - name: zookeeper-data
213         emptyDir: {}
214 {{ else }}
215   volumeClaimTemplates:
216     - metadata:
217         name: zookeeper-data
218         labels:
219           app: {{ include "common.fullname" . }}
220           chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
221           release: "{{ include "common.release" . }}"
222           heritage: "{{ .Release.Service }}"
223       spec:
224         accessModes:
225           - {{ .Values.persistence.accessMode | quote }}
226         storageClassName: {{ include "common.storageClass" . }}
227         resources:
228           requests:
229             storage: {{ .Values.persistence.size | quote }}
230 {{ end }}