跳至主要內容

Helm安装Redis

知识库容器技术kubernetes实战kubernetes实战小于 1 分钟

Redis 1主2从3哨兵

参考文档open in new window

1、添加仓库

helm repo add bitnami https://charts.bitnami.com/bitnami
## 更新仓库
helm repo update
## 搜索redis
helm search repo bitnami/redis
# NAME                    CHART VERSION   APP VERSION     DESCRIPTION
# bitnami/redis           17.8.0          7.0.8           Redis(R) is an open source, advanced key-value ...
# bitnami/redis-cluster   8.3.8           7.0.8           Redis(R) is an open source, scalable, distribut...

2. 安装Redis

## 安装redis集群
helm install redis bitnami/redis --version 17.8.0 \
  --set global.redis.password=123456 \
  --set fullnameOverride=redis \
  --set architecture=replication \
  --set sentinel.enabled=true \
  --set sentinel.persistence.enabled=true \
  --namespace=devops-redis --create-namespace
## 查看资源
helm -n devops-redis list
kubectl -n devops-redis get pod,pvc,svc
## 导出redis密码
export REDIS_PASSWORD=$(kubectl get secret --namespace devops-redis redis -o jsonpath="{.data.redis-password}" | base64 -d)
## 运行一个客户端pod
kubectl run --namespace devops-redis redis-client --restart='Never'  --env REDIS_PASSWORD=$REDIS_PASSWORD  --image docker.io/bitnami/redis:7.0.8-debian-11-r13 --command -- sleep infinity
## 进去客户端
kubectl exec --tty -i redis-client --namespace devops-redis -- bash
#### 访问主从集群
REDISCLI_AUTH="$REDIS_PASSWORD" redis-cli -h redis -p 6379
info Replication
#### 哨兵访问
REDISCLI_AUTH="$REDIS_PASSWORD" redis-cli -h redis-headless -p 26379
info Sentinel

Redis集群 3主3从

helm install redis-c bitnami/redis-cluster --version 8.3.8 \
  --namespace=devops-redis --create-namespace