Last active
August 28, 2022 11:33
-
-
Save jithin-scaria/f6e9195af5b5e5640722c699fb63e25b to your computer and use it in GitHub Desktop.
StatefulSet definition for redis cluster in K8s
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: StatefulSet | |
metadata: | |
name: redis | |
namespace: redis | |
spec: | |
serviceName: redis | |
replicas: 6 # 6 replicas, 3 master and 3 replicas(slaves) | |
selector: | |
matchLabels: | |
app: redis | |
template: | |
metadata: | |
labels: | |
app: redis | |
spec: | |
initContainers: | |
- name: config | |
image: redis:7.0.0-alpine | |
command: [ "sh", "-c" ] | |
args: | |
- | | |
if [ -f "/conf/redis.conf" ]; then | |
echo "config exists /conf/redis.conf .. not creating new" | |
else | |
echo "config doesn't exist copying to /conf/redis.conf" | |
cp /tmp/conf/redis.conf /conf/redis.conf | |
fi | |
volumeMounts: | |
- name: storage | |
subPath: conf | |
mountPath: /conf | |
- name: config | |
mountPath: /tmp/conf/ | |
containers: | |
- name: redis | |
image: redis:7.0.0-alpine | |
command: ["redis-server"] | |
args: ["/conf/redis.conf"] | |
resources: | |
requests: | |
memory: "100M" | |
limits: | |
memory: "2000M" | |
ports: | |
- containerPort: 6379 | |
name: redis | |
volumeMounts: | |
- name: storage | |
mountPath: /data | |
subPath: data | |
- name: storage | |
mountPath: /conf | |
subPath: conf | |
- name: config-acl | |
mountPath: /conf/acl/ | |
volumes: | |
- name: config | |
configMap: | |
name: redis-config | |
- name: config-acl | |
configMap: | |
name: redis-acl | |
volumeClaimTemplates: | |
- metadata: | |
name: storage | |
spec: | |
accessModes: [ "ReadWriteOnce" ] | |
resources: | |
requests: | |
storage: 50Mi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment