DMAAP changes
[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          {{if eq .Values.podAntiAffinityType "hard" -}}
38          requiredDuringSchedulingIgnoredDuringExecution:
39          {{- else -}}
40          preferredDuringSchedulingIgnoredDuringExecution:
41          {{- end}}
42          - weight: 1
43            podAffinityTerm:
44              labelSelector:
45                 matchExpressions:
46                   - key: "app"
47                     operator: In
48                     values:
49                     - {{ include "common.name" . }}
50              topologyKey: "kubernetes.io/hostname"
51       {{- if .Values.nodeAffinity }}
52       nodeAffinity:
53         {{ toYaml .Values.nodeAffinity | indent 10 }}
54       {{- end }}
55       initContainers:
56       - name: {{ include "common.name" . }}-initcontainer
57         image: "{{ .Values.global.ubuntuInitRepository }}/{{ .Values.ubuntuInitImage }}"
58         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
59       - command:
60         - /root/ready.py
61         args:
62         - --container-name
63         - {{ .Values.zookeeper.name }}
64         env:
65         - name: NAMESPACE
66           valueFrom:
67             fieldRef:
68               apiVersion: v1
69               fieldPath: metadata.namespace
70         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
71         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
72         name: {{ include "common.name" . }}-readiness
73       containers:
74       - name: {{ include "common.name" .  }}
75         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
76         imagePullPolicy:  {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
77         command:
78         - sh
79         - -exc
80         - |
81           export KAFKA_BROKER_ID=${HOSTNAME##*-} && \
82           export ENDPOINT_PORT=$(( $KAFKA_BROKER_ID + {{ .Values.service.baseNodePort }} )) && \
83           export KAFKA_ADVERTISED_LISTENERS=EXTERNAL_SASL_PLAINTEXT://$(HOST_IP):$(( $KAFKA_BROKER_ID + {{ .Values.service.baseNodePort }} )),INTERNAL_SASL_PLAINTEXT://:{{ .Values.service.internalPort }} && \
84           exec start-kafka.sh
85         resources:
86 {{ include "common.resources" . | indent 12 }}
87         ports:
88         - containerPort: {{ .Values.service.internalPort }}
89         - containerPort: {{ .Values.service.externalPort }}
90        {{ if eq .Values.liveness.enabled true }}
91         livenessProbe:
92           tcpSocket:
93             port: {{ .Values.service.internalPort }}
94           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
95           periodSeconds: {{ .Values.liveness.periodSeconds }}
96         {{ end }}
97         readinessProbe:
98           tcpSocket:
99             port: {{ .Values.service.internalPort }}
100           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
101           periodSeconds: {{ .Values.readiness.periodSeconds }}
102         env:
103         - name: HOST_IP
104           valueFrom:
105             fieldRef:
106               apiVersion: v1
107               fieldPath: status.hostIP
108         - name: KAFKA_ZOOKEEPER_CONNECT
109           value: "{{.Values.zookeeper.name}}:{{.Values.zookeeper.port}}"
110         - name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
111           value: "INTERNAL_SASL_PLAINTEXT:SASL_PLAINTEXT,EXTERNAL_SASL_PLAINTEXT:SASL_PLAINTEXT"
112         - name: KAFKA_LISTENERS
113           value: "EXTERNAL_SASL_PLAINTEXT://0.0.0.0:{{ .Values.service.externalPort }},INTERNAL_SASL_PLAINTEXT://0.0.0.0:{{ .Values.service.internalPort }}"
114         - name: KAFKA_INTER_BROKER_LISTENER_NAME
115           value: "INTERNAL_SASL_PLAINTEXT"
116         - name: KAFKA_SASL_ENABLED_MECHANISMS
117           value: "PLAIN"
118         - name: KAFKA_SASL_MECHANISM_INTER_BROKER_PROTOCOL
119           value: "PLAIN"
120         - name: KAFKA_AUTHORIZER_CLASS_NAME
121           value: "{{ .Values.kafkaCustomAuthorizer }}"
122         - name: KAFKA_DELETE_TOPIC_ENABLE
123           value: "{{ .Values.deleteTopicEnable }}"
124         - name: aaf_locate_url
125           value: "https://aaf-locate:8095"
126         - name: KAFKA_LOG_DIRS
127           value: "kafka/logs"
128         - name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
129           value: "{{ .Values.replicaCount }}"
130         - name: KAFKA_DEFAULT_REPLICATION_FACTOR
131           value: "{{ .Values.replicaCount }}"
132         - name: KAFKA_NUM_PARTITIONS
133           value: "{{ .Values.defaultpartitions }}"
134         volumeMounts:
135         - mountPath: /etc/localtime
136           name: localtime
137           readOnly: true
138         - mountPath: /var/run/docker.sock
139           name: docker-socket
140         - mountPath: /kafka
141           name: kafka-data
142       {{- if .Values.tolerations }}
143       tolerations:
144         {{ toYaml .Values.tolerations | indent 10 }}
145       {{- end }}
146       volumes:
147       - name: localtime
148         hostPath:
149           path: /etc/localtime
150       - name: docker-socket
151         hostPath:
152           path: /var/run/docker.sock
153 {{ if not .Values.persistence.enabled }}
154       - name: kafka-data
155         emptyDir: {}
156 {{ else }}
157   volumeClaimTemplates:
158     - metadata:
159         name: kafka-data
160         labels:
161           app: {{ include "common.fullname" . }}
162           chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
163           release: "{{ .Release.Name }}"
164           heritage: "{{ .Release.Service }}"
165       spec:
166         accessModes:
167           - {{ .Values.persistence.accessMode | quote }}
168         resources:
169           requests:
170             storage: {{ .Values.persistence.size | quote }}
171         selector:
172           matchLabels:
173             release: "{{ .Release.Name }}"
174             app: {{ .Values.service.name }}
175             chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
176             heritage: "{{ .Release.Service }}"
177 {{ end }}
178       imagePullSecrets:
179       - name: "{{ include "common.namespace" . }}-docker-registry-key"