add tolerations for kafka/zookeeper
[oom.git] / kubernetes / dmaap / components / message-router / charts / message-router-kafka / 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: {{ .Release.Name }}
25     heritage: {{ .Release.Service }}
26 spec:
27   serviceName: {{ .Values.service.name }}
28   replicas: {{ .Values.replicaCount }}
29   podManagementPolicy: Parallel
30   template:
31     metadata:
32       labels:
33         app:  {{ include "common.name" . }}
34         release: {{ .Release.Name }}
35     spec:
36       podAntiAffinity:
37          preferredDuringSchedulingIgnoredDuringExecution:
38          - weight: 1
39            podAffinityTerm:
40              labelSelector:
41                 matchExpressions:
42                   - key: "app"
43                     operator: In
44                     values:
45                     - {{ include "common.name" . }}
46              topologyKey: "kubernetes.io/hostname"
47       initContainers:
48       - name: {{ include "common.name" . }}-initcontainer
49         image: "{{ .Values.global.ubuntuInitRepository }}/{{ .Values.ubuntuInitImage }}"
50         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
51       - command:
52         - /root/ready.py
53         args:
54         - --container-name
55         - {{ .Values.zookeeper.name }}
56         env:
57         - name: NAMESPACE
58           valueFrom:
59             fieldRef:
60               apiVersion: v1
61               fieldPath: metadata.namespace
62         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
63         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
64         name: {{ include "common.name" . }}-readiness
65       containers:
66       - name: {{ include "common.name" .  }}
67         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
68         imagePullPolicy:  {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
69         resources:
70 {{ include "common.resources" . | indent 12 }}
71         ports:
72         - containerPort: {{ .Values.service.internalPort }}
73        {{ if eq .Values.liveness.enabled true }}
74         livenessProbe:
75           tcpSocket:
76             port: {{ .Values.service.internalPort }}
77           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
78           periodSeconds: {{ .Values.liveness.periodSeconds }}
79         {{ end }}
80         readinessProbe:
81           tcpSocket:
82             port: {{ .Values.service.internalPort }}
83           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
84           periodSeconds: {{ .Values.readiness.periodSeconds }}
85         env:
86         - name: HOST_NAME
87           valueFrom:
88             fieldRef:
89               apiVersion: v1
90               fieldPath: metadata.name
91         - name: HOST_NAMESPACE
92           valueFrom:
93             fieldRef:
94               apiVersion: v1
95               fieldPath: metadata.namespace
96         - name: KAFKA_ZOOKEEPER_CONNECT
97           value: "{{.Values.zookeeper.name}}:{{.Values.zookeeper.port}}"
98         - name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
99           value: "INTERNAL_PLAINTEXT:PLAINTEXT,EXTERNAL_PLAINTEXT:PLAINTEXT"
100         - name: KAFKA_ADVERTISED_LISTENERS
101           value: "INTERNAL_PLAINTEXT://$(HOST_NAME).{{ .Values.service.name }}.$(HOST_NAMESPACE).svc.cluster.local:{{ .Values.service.internalPort}}"
102         - name: KAFKA_LISTENERS
103           value: "INTERNAL_PLAINTEXT://0.0.0.0:{{.Values.service.internalPort}}"
104         - name: KAFKA_INTER_BROKER_LISTENER_NAME
105           value: "INTERNAL_PLAINTEXT"
106         - name: KAFKA_LOG_DIRS
107           value: "kafka/logs"
108         - name: BROKER_ID_COMMAND
109           value: "hostname | awk -F '-' '{print $NF}'"
110         - name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
111           value: "{{ .Values.replicaCount }}"
112         - name: KAFKA_DEFAULT_REPLICATION_FACTOR
113           value: "{{ .Values.replicaCount }}"
114         - name: KAFKA_NUM_PARTITIONS
115           value: "{{ .Values.defaultpartitions }}"
116         volumeMounts:
117         - mountPath: /etc/localtime
118           name: localtime
119           readOnly: true
120         - mountPath: /var/run/docker.sock
121           name: docker-socket
122         - mountPath: /kafka
123           name: kafka-data
124       {{- if .Values.tolerations }}
125       tolerations:
126         {{ toYaml .Values.tolerations | indent 10 }}
127       {{- end }}
128       volumes:
129       - name: localtime
130         hostPath:
131           path: /etc/localtime
132       - name: docker-socket
133         hostPath:
134           path: /var/run/docker.sock
135 {{ if not .Values.persistence.enabled }}
136       - name: kafka-data
137         emptyDir: {}
138 {{ else }}
139   volumeClaimTemplates:
140     - metadata:
141         name: kafka-data
142         labels:
143           app: {{ include "common.fullname" . }}
144           chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
145           release: "{{ .Release.Name }}"
146           heritage: "{{ .Release.Service }}"
147       spec:
148         accessModes:
149           - {{ .Values.persistence.accessMode | quote }}
150         resources:
151           requests:
152             storage: {{ .Values.persistence.size | quote }}
153         selector:
154           matchLabels:
155             release: "{{ .Release.Name }}"
156             app: {{ .Values.service.name }}
157             chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
158             heritage: "{{ .Release.Service }}"
159 {{ end }}
160       imagePullSecrets:
161       - name: "{{ include "common.namespace" . }}-docker-registry-key"