81563eb2006eb7b3e035fb83242858b12e86196f
[osm/devops.git] / installers / helm / osm / templates / kafka / kafka-statefulset.yaml
1 {{- if .Values.kafka.enabled -}}
2 #######################################################################################
3 # Copyright ETSI Contributors and Others.
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
14 # implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #######################################################################################
18 apiVersion: apps/v1
19 kind: StatefulSet
20 metadata:
21   name: kafka
22   labels:
23     {{- include "osm.labels" . | nindent 4 }}
24 spec:
25   replicas: {{ .Values.kafka.replicaCount | default .Values.global.replicaCount }}
26   serviceName: kafka
27   selector:
28     matchLabels:
29       app.kubernetes.io/component: kafka
30       {{- include "osm.selectorLabels" . | nindent 6 }}
31   template:
32     metadata:
33       {{- with .Values.global.podAnnotations }}
34       annotations:
35         {{- toYaml . | nindent 8 }}
36       {{- end }}
37       labels:
38         app.kubernetes.io/component: kafka
39         {{- include "osm.selectorLabels" . | nindent 8 }}
40     spec:
41       {{- with .Values.global.imagePullSecrets }}
42       imagePullSecrets:
43         {{- toYaml . | nindent 8 }}
44       {{- end }}
45       serviceAccountName: {{ include "osm.serviceAccountName" . }}
46       initContainers:
47         - name: zookeeper-test
48           image: alpine:latest
49           command: ["sh", "-c", "until nc -zvw1 zookeeper 2181; do sleep 3; done; exit 0"]
50       containers:
51         - name: kafka
52           securityContext:
53             # readOnlyRootFilesystem: true
54             allowPrivilegeEscalation: false
55             # runAsNonRoot: true
56           image: wurstmeister/kafka:2.11-1.0.2
57           imagePullPolicy: {{ .Values.global.image.pullPolicy }}
58           ports:
59             - containerPort: 9092
60               protocol: TCP
61           volumeMounts:
62             - name: socket
63               mountPath: /var/run/docker.sock
64           resources:
65             limits:
66               memory: 1024Mi
67             requests:
68               memory: 128Mi
69           envFrom:
70             - configMapRef:
71                 name: {{ include "osm.fullname" . }}-kafka-configmap
72       {{- with .Values.global.nodeSelector }}
73       nodeSelector:
74         {{- toYaml . | nindent 8 }}
75       {{- end }}
76       {{- with .Values.global.affinity }}
77       affinity:
78         {{- toYaml . | nindent 8 }}
79       {{- end }}
80       {{- with .Values.global.tolerations }}
81       tolerations:
82         {{- toYaml . | nindent 8 }}
83       {{- end }}
84       volumes:
85         - name: socket
86           hostPath:
87             path: /var/run/docker.sock
88 {{- end }}