在K8S中部署redis集群(3master+3slave)

 

  • 功能需求

 

     在K8S中部署redis集群(3master+3slave)

  • 实验环境

     k8s, 1台master+2台worknode

  • 操作步骤

 

Step1. 部署nfs

 

//在svi-master1上做nfs共享

yum -y install nfs-utils rpcbind

mkdir -p /data/redis/{cluster0,cluster1,cluster2,cluster3,cluster4,cluster5}

vim /etc/exports

/data/redis/cluster0 10.0.0.13/24(rw,sync,no_root_squash)
/data/redis/cluster1 10.0.0.13/24(rw,sync,no_root_squash)
/data/redis/cluster2 10.0.0.1324(rw,sync,no_root_squash)
/data/redis/cluster3 10.0.0.13/24(rw,sync,no_root_squash)
/data/redis/cluster4 10.0.0.13/24(rw,sync,no_root_squash)
/data/redis/cluster5 10.0.0.13/24(rw,sync,no_root_squash)

chmod -R 755 /data/redis 

exportfs -arv 

systemctl enable rpcbind && systemctl start rpcbind 

systemctl enable nfs && systemctl start nfs

//在svi-node1,svi-node2上安装nfs

yum -y install nfs-utils

 

#kubectl create deployment helloNginx --image=nginx --replicas=3

//查询部署的deployment以及pods

#kubectl get deploy, pods

Step2: 使用Service将Pods暴露出去

//以NodePort方式将端口暴露出去,

#kubectl expose deployment helloNginx --port=80 --targetPort=80 --type=NodePort

//查询部署的deployment以及pods

#kubectl get service

Step3: 浏览器访问应用

  http://<任意worknodeIP>:<service随机生成的3xxxx端口>/

 

posted @ 2022-04-08 20:36  VinceGod  阅读(281)  评论(0)    收藏  举报