Merge "Drop the submodule nexus-repository-helm"
[it/dep.git] / ric-aux / 80-Auxiliary-Functions / helm / message-router / charts / message-router-kafka / templates / statefulset.yaml
1 ################################################################################
2 #   Copyright (c) 2019 AT&T Intellectual Property.                             #
3 #   Copyright (c) 2019 Nokia.                                                  #
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 implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17
18
19 apiVersion: apps/v1beta1
20 kind: StatefulSet
21 metadata:
22   name: {{ include "common.fullname" . }}
23   namespace: {{ include "common.namespace" . }}
24   labels:
25     app: {{ include "common.name" . }}
26     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
27     release: {{ .Release.Name }}
28     heritage: {{ .Release.Service }}
29 spec:
30   serviceName: {{ .Values.service.name }}
31   replicas: {{ .Values.replicaCount }}
32   podManagementPolicy: Parallel
33   template:
34     metadata:
35       labels:
36         app:  {{ include "common.name" . }}
37         release: {{ .Release.Name }}
38     spec:
39       podAntiAffinity:
40          {{if eq .Values.podAntiAffinityType "hard" -}}
41          requiredDuringSchedulingIgnoredDuringExecution:
42          {{- else -}}
43          preferredDuringSchedulingIgnoredDuringExecution:
44          {{- end}}
45          - weight: 1
46            podAffinityTerm:
47              labelSelector:
48                 matchExpressions:
49                   - key: "app"
50                     operator: In
51                     values:
52                     - {{ include "common.name" . }}
53              topologyKey: "kubernetes.io/hostname"
54       {{- if .Values.nodeAffinity }}
55       nodeAffinity:
56         {{ toYaml .Values.nodeAffinity | indent 10 }}
57       {{- end }}
58       initContainers:
59       - name: {{ include "common.name" . }}-initcontainer
60         image: "{{ .Values.global.ubuntuInitRepository }}/{{ .Values.ubuntuInitImage }}"
61         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
62       - command:
63         -  sh
64         - -exec
65         - |
66           chown -R 1000:1000 /opt/kafka/data;
67         image: "{{ .Values.busyBoxRepository }}/{{ .Values.busyBoxImage }}"
68         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
69         volumeMounts:
70         - mountPath: /opt/kafka/data
71           name: kafka-data
72         name: {{ include "common.name" . }}-permission-fixer
73       containers:
74       - name: {{ include "common.name" .  }}
75         image: "{{ .Values.onapRepository }}/{{ .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: "/opt/kafka/data"
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: /opt/kafka/data
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"