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