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