当前位置:网站首页>多个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
边栏推荐
- Yunjing network technology interview question [Hangzhou multi tester] [Hangzhou multi tester _ Wang Sir]
- 标准ACL与扩展ACL
- Tsinghua, Cambridge and UIC jointly launched the first Chinese fact verification data set: evidence-based, covering many fields such as medical society
- Is AI more fair than people in the distribution of wealth? Research on multiplayer game from deepmind
- [mime notes]
- ip netns 命令(备忘)
- Thread pool and singleton mode and file operation
- Usage of PHP interview questions foreach ($arr as $value) and foreach ($arr as $value)
- Scientists have observed for the first time that the "electron vortex" helps to design more efficient electronic products
- Short selling, overprinting and stock keeping, Oriental selection actually sold 2.66 million books in Tiktok in one month
猜你喜欢

Three forms of multimedia technology commonly used in enterprise exhibition hall design

Borui data was selected in the 2022 love analysis - Panoramic report of it operation and maintenance manufacturers

Antisamy: a solution against XSS attack tutorial

Mathematical analysis_ Notes_ Chapter 11: Fourier series

In 2021, the national average salary was released. Have you reached the standard?

前首富,沉迷种田

企业展厅设计中常用的三种多媒体技术形式

gsap动画库

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

我感觉被骗了,微信内测 “大小号” 功能,同一手机号可注册两个微信
随机推荐
Cadre de validation des données Apache bval réutilisé
For friends who are not fat at all, nature tells you the reason: it is a genetic mutation
POJ 2392 Space Elevator
【塔望方法论】塔望3W消费战略 - U&A研究法
Will low code help enterprises' digital transformation make programmers unemployed?
Simple configuration of single arm routing and layer 3 switching
2022-07-04 matlab reads video frames and saves them
The performance and efficiency of the model that can do three segmentation tasks at the same time is better than maskformer! Meta & UIUC proposes a general segmentation model with better performance t
App capture of charles+postern
初识缓存以及ehcache初体验「建议收藏」
【Base64笔记】「建议收藏」
微信网页调试8.0.19换掉X5内核,改用xweb,所以x5调试方式已经不能用了,现在有了解决方案
Redis
String type, constant type and container type of go language
Complete e-commerce system
直播预约通道开启!解锁音视频应用快速上线的秘诀
Save the memory of the model! Meta & UC Berkeley proposed memvit. The modeling time support is 30 times longer than the existing model, and the calculation amount is only increased by 4.5%
App capture of charles+drony
3.关于cookie
[unity shader] insert pass to realize the X-ray perspective effect of model occlusion