Merge "Add Lenovo ThinkCloud Charts in OOM"
[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       {{- if .Values.nodeAffinity }}
52       nodeAffinity:
53         {{ toYaml .Values.nodeAffinity | indent 10 }}
54       {{- end }}
55       initContainers:
56       - name: {{ include "common.name" . }}-permission-fixer
57         command:
58         - sh
59         - -exec
60         - >
61           chown -R 1000:1000 /tmp/zookeeper/apikeys;
62         image: "{{ .Values.busyBoxRepository }}/{{ .Values.busyBoxImage }}"
63         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
64         volumeMounts:
65         - mountPath: /tmp/zookeeper/apikeys
66           name: zookeeper-data
67       containers:
68       - name: {{ include "common.name" . }}
69         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
70         imagePullPolicy:  {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
71         resources:
72 {{ include "common.resources" . | indent 12 }}
73         ports:
74         - containerPort: {{ .Values.service.clientPort }}
75           name: {{ .Values.service.clientPortName }}
76         - containerPort: {{ .Values.service.serverPort }}
77           name: {{ .Values.service.serverPortName }}
78         - containerPort: {{ .Values.service.leaderElectionPort }}
79           name: {{ .Values.service.leaderElectionPortName }}
80         {{ if eq .Values.liveness.enabled true }}
81         livenessProbe:
82           exec:
83             command:
84             - sh
85             - -c
86             - "zookeeper-ready.sh 2181"
87           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
88           periodSeconds: {{ .Values.liveness.periodSeconds }}
89         {{ end }}
90         readinessProbe:
91           exec:
92             command:
93             - sh
94             - -c
95             - "zookeeper-ready.sh 2181"
96           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
97           periodSeconds: {{ .Values.readiness.periodSeconds }}
98         env:
99         - name: ZK_REPLICAS
100           value: "{{ .Values.replicaCount }}"
101         - name: ZK_INIT_LIMIT
102           value: "{{ .Values.zk.initLimit }}"
103         - name: ZK_SYNC_LIMIT
104           value: "{{ .Values.zk.syncLimit }}"
105         volumeMounts:
106         - mountPath: /etc/localtime
107           name: localtime
108           readOnly: true
109         - mountPath: /var/lib/zookeeper/data
110           name: zookeeper-data
111       {{- if .Values.tolerations }}
112       tolerations:
113         {{ toYaml .Values.tolerations | indent 10 }}
114       {{- end }}
115       volumes:
116       - name: localtime
117         hostPath:
118           path: /etc/localtime
119 {{ if not .Values.persistence.enabled }}
120       - name: zookeeper-data
121         emptyDir: {}
122 {{ else }}
123   volumeClaimTemplates:
124     - metadata:
125         name:  zookeeper-data
126         labels:
127           app:  {{ include "common.fullname" . }}
128           chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
129           release: "{{ .Release.Name }}"
130           heritage: "{{ .Release.Service }}"
131       spec:
132         accessModes:
133           - {{ .Values.persistence.accessMode | quote }}
134         resources:
135           requests:
136             storage: {{ .Values.persistence.size | quote }}
137         selector:
138           matchLabels:
139             release: "{{ .Release.Name }}"
140             app: {{ .Values.service.name }}
141             chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
142             heritage: "{{ .Release.Service }}"
143 {{ end }}
144       imagePullSecrets:
145       - name: "{{ include "common.namespace" . }}-docker-registry-key"
146
147