当前位置:网站首页>多个kubernetes集群如何实现共享同一个存储
多个kubernetes集群如何实现共享同一个存储
2022-07-07 17:03:00 【傻啦猫@[email protected]】
引言
今天工作的时候想了一个问题:项目上使用的是双集群部署应用,但是使用的存储却只有一个,还起来一个怪有趣的名字,叫“多中心共享存储”。这样做的优点很明显,一个存储实现了多集群的数据共享,这个也很好理解,虽然是多个集群,但是应用却是相同的,数据理应可以共享。那么是如何做的呢?思考许久,想到了破解方法。
环境准备
服务器准备
准备了7台服务器,这些服务器在同一个网络之内,可以互相访问。6台服务器可以建两个kubernetes集群(一主两从),还有一台作为NFS文件系统的主节点。

资源分配
k8s集群1 | k8s集群2 | NFS |
---|---|---|
192.168.0.135 | 192.168.0.163 | 192.168.0.185 |
192.168.0.198 | 192.168.0.247 | |
192.168.0.12 | 192.168.0.167 |
说明:NFS是网络文件系统,单独给一台服务器作为server,其他服务器都是client。
安装NFS
所有节点执行
yum install -y nfs-utils
nfs主节点(192.168.0.185)执行
echo "/nfs/data/ *(insecure,rw,sync,no_root_squash)" > /etc/exports # 暴露了目录/nfs/data/,`*`表示所有节点都可以访问。
mkdir -p /nfs/data
systemctl enable rpcbind --now
systemctl enable nfs-server --now
# 配置生效
exportfs -r
# 检查验证
[[email protected] ~]# exportfs
/nfs/data <world>
[[email protected] ~]#
nfs从节点执行
# 展示192.168.0.185有哪些目录可以挂载
showmount -e 192.168.0.185 # ip改成自己的主节点ip
mkdir -p /nfs/data
# 将本地目录和远程目录进行挂载
mount -t nfs 192.168.0.185:/nfs/data /nfs/data
验证
# 在任意节点写入一个测试文件
echo "hello nfs server" > /nfs/data/test.txt

通过在任意节点写入一个文件,在其他节点都可以看到文件内容。这样便实现了kubernetes多个集群的文件共享。将NFS主节点单独维护,不会对kubernetes集群造成影响。“多中心共享存储”由此诞生了。
本文由 mdnice 多平台发布
版权声明
本文为[傻啦猫@[email protected]]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_45842494/article/details/125650136
边栏推荐
- 直播预约通道开启!解锁音视频应用快速上线的秘诀
- LeetCode 890(C#)
- The live broadcast reservation channel is open! Unlock the secret of fast launching of audio and video applications
- Interview vipshop internship testing post, Tiktok internship testing post [true submission]
- Comparison and selection of kubernetes Devops CD Tools
- Micro service remote debug, nocalhost + rainbow micro service development second bullet
- ip netns 命令(备忘)
- DeSci:去中心化科学是Web3.0的新趋势?
- 国内的软件测试会受到偏见吗
- 国内首次!这家中国企业的语言AI实力被公认全球No.2!仅次于谷歌
猜你喜欢
将模型的记忆保存下来!Meta&UC Berkeley提出MeMViT,建模时间支持比现有模型长30倍,计算量仅增加4.5%...
String type, constant type and container type of go language
Reuse of data validation framework Apache bval
【软件测试】从企业版BOSS直聘,看求职简历,你没被面上是有原因的
App capture of charles+drony
Industry case | digital operation base helps the transformation of life insurance industry
The live broadcast reservation channel is open! Unlock the secret of fast launching of audio and video applications
面试唯品会实习测试岗、抖音实习测试岗【真实投稿】
Simple configuration of single arm routing and layer 3 switching
Micro service remote debug, nocalhost + rainbow micro service development second bullet
随机推荐
[tpm2.0 principle and Application guide] Chapter 16, 17 and 18
前首富,沉迷种田
Review of network attack and defense
"Decryption" Huawei machine vision Corps: Huawei is moving up and the industry is moving forward
GSAP animation library
gsap动画库
微信网页调试8.0.19换掉X5内核,改用xweb,所以x5调试方式已经不能用了,现在有了解决方案
线程池的拒绝策略
[sword finger offer] 59 - I. maximum value of sliding window
Standard ACL and extended ACL
Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布
Idea completely uninstalls installation and configuration notes
App capture of charles+postern
2022.07.02
LeetCode 497(C#)
我感觉被骗了,微信内测 “大小号” 功能,同一手机号可注册两个微信
Nat address translation
2022年推荐免费在线接收短信平台(国内、国外)
SQLite SQL exception near "with": syntax error
[paper sharing] where's crypto?