add tolerations for kafka/zookeeper
[oom.git] / kubernetes / dmaap / components / message-router / charts / message-router-zookeeper / 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   updateStrategy:
30     type: RollingUpdate
31     rollingUpdate:
32       maxUnavailable: {{ .Values.maxUnavailable }}
33   podManagementPolicy: Parallel
34   template:
35     metadata:
36       labels:
37         app: {{ include "common.name" . }}
38         release: {{ .Release.Name }}
39     spec:
40       podAntiAffinity:
41          preferredDuringSchedulingIgnoredDuringExecution:
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       initContainers:
52       - name: {{ include "common.name" . }}-seed-topics-apikeys
53         command:
54         - /bin/bash
55         - -c
56         - >
57           if [ -d /tmp/topics/version-2 ]; then
58           echo "nothing to do";
59           else
60           git clone -b {{ .Values.config.gerritBranch }} --single-branch {{ .Values.config.gerritProject }} /tmp/gerrit;
61           echo "Clone complete. Copying from /tmp/gerrit/oom-projects/data-zookeeper/* to /tmp/topics";
62           cp -var /tmp/gerrit/oom-topics/data-zookeeper/* /tmp/topics;
63           echo "Done.";
64           fi
65         image: "{{ .Values.global.ubuntuInitRepository }}/{{ .Values.ubuntuInitImage }}"
66         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
67         volumeMounts:
68         - mountPath: /tmp/topics
69           name: zookeeper-data
70       containers:
71       - name: {{ include "common.name" . }}
72         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
73         imagePullPolicy:  {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
74         resources:
75 {{ include "common.resources" . | indent 12 }}
76         ports:
77         - containerPort: {{ .Values.service.clientPort }}
78           name: {{ .Values.service.clientPortName }}
79         - containerPort: {{ .Values.service.serverPort }}
80           name: {{ .Values.service.serverPortName }}
81         - containerPort: {{ .Values.service.leaderElectionPort }}
82           name: {{ .Values.service.leaderElectionPortName }}
83         {{ if eq .Values.liveness.enabled true }}
84         livenessProbe:
85           exec:
86             command:
87             - sh
88             - -c
89             - "zookeeper-ready.sh 2181"
90           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
91           periodSeconds: {{ .Values.liveness.periodSeconds }}
92         {{ end }}
93         readinessProbe:
94           exec:
95             command:
96             - sh
97             - -c
98             - "zookeeper-ready.sh 2181"
99           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
100           periodSeconds: {{ .Values.readiness.periodSeconds }}
101         env:
102         - name: ZK_REPLICAS
103           value: "{{ .Values.replicaCount }}"
104         - name: ZK_INIT_LIMIT
105           value: "{{ .Values.zk.initLimit }}"
106         - name: ZK_SYNC_LIMIT
107           value: "{{ .Values.zk.syncLimit }}"
108         volumeMounts:
109         - mountPath: /etc/localtime
110           name: localtime
111           readOnly: true
112         - mountPath: /var/lib/zookeeper/data
113           name: zookeeper-data
114       {{- if .Values.tolerations }}
115       tolerations:
116         {{ toYaml .Values.tolerations | indent 10 }}
117       {{- end }}
118       volumes:
119       - name: localtime
120         hostPath:
121           path: /etc/localtime
122 {{ if not .Values.persistence.enabled }}
123       - name: zookeeper-data
124         emptyDir: {}
125 {{ else }}
126   volumeClaimTemplates:
127     - metadata:
128         name:  zookeeper-data
129         labels:
130           app:  {{ include "common.fullname" . }}
131           chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
132           release: "{{ .Release.Name }}"
133           heritage: "{{ .Release.Service }}"
134       spec:
135         accessModes:
136           - {{ .Values.persistence.accessMode | quote }}
137         resources:
138           requests:
139             storage: {{ .Values.persistence.size | quote }}
140         selector:
141           matchLabels:
142             release: "{{ .Release.Name }}"
143             app: {{ .Values.service.name }}
144             chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
145             heritage: "{{ .Release.Service }}"
146 {{ end }}
147       imagePullSecrets:
148       - name: "{{ include "common.namespace" . }}-docker-registry-key"
149
150