Adding helm chart & documentation for redis-cluster related study ticket
[ric-plt/ric-dep.git] / helm / redis-cluster / templates / statefulset.yaml
1 ###################################################################################
2 #  ============LICENSE_START=======================================================
3 #
4 #  ================================================================================
5 #  Copyright (C) 2020 Hcl Technologies Limited.
6 #  ================================================================================
7 #  Licensed under the Apache License, Version 2.0 (the "License");
8 #  you may not use this file except in compliance with the License.
9 #  You may obtain a copy of the License at
10 #
11 #       http://www.apache.org/licenses/LICENSE-2.0
12 #
13 #  Unless required by applicable law or agreed to in writing, software
14 #  distributed under the License is distributed on an "AS IS" BASIS,
15 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 #  See the License for the specific language governing permissions and
17 #  limitations under the License.
18 # ============LICENSE_END=========================================================
19 ###################################################################################
20
21 apiVersion: apps/v1
22 kind: StatefulSet
23 metadata:
24   name: {{ .Values.rediscluster.name }}
25 spec:
26   serviceName: {{ .Values.service.name }}
27   replicas: {{ .Values.rediscluster.replicaCount }}
28   selector:
29     matchLabels:
30       app.kubernetes.io/name: {{ .Values.rediscluster.name }}
31       app.kubernetes.io/instance: {{ .Release.Name }}
32   template:
33     metadata:
34       labels:
35         app.kubernetes.io/name: {{ .Values.rediscluster.name }}
36         app.kubernetes.io/instance: {{ .Release.Name }}
37     spec:
38       topologySpreadConstraints:
39        - maxSkew: 1
40          topologyKey: kubernetes.io/hostname
41          whenUnsatisfiable: {{ .Values.topology.policyUnstisfiable }}
42          #whenUnsatisfiable: ScheduleAnyway
43          #whenUnsatisfiable: DoNotSchedule
44          labelSelector:
45            matchLabels:
46              app.kubernetes.io/name: {{ .Values.rediscluster.name }}
47              app.kubernetes.io/instance: {{ .Release.Name }}
48       containers:
49       - name: {{ .Values.container.name }}
50         image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
51         imagePullPolicy: {{ .Values.image.pullPolicy }}
52         ports:
53         - containerPort: 6379
54           name: client
55         - containerPort: 16379
56           name: gossip
57         command: ["/conf/update-node.sh", "redis-server", "/conf/redis.conf"]
58         env:
59         - name: POD_IP
60           valueFrom:
61             fieldRef:
62               fieldPath: status.podIP
63         volumeMounts:
64         - name: conf
65           mountPath: /conf
66           readOnly: false
67         - name: data
68           mountPath: /data
69           readOnly: false
70       volumes:
71       - name: conf
72         configMap:
73           name: {{ .Values.rediscluster.name }}-cm
74           defaultMode: 0755
75   volumeClaimTemplates:
76   - metadata:
77       name: data
78       labels:
79         app.kubernetes.io/name: {{ .Values.rediscluster.name }}
80         app.kubernetes.io/instance: {{ .Release.Name }}
81     spec:
82       accessModes: [ "ReadWriteOnce" ]
83       resources:
84         requests:
85           storage: {{ .Values.volume.storage }}