当前位置:网站首页>多个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
边栏推荐
- Will low code help enterprises' digital transformation make programmers unemployed?
- Three forms of multimedia technology commonly used in enterprise exhibition hall design
- POJ 1182 :食物链(并查集)[通俗易懂]
- Redis publishing and subscription
- Draw squares with Obama (Lua)
- A hodgepodge of ICER knowledge points (attached with a large number of topics, which are constantly being updated)
- CVPR 2022 - learning non target knowledge for semantic segmentation of small samples
- [C language] string function
- Industry case | digital operation base helps the transformation of life insurance industry
- I feel cheated. Wechat tests the function of "size number" internally, and two wechat can be registered with the same mobile number
猜你喜欢

Will low code help enterprises' digital transformation make programmers unemployed?

行业案例|数字化经营底座助力寿险行业转型

ES6笔记一

Reuse of data validation framework Apache bval

【Unity Shader】插入Pass实现模型遮挡X光透视效果

50亿,福建又诞生一只母基金

Differences between rip and OSPF and configuration commands

RISCV64

Calculation of torque target value (ftorque) in servo torque control mode

直播预约通道开启!解锁音视频应用快速上线的秘诀
随机推荐
数据验证框架 Apache BVal 再使用
静态路由配置
如何选择合适的自动化测试工具?
NAT地址转换
Policy mode - unity
Wireshark analyzes packet capture data * cap
Mathematical analysis_ Notes_ Chapter 11: Fourier series
Hutool - lightweight DB operation solution
Redis
Recommend free online SMS receiving platform in 2022 (domestic and foreign)
PTA 1102 teaching Super Champion volume
Reinforcement learning - learning notes 8 | Q-learning
Embedded interview questions (algorithm part)
GSAP animation library
学习open62541 --- [67] 添加自定义Enum并显示名字
[paper sharing] where's crypto?
【Base64笔记】「建议收藏」
[information security laws and regulations] review
coming! Gaussdb (for Cassandra) new features appear
The moveposition function of rigidbody2d of unity2d solves the problem of people or screen jitter when moving