Merge "Temporarily remove the dependency on Cassandra"
[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: {{ include "common.release" . }}
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: {{ include "common.release" . }}
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       - command:
74         -  sh
75         - -exec
76         - |
77           chown -R 1000:1000 /opt/kafka/data;
78           rm -rf '/opt/kafka/data/lost+found';
79           cp /opt/kafka/tmpconfig/server.properties /opt/kafka/config/;
80           chown 1000:1000 /opt/kafka/config/server.properties;
81           cd /opt/kafka/config;
82           ls;
83         image: "{{ .Values.busyBoxRepository }}/{{ .Values.busyBoxImage }}"
84         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
85         volumeMounts:
86         - mountPath: /opt/kafka/data
87           name: kafka-data
88         - mountPath: /opt/kafka/tmpconfig/server.properties
89           subPath: server.properties
90           name: server
91         - mountPath: /opt/kafka/config
92           name: config-data
93         name: {{ include "common.name" . }}-permission-fixer
94       containers:
95       - name: {{ include "common.name" .  }}
96         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
97         imagePullPolicy:  {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
98         command:
99         - sh
100         - -exc
101         - |
102           export KAFKA_BROKER_ID=${HOSTNAME##*-} && \
103           export ENDPOINT_PORT=$(( $KAFKA_BROKER_ID + {{ .Values.service.baseNodePort }} )) && \
104           export KAFKA_ADVERTISED_LISTENERS=EXTERNAL_SASL_PLAINTEXT://$(HOST_IP):$(( $KAFKA_BROKER_ID + {{ .Values.service.baseNodePort }} )),INTERNAL_SASL_PLAINTEXT://:{{ .Values.service.internalPort }} && \
105           exec start-kafka.sh
106         resources:
107 {{ include "common.resources" . | indent 12 }}
108         ports:
109         - containerPort: {{ .Values.service.internalPort }}
110         - containerPort: {{ .Values.service.externalPort }}
111        {{ if eq .Values.liveness.enabled true }}
112         livenessProbe:
113           tcpSocket:
114             port: {{ .Values.service.internalPort }}
115           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
116           periodSeconds: {{ .Values.liveness.periodSeconds }}
117           timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
118         {{ end }}
119         readinessProbe:
120           tcpSocket:
121             port: {{ .Values.service.internalPort }}
122           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
123           periodSeconds: {{ .Values.readiness.periodSeconds }}
124           timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
125         env:
126         - name: HOST_IP
127           valueFrom:
128             fieldRef:
129               apiVersion: v1
130               fieldPath: status.hostIP
131         - name: aaf_locate_url
132           value: https://aaf-locate.{{ include "common.namespace" . }}:8095
133
134         volumeMounts:
135         - mountPath: /etc/localtime
136           name: localtime
137           readOnly: true
138         - mountPath: /var/run/docker.sock
139           name: docker-socket
140         - mountPath: /opt/kafka/tmpconfig/server.properties
141           subPath: server.properties
142           name: server
143         - mountPath: /opt/kafka/config/server.properties
144           subPath: server.properties
145           name: config-data
146         - mountPath: /opt/kafka/config/log4j.properties
147           subPath: log4j.properties
148           name: log4j
149         - mountPath: /opt/kafka/config/cadi.properties
150           subPath: cadi.properties
151           name: cadi
152         - mountPath: /opt/kafka/data
153           name: kafka-data
154       {{- if .Values.tolerations }}
155       tolerations:
156         {{ toYaml .Values.tolerations | indent 10 }}
157       {{- end }}
158       volumes:
159       - name: localtime
160         hostPath:
161           path: /etc/localtime
162       - name: config-data
163         emptyDir: {}
164       - name: docker-socket
165         hostPath:
166           path: /var/run/docker.sock
167       - name: server
168         configMap:
169           name: {{ include "common.fullname" . }}-server-prop-configmap
170       - name: log4j
171         configMap:
172           name: {{ include "common.fullname" . }}-log4j-prop-configmap
173       - name: cadi
174         configMap:
175           name: {{ include "common.fullname" . }}-cadi-prop-configmap
176 {{ if not .Values.persistence.enabled }}
177       - name: kafka-data
178         emptyDir: {}
179 {{ else }}
180   volumeClaimTemplates:
181     - metadata:
182         name: kafka-data
183         labels:
184           app: {{ include "common.fullname" . }}
185           chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
186           release: "{{ include "common.release" . }}"
187           heritage: "{{ .Release.Service }}"
188       spec:
189         accessModes:
190           - {{ .Values.persistence.accessMode | quote }}
191         storageClassName: {{ include "common.storageClass" . }}
192         resources:
193           requests:
194             storage: {{ .Values.persistence.size | quote }}
195 {{ end }}
196       imagePullSecrets:
197       - name: "{{ include "common.namespace" . }}-docker-registry-key"