# cat redis-configmaps.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: redis-standalone-conf
data:
redis.conf: |
bind 0.0.0.0
port 6379
requirepass redis
appendonly yes
cluster-config-file nodes-6379.conf
pidfile /redis/log/redis-6379.pid
cluster-config-file /redis/conf/redis.conf
dir /redis/data/
logfile /redis/log/redis-6379.log
cluster-node-timeout 5000
protected-mode no
###################################
# cat redis-standalone-pvc.yml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: redis-standalone-pvc
spec:
storageClassName: rook-ceph-block
accessModes: ["ReadWriteOnce","ReadWriteMany"]
resources:
requests:
storage: 50Gi
###################################
# cat redis-standalone-statefulset.yml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: redis-standalone
spec:
replicas: 1
serviceName: redis-standalone
selector:
matchLabels:
name: redis-standalone
template:
metadata:
labels:
name: redis-standalone
spec:
initContainers:
- name: init-redis-standalone
image: busybox
command: ['sh', '-c', 'mkdir -p /redis/log/;mkdir -p /redis/conf/;mkdir -p /redis/data/']
volumeMounts:
- name: redis-standalone-pvc
mountPath: /redis/
containers:
- name: redis-standalone
image: redis:5.0.6
imagePullPolicy: IfNotPresent
command:
- sh
- -c
- "exec redis-server /redis/conf/redis.conf"
ports:
- containerPort: 6379
name: redis
protocol: TCP
volumeMounts:
- name: redis-config
mountPath: /redis/conf/
- name: redis-standalone-pvc
mountPath: /redis/
volumes:
- name: redis-config
configMap:
name: redis-standalone-conf
- name: redis-standalone-pvc
persistentVolumeClaim:
claimName: redis-standalone-pvc
###################################
# cat redis-standalone-service.yml
kind: Service
apiVersion: v1
metadata:
labels:
name: redis-standalone
name: redis-standalone
spec:
type: ClusterIP
ports:
- name: redis
port: 6379
targetPort: 6379
selector:
name: redis-standalone
###################################
kubectl apply -f redis-configmaps.yaml
kubectl apply -f redis-standalone-pvc.yml
kubectl apply -f redis-standalone-service.yml
kubectl apply -f redis-standalone-statefulset.yml