Extend K8S and RIC installation instructions
[it/dep.git] / ric-aux / helm / message-router / charts / message-router-zookeeper / 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/v1
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   selector:
33     matchLabels:
34       app: {{ include "common.name" . }}
35       release: {{ .Release.Name }}
36   updateStrategy:
37     type: RollingUpdate
38     rollingUpdate:
39       maxUnavailable: {{ .Values.rollingUpdate.maxUnavailable }}
40   podManagementPolicy: Parallel
41   template:
42     metadata:
43       labels:
44         app: {{ include "common.name" . }}
45         release: {{ .Release.Name }}
46     spec:
47       podAntiAffinity:
48          preferredDuringSchedulingIgnoredDuringExecution:
49          - weight: 1
50            podAffinityTerm:
51              labelSelector:
52                 matchExpressions:
53                   - key: "app"
54                     operator: In
55                     values:
56                     - {{ include "common.name" . }}
57              topologyKey: "kubernetes.io/hostname"
58       {{- if .Values.nodeAffinity }}
59       nodeAffinity:
60         {{ toYaml .Values.nodeAffinity | indent 10 }}
61       {{- end }}
62       initContainers:
63       - name: {{ include "common.name" . }}-permission-fixer
64         command:
65         - sh
66         - -exec
67         - >
68           mkdir -p /tmp/zookeeper/apikeys/version-2 && chown -R 1000:1000 /tmp/zookeeper/apikeys;
69         image: "{{ .Values.busyBoxRepository }}/{{ .Values.busyBoxImage }}"
70         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
71         volumeMounts:
72         - mountPath: /tmp/zookeeper/apikeys
73           name: zookeeper-data
74       containers:
75       - name: {{ include "common.name" . }}
76         image: "{{ .Values.onapRepository }}/{{ .Values.image }}"
77         imagePullPolicy:  {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
78         resources:
79 {{ include "common.resources" . | indent 12 }}
80         ports:
81         - containerPort: {{ .Values.service.clientPort }}
82           name: {{ .Values.service.clientPortName }}
83         - containerPort: {{ .Values.service.serverPort }}
84           name: {{ .Values.service.serverPortName }}
85         - containerPort: {{ .Values.service.leaderElectionPort }}
86           name: {{ .Values.service.leaderElectionPortName }}
87         {{ if eq .Values.liveness.enabled true }}
88         livenessProbe:
89           exec:
90             command:
91             - sh
92             - -c
93             - "zookeeper-ready.sh 2181"
94           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
95           periodSeconds: {{ .Values.liveness.periodSeconds }}
96         {{ end }}
97         readinessProbe:
98           exec:
99             command:
100             - sh
101             - -c
102             - "zookeeper-ready.sh 2181"
103           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
104           periodSeconds: {{ .Values.readiness.periodSeconds }}
105         env:
106         - name: ZK_REPLICAS
107           value: "{{ .Values.replicaCount }}"
108         - name: ZK_INIT_LIMIT
109           value: "{{ .Values.zk.initLimit }}"
110         - name: ZK_SYNC_LIMIT
111           value: "{{ .Values.zk.syncLimit }}"
112         volumeMounts:
113         - mountPath: /etc/localtime
114           name: localtime
115           readOnly: true
116         - mountPath: /var/lib/zookeeper/data
117           name: zookeeper-data
118       {{- if .Values.tolerations }}
119       tolerations:
120         {{ toYaml .Values.tolerations | indent 10 }}
121       {{- end }}
122       volumes:
123       - name: localtime
124         hostPath:
125           path: /etc/localtime
126 {{ if not .Values.persistence.enabled }}
127       - name: zookeeper-data
128         emptyDir: {}
129 {{ else }}
130   volumeClaimTemplates:
131     - metadata:
132         name:  zookeeper-data
133         labels:
134           app:  {{ include "common.fullname" . }}
135           chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
136           release: "{{ .Release.Name }}"
137           heritage: "{{ .Release.Service }}"
138       spec:
139         accessModes:
140           - {{ .Values.persistence.accessMode | quote }}
141         resources:
142           requests:
143             storage: {{ .Values.persistence.size | quote }}
144         selector:
145           matchLabels:
146             release: "{{ .Release.Name }}"
147             app: {{ .Values.service.name }}
148             chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
149             heritage: "{{ .Release.Service }}"
150 {{ end }}
151       imagePullSecrets:
152       - name: "docker-reg-cred"
153
154