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