redis主从 on k8s
参考
https://github.com/bitnami/charts/tree/main/bitnami/redis/#installing-the-chart
添加仓库
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
helm search repo redis
默认配置
https://raw.githubusercontent.com/bitnami/charts/main/bitnami/redis/values.yaml
#持久化
--set global.storageClass=managed-nfs-storage
默认主从模式
helm install -n db redis --set global.redis.password=gaojinbo.com bitnami/redis
单机模式
helm install -n db redis --set architecture=standalone --set global.redis.password=gaojinbo.com bitnami/redis
命令行客户端
export REDIS_PASSWORD=$(kubectl get secret --namespace db redis -o jsonpath="{.data.redis-password}" | base64 -d)
kubectl run --namespace db redis-client --restart='Never' --env REDIS_PASSWORD=$REDIS_PASSWORD --image docker.io/bitnami/redis:7.2.3-debian-11-r1 --command -- sleep infinity
kubectl exec --tty -i redis-client \
--namespace db -- bash
REDISCLI_AUTH="$REDIS_PASSWORD" redis-cli -h redis-master
REDISCLI_AUTH="$REDIS_PASSWORD" redis-cli -h redis-replicas