[DCAEMOD] Uses new tpls for repos / images
[oom.git] / kubernetes / dmaap / components / message-router / charts / message-router-kafka / templates / statefulset.yaml
1 {{/*
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
17 apiVersion: apps/v1
18 kind: StatefulSet
19 metadata:
20   name: {{ include "common.fullname" . }}
21   namespace: {{ include "common.namespace" . }}
22   labels:
23     app: {{ include "common.name" . }}
24     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
25     release: {{ include "common.release" . }}
26     heritage: {{ .Release.Service }}
27 spec:
28   selector:
29     matchLabels:
30       app: {{ include "common.name" . }}
31   serviceName: {{ .Values.service.name }}
32   replicas: {{ .Values.replicaCount }}
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       {{- if .Values.nodeAffinity }}
46       nodeAffinity:
47       {{ toYaml .Values.nodeAffinity | indent 10 }}
48       {{- end }}
49       imagePullSecrets:
50       - name: "{{ include "common.namespace" . }}-docker-registry-key"
51       initContainers:
52       - name: {{ include "common.name" . }}-initcontainer
53         image: "{{ .Values.global.ubuntuInitRepository }}/{{ .Values.ubuntuInitImage }}"
54         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
55       - command:
56         - /app/ready.py
57         args:
58         - --container-name
59         - {{ .Values.zookeeper.name }}
60         env:
61         - name: NAMESPACE
62           valueFrom:
63             fieldRef:
64               apiVersion: v1
65               fieldPath: metadata.namespace
66         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
67         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
68         name: {{ include "common.name" . }}-readiness
69       - command:
70         -  sh
71         - -exec
72         - |
73           rm -rf '/var/lib/kafka/data/lost+found';
74           chown -R 1000:0 /var/lib/kafka/data;
75         image: "{{ .Values.busyBoxRepository }}/{{ .Values.busyBoxImage }}"
76         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
77         volumeMounts:
78         - mountPath: /var/lib/kafka/data
79           name: kafka-data
80         name: {{ include "common.name" . }}-permission-fixer
81       - command:
82         - sh
83         args:
84         - -c
85         - "cd /config-input  && for PFILE in `ls -1 .`; do envsubst <${PFILE} >/etc/kafka/secrets/jaas/${PFILE}; done"
86         env:
87         - name: ZK_ADMIN
88           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "zk-client" "key" "login") | indent 10 }}
89         - name: ZK_PSWD
90           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "zk-client" "key" "password") | indent 10 }}
91         - name: KAFKA_ADMIN
92           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "kafka-admin" "key" "login") | indent 10 }}
93         - name: KAFKA_PSWD
94           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "kafka-admin" "key" "password") | indent 10 }}
95         volumeMounts:
96         - mountPath: /etc/kafka/secrets/jaas
97           name: jaas-config
98         - mountPath: /config-input
99           name: jaas
100         image: "{{ .Values.global.envsubstImage }}"
101         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
102         name: {{ include "common.name" . }}-update-config
103       containers:
104       {{- if .Values.prometheus.jmx.enabled }}
105       - name: prometheus-jmx-exporter
106         image: "{{ .Values.prometheus.jmx.imageRepository }}/{{ .Values.prometheus.jmx.image }}:{{ .Values.prometheus.jmx.imageTag }}"
107         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
108         command:
109         - java
110         - -XX:+UnlockExperimentalVMOptions
111         - -XX:+UseCGroupMemoryLimitForHeap
112         - -XX:MaxRAMFraction=1
113         - -XshowSettings:vm
114         - -jar
115         - jmx_prometheus_httpserver.jar
116         - {{ .Values.prometheus.jmx.port | quote }}
117         - /etc/jmx-kafka/jmx-kafka-prometheus.yml
118         ports:
119         - containerPort: {{ .Values.prometheus.jmx.port }}
120         resources:
121 {{ toYaml .Values.prometheus.jmx.resources | indent 10 }}
122         volumeMounts:
123         - name: jmx-config
124           mountPath: /etc/jmx-kafka
125       {{- end }}
126       - name: {{ include "common.name" .  }}
127         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
128         imagePullPolicy:  {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
129         command:
130         - sh
131         - -exc
132         - |
133           export KAFKA_BROKER_ID=${HOSTNAME##*-} && \
134           {{- if  .Values.global.aafEnabled }}
135           export KAFKA_ADVERTISED_LISTENERS=EXTERNAL_SASL_PLAINTEXT://$(HOST_IP):$(( $KAFKA_BROKER_ID + {{ .Values.service.baseNodePort }} )),INTERNAL_SASL_PLAINTEXT://:{{ .Values.service.internalPort }} && \
136           {{ else }}
137           export KAFKA_ADVERTISED_LISTENERS=EXTERNAL_PLAINTEXT://$(HOST_IP):$(( $KAFKA_BROKER_ID + {{ .Values.service.baseNodePort }} )),INTERNAL_PLAINTEXT://:{{ .Values.service.internalPort }} && \
138           {{- end }}
139           exec /etc/confluent/docker/run
140         resources:
141 {{ include "common.resources" . | indent 12 }}
142         ports:
143         - containerPort: {{ .Values.service.internalPort }}
144         - containerPort: {{ .Values.service.externalPort }}
145         {{- if .Values.prometheus.jmx.enabled }}
146         - containerPort: {{ .Values.jmx.port }}
147           name: jmx
148         {{- end }}
149        {{ if eq .Values.liveness.enabled true }}
150         livenessProbe:
151           tcpSocket:
152             port: {{ .Values.service.internalPort }}
153           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
154           periodSeconds: {{ .Values.liveness.periodSeconds }}
155           timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
156         {{ end }}
157         readinessProbe:
158           tcpSocket:
159             port: {{ .Values.service.internalPort }}
160           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
161           periodSeconds: {{ .Values.readiness.periodSeconds }}
162           timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
163         env:
164         - name: HOST_IP
165           valueFrom:
166             fieldRef:
167               apiVersion: v1
168               fieldPath: status.hostIP
169         - name: KAFKA_ZOOKEEPER_CONNECT
170           value: {{ include "common.release" . }}-{{.Values.zookeeper.name}}-0.{{.Values.zookeeper.name}}.{{.Release.Namespace}}.svc.cluster.local:{{.Values.zookeeper.port}},{{ include "common.release" . }}-{{.Values.zookeeper.name}}-1.{{.Values.zookeeper.name}}.{{.Release.Namespace}}.svc.cluster.local:{{.Values.zookeeper.port}},{{ include "common.release" . }}-{{.Values.zookeeper.name}}-2.{{.Values.zookeeper.name}}.{{.Release.Namespace}}.svc.cluster.local:{{.Values.zookeeper.port}}
171         - name: KAFKA_CONFLUENT_SUPPORT_METRICS_ENABLE
172           value: "{{ .Values.kafka.enableSupport }}"
173         - name: KAFKA_OPTS
174           value: "{{ .Values.kafka.jaasOptions }}"
175         {{- if  .Values.global.aafEnabled }}
176         - name: KAFKA_OPTS
177           value: "{{ .Values.kafka.jaasOptionsAaf }}"
178         - name: aaf_locate_url
179           value: https://aaf-locate.{{ include "common.namespace" . }}:8095
180         - name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
181           value: "{{ .Values.kafka.protocolMapAaf }}"
182         - name: KAFKA_LISTENERS
183           value: "{{ .Values.kafka.listenersAaf }}"
184         - name: KAFKA_SASL_ENABLED_MECHANISMS
185           value: "{{ .Values.kafka.saslMech }}"
186         - name: KAFKA_INTER_BROKER_LISTENER_NAME
187           value: "{{ .Values.kafka.interBrokerListernerAaf }}"
188         - name: KAFKA_SASL_MECHANISM_INTER_BROKER_PROTOCOL
189           value: "{{ .Values.kafka.saslInterBrokerProtocol }}"
190         - name: KAFKA_AUTHORIZER_CLASS_NAME
191           value: "{{ .Values.kafka.authorizer }}"
192         {{ else }}
193         - name: KAFKA_OPTS
194           value: "{{ .Values.kafka.jaasOptions }}"
195         - name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
196           value: "{{ .Values.kafka.protocolMap }}"
197         - name: KAFKA_LISTENERS
198           value: "{{ .Values.kafka.listeners }}"
199         - name: KAFKA_INTER_BROKER_LISTENER_NAME
200           value: "{{ .Values.kafka.interBrokerListerner }}"
201         {{- end }}
202         {{- range $key, $value := .Values.configurationOverrides }}
203         - name: {{ printf "KAFKA_%s" $key | replace "." "_" | upper | quote }}
204           value: {{ $value | quote }}
205         {{- end }}
206         {{- if .Values.jmx.port }}
207         - name: KAFKA_JMX_PORT
208           value: "{{ .Values.jmx.port }}"
209         {{- end }}
210         - name: enableCadi
211           value: "{{ .Values.global.aafEnabled }}"
212         volumeMounts:
213         - mountPath: /etc/localtime
214           name: localtime
215           readOnly: true
216         - mountPath: /var/run/docker.sock
217           name: docker-socket
218         {{- if .Values.global.aafEnabled }}
219         - mountPath: /etc/kafka/data/cadi.properties
220           subPath: cadi.properties
221           name: cadi
222         {{ end  }}
223         - name: jaas-config
224           mountPath: /etc/kafka/secrets/jaas
225         - mountPath: /var/lib/kafka/data
226           name: kafka-data
227       {{- if .Values.tolerations }}
228       tolerations:
229         {{ toYaml .Values.tolerations | indent 10 }}
230       {{- end }}
231       volumes:
232       - name: localtime
233         hostPath:
234           path: /etc/localtime
235       - name: jaas-config
236         emptyDir:
237           medium: Memory
238       - name: docker-socket
239         hostPath:
240           path: /var/run/docker.sock
241       {{- if .Values.global.aafEnabled }}
242       - name: cadi
243         configMap:
244           name: {{ include "common.fullname" . }}-cadi-prop-configmap
245       {{ end }}
246       - name: jaas
247         configMap:
248           name: {{ include "common.fullname" . }}-jaas-configmap
249        {{- if .Values.prometheus.jmx.enabled }}
250       - name: jmx-config
251         configMap:
252           name: {{ include "common.fullname" . }}-prometheus-configmap
253        {{- end }}
254 {{ if not .Values.persistence.enabled }}
255       - name: kafka-data
256         emptyDir: {}
257 {{ else }}
258   volumeClaimTemplates:
259     - metadata:
260         name: kafka-data
261         labels:
262           app: {{ include "common.fullname" . }}
263           chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
264           release: "{{ include "common.release" . }}"
265           heritage: "{{ .Release.Service }}"
266       spec:
267         accessModes:
268           - {{ .Values.persistence.accessMode | quote }}
269         storageClassName: {{ include "common.storageClass" . }}
270         resources:
271           requests:
272             storage: {{ .Values.persistence.size | quote }}
273 {{ end }}