赞
踩
helm部署redis集群 一: 配置: nfs存储:100G 节点1:node1-iot.com 192.168.0.201 节点2:node2-iot.com 192.168.0.202 节点3:node3-iot.com 192.168.0.204 二:部署storageclass [root@master-iot ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION master-iot.com Ready master 37h v1.17.0 node1-iot.com Ready <none> 37h v1.17.0 node2-iot.com Ready <none> 37h v1.17.0 node3-iot.com Ready <none> 24m v1.17.0 [root@master-iot ~]# helm install stable/nfs-client-provisioner --set nfs.server=192.168.0.203 --set nfs.path=/opt 注意修改nfs地址和路径 [root@master-iot ~]# kubectl get pods NAME READY STATUS RESTARTS AGE giggly-goose-nfs-client-provisioner-7b94d4dc4f-6dhw4 1/1 Running 0 53m 三:helm部署redis集群 [root@master-iot redis]# cat values.yaml image: repository: redis tag: 5.0.5 pullPolicy: IfNotPresent redis: resources: requests: memory: 200Mi cpu: 100m limits: memory: 700Mi sentinel: resources: requests: memory: 200Mi cpu: 100m limits: memory: 200Mi persistentVolume: enabled: true storageClass: "nfs-client" accessModes: - ReadWriteOnce size: 10Gi [root@master-iot redis]# helm install stable/redis-ha --name=redis-ha --namespace=redis [root@master-iot redis]# kubectl get all -n redis NAME READY STATUS RESTARTS AGE pod/redis-ha-server-0 2/2 Running 3 24m pod/redis-ha-server-1 2/2 Running 0 24m pod/redis-ha-server-2 2/2 Running 0 24m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/redis-ha ClusterIP None <none> 6379/TCP,26379/TCP 24m service/redis-ha-announce-0 ClusterIP 10.96.177.155 <none> 6379/TCP,26379/TCP 24m service/redis-ha-announce-1 ClusterIP 10.96.255.63 <none> 6379/TCP,26379/TCP 24m service/redis-ha-announce-2 ClusterIP 10.96.166.228 <none> 6379/TCP,26379/TCP 24m NAME READY AGE statefulset.apps/redis-ha-server 3/3 24m 四:测试 [root@master-iot redis]# kubectl get svc -n redis NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE redis-ha ClusterIP None <none> 6379/TCP,26379/TCP 25m redis-ha-announce-0 ClusterIP 10.96.177.155 <none> 6379/TCP,26379/TCP 25m redis-ha-announce-1 ClusterIP 10.96.255.63 <none> 6379/TCP,26379/TCP 25m redis-ha-announce-2 ClusterIP 10.96.166.228 <none> 6379/TCP,26379/TCP 25m [root@master-iot redis]# redis-cli -h 10.96.166.228 -p 6379 10.96.166.228:6379> INFO replication # Replication role:master connected_slaves:2 min_slaves_good_slaves:2 slave0:ip=10.96.255.63,port=6379,state=online,offset=218033,lag=1 slave1:ip=10.96.177.155,port=6379,state=online,offset=218174,lag=0 master_replid:ebe58c1995af9ee29119744503a20a805aab28ae master_replid2:7ff4e6ea64e6f76766409679e6f6d18867dfa7f2 master_repl_offset:218174 second_repl_offset:26098 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:868 repl_backlog_histlen:217307 10.96.166.228:6379> set foo1 bar1 OK 10.96.166.228:6379> set foo2 bar2 OK [root@master-iot redis]# redis-cli -h 10.96.255.63 -p 6379 10.96.255.63:6379> KEYS * 1) "foo1" 2) "foo2" 接下来删除一个pod看是否重建 [root@master-iot redis]# kubectl get pods -n redis NAME READY STATUS RESTARTS AGE redis-ha-server-0 2/2 Running 3 32m redis-ha-server-1 2/2 Running 0 32m redis-ha-server-2 2/2 Running 0 32m [root@master-iot redis]# kubectl delete pod redis-ha-server-0 -n redis pod "redis-ha-server-0" deleted [root@master-iot redis]# kubectl get pods -n redis NAME READY STATUS RESTARTS AGE redis-ha-server-0 2/2 Running 0 18s redis-ha-server-1 2/2 Running 0 33m redis-ha-server-2 2/2 Running 0 33m 重建完毕 [root@master-iot redis]# redis-cli -h 10.96.177.155 -p 6379 10.96.177.155:6379> KEYS * 1) "foo1" 2) "foo2" 数据保持一致
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。