Merge "[DMAAP] remove field undefined in in statefulset specification"
[oom.git] / kubernetes / dmaap / components / message-router / charts / message-router-zookeeper / templates / statefulset.yaml
1 # Copyright © 2017 Amdocs, Bell Canada
2 # Modifications Copyright © 2018 AT&T
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 apiVersion: apps/v1
17 kind: StatefulSet
18 metadata:
19   name: {{ include "common.fullname" . }}
20   namespace: {{ include "common.namespace" . }}
21   labels:
22     app: {{ include "common.name" . }}
23     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
24     release: {{ include "common.release" . }}
25     heritage: {{ .Release.Service }}
26 spec:
27   selector:
28     matchLabels:
29       app: {{ include "common.name" . }}
30   serviceName: {{ .Values.service.name }}
31   replicas: {{ .Values.replicaCount }}
32   updateStrategy:
33     type: RollingUpdate
34     rollingUpdate:
35       maxUnavailable: {{ .Values.maxUnavailable }}
36   podManagementPolicy: Parallel
37   template:
38     metadata:
39       labels:
40         app: {{ include "common.name" . }}
41         release: {{ include "common.release" . }}
42       {{- if .Values.prometheus.jmx.enabled }}
43       annotations:
44         prometheus.io/scrape: "true"
45         prometheus.io/port: {{ .Values.prometheus.jmx.port | quote }}
46       {{- end }}
47     spec:
48       {{- if .Values.nodeAffinity }}
49       nodeAffinity:
50         {{ toYaml .Values.nodeAffinity | indent 10 }}
51       {{- end }}
52       imagePullSecrets:
53       - name: "{{ include "common.namespace" . }}-docker-registry-key"
54       initContainers:
55       - name: {{ include "common.name" . }}-permission-fixer
56         command:
57         - sh
58         - -exec
59         - >
60           chown -R 1000:0 /tmp/zookeeper/apikeys;
61         image: "{{ .Values.busyBoxRepository }}/{{ .Values.busyBoxImage }}"
62         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
63         volumeMounts:
64         - mountPath: /tmp/zookeeper/apikeys
65           name: zookeeper-data
66       - command:
67         - sh
68         args:
69         - -c
70         - "cd /config-input && for PFILE in `ls -1 .`; do envsubst <${PFILE} >/etc/zookeeper/secrets/jaas/${PFILE}; done"
71         env:
72         - name: ZK_ADMIN
73           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "zk-admin" "key" "login") | indent 10 }}
74         - name: ZK_PSWD
75           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "zk-admin" "key" "password") | indent 10 }}
76         volumeMounts:
77         - mountPath: /etc/zookeeper/secrets/jaas
78           name: jaas-config
79         - mountPath: /config-input
80           name: jaas
81         image: "{{ .Values.global.envsubstImage }}"
82         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
83         name: {{ include "common.name" . }}-update-config
84       containers:
85       {{- if .Values.prometheus.jmx.enabled }}
86       - name: prometheus-jmx-exporter
87         image: "{{ .Values.prometheus.jmx.imageRepository }}/{{ .Values.prometheus.jmx.image }}:{{ .Values.prometheus.jmx.imageTag }}"
88         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
89         command:
90         - java
91         - -XX:+UnlockExperimentalVMOptions
92         - -XX:+UseCGroupMemoryLimitForHeap
93         - -XX:MaxRAMFraction=1
94         - -XshowSettings:vm
95         - -jar
96         - jmx_prometheus_httpserver.jar
97         - {{ .Values.prometheus.jmx.port | quote }}
98         - /etc/jmx-zookeeper/jmx-zookeeper-prometheus.yml
99         ports:
100         - containerPort: {{ .Values.prometheus.jmx.port }}
101         resources:
102 {{ toYaml .Values.prometheus.jmx.resources | indent 10 }}
103         volumeMounts:
104         - name: jmx-config
105           mountPath: /etc/jmx-zookeeper
106       {{- end }}
107       - name: {{ include "common.name" . }}
108         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
109         imagePullPolicy:  {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
110         resources:
111 {{ include "common.resources" . | indent 12 }}
112         ports:
113         - containerPort: {{ .Values.service.clientPort }}
114           name: {{ .Values.service.clientPortName }}
115         - containerPort: {{ .Values.service.serverPort }}
116           name: {{ .Values.service.serverPortName }}
117         - containerPort: {{ .Values.service.leaderElectionPort }}
118           name: {{ .Values.service.leaderElectionPortName }}
119         {{- if .Values.prometheus.jmx.enabled }}
120         - containerPort: {{ .Values.jmx.port }}
121           name: jmx
122         {{- end }}
123         {{ if eq .Values.liveness.enabled true }}
124         livenessProbe:
125           exec:
126             command:  ['/bin/bash', '-c', 'echo "ruok" | nc -w 2 -q 2 localhost 2181 | grep imok']
127           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
128           periodSeconds: {{ .Values.liveness.periodSeconds }}
129           timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
130         {{ end }}
131         readinessProbe:
132           exec:
133             command: ['/bin/bash', '-c', 'echo "ruok" | nc -w 2 -q 2 localhost 2181 | grep imok']
134           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
135           periodSeconds: {{ .Values.readiness.periodSeconds }}
136           timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
137         resources:
138 {{ include "common.resources" . | indent 10 }}
139         env:
140         - name : KAFKA_HEAP_OPTS
141           value: "{{ .Values.zkConfig.heapOptions }}"
142         {{- if .Values.jmx.port }}
143         - name : KAFKA_JMX_PORT
144           value: "{{ .Values.jmx.port }}"
145         {{- end }}
146         - name : ZOOKEEPER_REPLICAS
147           value: "{{ .Values.replicaCount }}"
148         - name : ZOOKEEPER_TICK_TIME
149           value: "{{ .Values.zkConfig.tickTime }}"
150         - name : ZOOKEEPER_SYNC_LIMIT
151           value: "{{ .Values.zkConfig.syncLimit }}"
152         - name : ZOOKEEPER_INIT_LIMIT
153           value: "{{ .Values.zkConfig.initLimit }}"
154         - name : ZOOKEEPER_MAX_CLIENT_CNXNS
155           value: "{{ .Values.zkConfig.maxClientCnxns }}"
156         - name : ZOOKEEPER_AUTOPURGE_SNAP_RETAIN_COUNT
157           value: "{{ .Values.zkConfig.autoPurgeSnapRetainCount}}"
158         - name : ZOOKEEPER_AUTOPURGE_PURGE_INTERVAL
159           value: "{{ .Values.zkConfig.autoPurgePurgeInterval}}"
160         - name: ZOOKEEPER_CLIENT_PORT
161           value: "{{ .Values.zkConfig.clientPort }}"
162         - name: KAFKA_OPTS
163           value: "{{ .Values.zkConfig.kafkaOpts }}"
164         - name: ZOOKEEPER_SERVER_ID
165           valueFrom:
166             fieldRef:
167               fieldPath: metadata.name
168         command:
169         - "bash"
170         - "-c"
171         - |
172           ZOOKEEPER_SERVER_ID=$((${HOSTNAME##*-}+1)) \
173           /etc/confluent/docker/run
174         volumeMounts:
175         - mountPath: /etc/localtime
176           name: localtime
177           readOnly: true
178         - mountPath: /var/lib/zookeeper/data
179           name: zookeeper-data
180         - name: jaas-config
181           mountPath: /etc/zookeeper/secrets/jaas
182       {{- if .Values.tolerations }}
183       tolerations:
184         {{ toYaml .Values.tolerations | indent 10 }}
185       {{- end }}
186       volumes:
187       - name: localtime
188         hostPath:
189           path: /etc/localtime
190       - name: jaas-config
191         emptyDir:
192           medium: Memory
193       - name: docker-socket
194         hostPath:
195           path: /var/run/docker.sock
196       - name: jaas
197         configMap:
198           name: {{ include "common.fullname" . }}-jaas-configmap
199        {{- if .Values.prometheus.jmx.enabled }}
200       - name: jmx-config
201         configMap:
202            name: {{ include "common.fullname" . }}-prometheus-configmap
203        {{- end }}
204 {{ if not .Values.persistence.enabled }}
205       - name: zookeeper-data
206         emptyDir: {}
207 {{ else }}
208   volumeClaimTemplates:
209     - metadata:
210         name: zookeeper-data
211         labels:
212           app: {{ include "common.fullname" . }}
213           chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
214           release: "{{ include "common.release" . }}"
215           heritage: "{{ .Release.Service }}"
216       spec:
217         accessModes:
218           - {{ .Values.persistence.accessMode | quote }}
219         storageClassName: {{ include "common.storageClass" . }}
220         resources:
221           requests:
222             storage: {{ .Values.persistence.size | quote }}
223 {{ end }}