当前位置:网站首页>多个kubernetes集群如何实现共享同一个存储
多个kubernetes集群如何实现共享同一个存储
2022-07-07 02:31:00 【江小南】
引言
今天工作的时候想了一个问题:项目上使用的是双集群部署应用,但是使用的存储却只有一个,还起来一个怪有趣的名字,叫“多中心共享存储”。这样做的优点很明显,一个存储实现了多集群的数据共享,这个也很好理解,虽然是多个集群,但是应用却是相同的,数据理应可以共享。那么是如何做的呢?思考许久,想到了破解方法。
环境准备
服务器准备
准备了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集群造成影响。“多中心共享存储”由此诞生了。
边栏推荐
- Handling hardfault in RT thread
- Symmetric binary tree [tree traversal]
- VIM mapping large K
- Etcd database source code analysis -- starting from the start function of raftnode
- C interview encryption program: input plaintext by keyboard, convert it into ciphertext through encryption program and output it to the screen.
- Matlab / envi principal component analysis implementation and result analysis
- ceres-solver和g2o性能比较
- A program lets you understand what static inner classes, local inner classes, and anonymous inner classes are
- Redhat5 installing vmware tools under virtual machine
- 哈趣投影黑馬之姿,僅用半年强勢突圍千元投影儀市場!
猜你喜欢

Shared memory for interprocess communication

Tkinter window selects PCD file and displays point cloud (open3d)

Pinduoduo lost the lawsuit: "bargain for free" infringed the right to know but did not constitute fraud, and was sentenced to pay 400 yuan

MySQL的安装

力扣62 不同路径(从矩阵左上到右下的所有路径数量) (动态规划)

哈趣投影黑马之姿,仅用半年强势突围千元投影仪市场!
![[GNN] graphic gnn:a gender Introduction (including video)](/img/b3/0855885dafa7afaa7375b8d2195974.png)
[GNN] graphic gnn:a gender Introduction (including video)

Force deduction 62 different paths (the number of all paths from the upper left to the lower right of the matrix) (dynamic planning)

How to use wechat cloud hosting or cloud functions for cloud development of unapp development applet

Leite smart home longhaiqi: from professional dimming to full house intelligence, 20 years of focus on professional achievements
随机推荐
C language interview to write a function to find the first public string in two strings
学习笔记|数据小白使用DataEase制作数据大屏
Shared memory for interprocess communication
MySQL的安装
dolphinscheduler3.x本地启动
POI export to excel: set font, color, row height adaptation, column width adaptation, lock cells, merge cells
拼多多败诉:“砍价免费拿”侵犯知情权但不构成欺诈,被判赔400元
How to find the literature of a foreign language journal?
MySQL(十)
Niuke Xiaobai monthly race 52 E. sum logarithms in groups (two points & inclusion and exclusion)
Leite smart home longhaiqi: from professional dimming to full house intelligence, 20 years of focus on professional achievements
算法---比特位计数(Kotlin)
精准时空行程流调系统—基于UWB超高精度定位系统
VIM mapping large K
MySQL卸载文档-Windows版
一段程序让你明白什么静态内部类,局部内部类,匿名内部类
SVN version management in use replacement release and connection reset
循环肿瘤细胞——Abnova 解决方案来啦
使用TCP/IP四层模型进行网络传输的基本流程
2022Android面试必备知识点,一文全面总结