我已经使用kubernetes statefulset object
创建了集群很好的Redis集群,然后删除了statefulset对象重新部署,但是键入命令“ cluster nodes”以检查集群显示集群失败。
redis-cluster.yaml
初始redis集群群集节点可行
# the first time deploy redis-cluster
$ kubectl apply -f redis-cluster.yaml
# sts objects
$ kubectl get sts -n kube-ops
redis-app 6/6 6m58s
# create the cluster replicas as 1
$ kubectl -n kube-ops exec -it redis-app-0 -- redis-cli --cluster create \
-- cluster-replicas 1 $(kubectl get -n kube-ops pods -l app=redis -o \
jsonpath='{range.items[*]}{.status.podIP}:6379 ' )
# via one node of cluster
$ kubectl exec -it redis-app-0 bash -n kube-ops
> redis-cli -c
> cluster nodes
784f9d3930d7e00047fa6c8c53f3ea5c04bba4cb 10.244.3.171:6379@16379 slave
afc3aac801f1268ce8f7549deb3eb5eca92e178b 0 1603341990044 4 connected
5ece7b219e0dbd5a17abfeb3af2a8ad847049891 10.244.0.85:6379@16379 master - 0
1603341991053 3 connected 10923-16383
039aec28c71d0becc77d5703bb16775dd55796d9 10.244.0.86:6379@16379 slave
5ece7b219e0dbd5a17abfeb3af2a8ad847049891 0 1603341991000 6 connected
2f30dc3d674e3dad98f42d2814e537a8bb458ed2 10.244.1.99:6379@16379 master - 0
1603341990000 2 connected 5461-10922
103ece1c43de20ab7f995f2e23662551cb1b1606 10.244.1.100:6379@16379 slave
2f30dc3d674e3dad98f42d2814e537a8bb458ed2 0 1603341991053 5 connected
afc3aac801f1268ce8f7549deb3eb5eca92e178b 10.244.3.170:6379@16379 myself,master
- 0 1603341988000 1 connected 0-5460
重新部署redis集群
# delete before sts
$ kubectl delete -f redis-cluster.yaml
# redeploy redis-cluster
$ kubectl apply -f redis-cluster.yaml
# check the cluster status via one of cluster
$ kubectl exec redis-app-0 -it bash -n kube-ops
> redis-cli -c
# output error as following
> cluster nodes
输出错误
root@redis-app-0:/data# redis-cli
127.0.0.1:6379> cluster nodes
c8cab83dedd37c9b84707758a2621d72dde4ca6b 10.244.1.78:6379@16379 master,fail? - 1603290611001
1603290609051 3 connected 10923-16383
f4a3fa3d7b10903f32f6d46054f593541a82ee3c 10.244.1.79:6379@16379 slave,fail?
cfa04f400535980d21ec4a7db5320fb477c3c90d 1603290611613 1603290609051 2 connected
7796faa8698d38d877657e488faa63f76306b531 10.244.0.71:6379@16379 slave,fail?
c8cab83dedd37c9b84707758a2621d72dde4ca6b 1603290609998 1603290609051 3 connected
f4a56ba199724dd971d2c5d32079954c4f43a9e4 10.244.3.140:6379@16379 slave,fail?
22072f4f2d1c89f9f01d38a8c4b77a7d726c795e 1603290611613 1603290609051 1 connected
cfa04f400535980d21ec4a7db5320fb477c3c90d 10.244.0.70:6379@16379 master,fail? - 1603290611613
1603290609051 2 connected 5461-10922
22072f4f2d1c89f9f01d38a8c4b77a7d726c795e 10.244.3.142:6379@16379 myself,master - 0 1603290609051 1
connected 0-5460