基于k8s集群的redis-cluster集群

一、提前准备好nfs存储

[root@k8s-master ~]# yum -y install nfs-utils nfs-common rpcbind
[root@k8s-master ~]# mkdir /nfsdata
[root@k8s-master ~]# chmod -R 777 /nfsdata
[root@k8s-master ~]# vim /etc/exports
/nfsdata *(rw,no_root_squash,sync,no_all_squash)
[root@k8s-master ~]# systemctl start rpcbind nfs
[root@k8s-master ~]# systemctl status nfs

# node节点
yum -y install nfs-utils nfs-common

二、制作动态存储

1.安装helm工具
[root@k8s-master ~]#  wget https://get.helm.sh/helm-v3.10.1-linux-amd64.tar.gz
--2024-08-06 15:53:55--  https://get.helm.sh/helm-v3.10.1-linux-amd64.tar.gz
正在解析主机 get.helm.sh (get.helm.sh)... 152.199.39.108, 2606:2800:247:1cb7:261b:1f9c:2074:3c
正在连接 get.helm.sh (get.helm.sh)|152.199.39.108|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:14565908 (14M) [application/x-tar]
正在保存至: “helm-v3.10.1-linux-amd64.tar.gz”

100%[=======================================================================>] 14,565,908   157KB/s 用时 46s    

2024-08-06 15:54:43 (312 KB/s) - 已保存 “helm-v3.10.1-linux-amd64.tar.gz” [14565908/14565908])

[root@k8s-master ~]# tar -xzvf helm-v3.10.1-linux-amd64.tar.gz 
linux-amd64/
linux-amd64/helm
linux-amd64/LICENSE
linux-amd64/README.md
[root@k8s-master ~]# cp linux-amd64/helm  /usr/bin/
[root@k8s-master ~]# helm version
version.BuildInfo{Version:"v3.10.1", GitCommit:"9f88ccb6aee40b9a0535fcc7efea6055e1ef72c9", GitTreeState:"clean", GoVersion:"go1.18.7"}
2.配置helm下载源
[root@k8s-master ~]# helm repo add stable  http://mirror.azure.cn/kubernetes/charts
"stable" has been added to your repositories
[root@k8s-master ~]# helm repo list
NAME    URL                                     
stable  http://mirror.azure.cn/kubernetes/charts
3.创建storageclass与nfs的目录相关联
[root@k8s-master ~]# helm install nfs-redis stable/nfs-client-provisioner --set nfs.server=192.168.22.134 --set nfs.path=/nfsdata
WARNING: This chart is deprecated
NAME: nfs-redis
LAST DEPLOYED: Tue Aug  6 16:01:14 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
[root@k8s-master ~]# helm list
NAME            NAMESPACE       REVISION        UPDATED                                 STATUS          CHART                            APP VERSION
nfs-redis       default         1               2024-08-06 16:01:14.424540014 +0800 CST deployed        nfs-client-provisioner-1.2.11    3.1.0      
[root@k8s-master ~]# kubectl get pod
NAME                                                READY   STATUS    RESTARTS   AGE
nfs-redis-nfs-client-provisioner-7bd85b55f4-p26ks   1/1     Running   0          39s

[root@k8s-master ~]# kubectl get sc
NAME         PROVISIONER                                      RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
nfs-client   cluster.local/nfs-redis-nfs-client-provisioner   Delete          Immediate           true                   53s
三、redis配置文件configmap
[root@k8s-master redis]# vim redis.conf
[root@k8s-master redis]# cat redis.conf 
appendonly yes
cluster-enabled yes
cluster-config-file /var/lib/redis/nodes.conf
cluster-node-timeout 5000
dir /var/lib/redis
port 6379
[root@k8s-master redis]#  kubectl create configmap redis-conf --from-file=redis.conf
configmap/redis-conf created
[root@k8s-master redis]# kubectl get cf
error: the server doesn't have a resource type "cf"
[root@k8s-master redis]# kubectl get cm
NAME         DATA   AGE
redis-conf   1      19s

四、创建Headless  service


                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值