# redis-cluster-on-k8s **Repository Path**: meoom/redis-cluster-on-k8s ## Basic Information - **Project Name**: redis-cluster-on-k8s - **Description**: k8s上部署redis-cluster - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 5 - **Created**: 2021-04-07 - **Last Updated**: 2021-04-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #修改Dockerfile里的FROM基础镜像为原始redis版本,然后构建镜像 #修改redis-cluster.yaml里的镜像信息和存储信息 #部署redis-cluster kubectl apply -f ceph-secret.yaml -f redis-cluster.yaml #kubectl创建redis-cluster kubectl -n test exec -it redis-cluster-0 -- redis-cli --cluster create --cluster-replicas 1 $(kubectl -n test get pods -l app=redis-cluster -o jsonpath='{range.items[*]}{.status.podIP}:6379 ') #删除: kubectl -n test delete -f redis-cluster.yaml kubectl -n test delete pvc data-redis-cluster-0 data-redis-cluster-1 data-redis-cluster-2 data-redis-cluster-3 data-redis-cluster-4 data-redis-cluster-5 #访问 redis-cli -c -h redis-cluster-0.redis-cluster-hs.test.svc -p 6379 重构集群---当整个redis集群因为devops平台重启需要重建redis集群时执行 ---现已解决 进入每一个容器执行以下命令然后重启后,即可重建集群 redis-cli flushall && rm -fr dump.rdb nodes.conf appendonly.aof 如果集群报(error) CLUSTERDOWN Hash slot not served,在每个pod里执行以下命令并重建cluster即可 ---现已解决 redis-cli --cluster fix 127.0.0.1:6379 注意:nodeport不支持外部访问,因为会Redirected到pod ip,而外部无法访问k8s内部pod ip,需要redis6 gateway支持。 注意:现在单节点重启,多节点重启,或者因停电全部重启,或者副本数置为0都无需删除数据重建cluster。