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