2022-01-24 22:23:00 +01:00
..
2021-08-14 08:39:00 +10:00
2020-08-13 11:21:07 +10:00

Redis on Kubernetes

Create a cluster with kind

kind create cluster --name redis --image kindest/node:v1.18.4

Namespace

kubectl create ns redis

Storage Class

kubectl get storageclass
NAME                 PROVISIONER             RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
standard (default)   rancher.io/local-path   Delete          WaitForFirstConsumer   false                  84s

Deployment: Redis nodes

cd storage/redis/kubernetes/
kubectl apply -n redis -f ./redis/redis-configmap.yaml
kubectl apply -n redis -f ./redis/redis-statefulset.yaml

kubectl -n redis get pods
kubectl -n redis get pv

kubectl -n redis logs redis-0
kubectl -n redis logs redis-1
kubectl -n redis logs redis-2

Test replication status

kubectl -n redis exec -it redis-0 sh
redis-cli 
auth a-very-complex-password-here
info replication

Deployment: Redis Sentinel (3 instances)

cd storage/redis/kubernetes/
kubectl apply -n redis -f ./sentinel/sentinel-statefulset.yaml

kubectl -n redis get pods
kubectl -n redis get pv
kubectl -n redis logs sentinel-0