当前位置:网站首页>多个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集群造成影响。“多中心共享存储”由此诞生了。
边栏推荐
- ceres-solver和g2o性能比较
- RuntimeError: CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling `cublasCreate(handle)`问题解决
- Installing redis and windows extension method under win system
- JVM 全面深入
- 【OpenCV】形态学滤波(2):开运算、形态学梯度、顶帽、黑帽
- The difference between string constants and string objects when allocating memory
- 拼多多败诉:“砍价免费拿”侵犯知情权但不构成欺诈,被判赔400元
- Stack and queue-p79-10 [2014 unified examination real question]
- MySQL卸载文档-Windows版
- Etcd database source code analysis -- starting from the start function of raftnode
猜你喜欢

项目实战 五 拟合直线 获得中线

Ha Qu projection dark horse posture, only half a year to break through the 1000 yuan projector market!

POI导出Excel:设置字体、颜色、行高自适应、列宽自适应、锁住单元格、合并单元格...

What are the classic database questions in the interview?

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

How to install swoole under window

ip地址那点事
![[start from scratch] detailed process of deploying yolov5 in win10 system (CPU, no GPU)](/img/77/bd80ed602208be6a9ef8be60c6ad06.png)
[start from scratch] detailed process of deploying yolov5 in win10 system (CPU, no GPU)

Prompt for channel security on the super-v / device defender side when installing vmmare

LM小型可编程控制器软件(基于CoDeSys)笔记二十三:伺服电机运行(步进电机)相对坐标转换为绝对坐标
随机推荐
matlab / ENVI 主成分分析实现及结果分析
算法---比特位计数(Kotlin)
ESXI挂载移动(机械)硬盘详细教程
Linear algebra (1)
Redis (I) -- getting to know redis for the first time
POI export to excel: set font, color, row height adaptation, column width adaptation, lock cells, merge cells
JVM 全面深入
Learning notes | data Xiaobai uses dataease to make a large data screen
FPGA课程:JESD204B的应用场景(干货分享)
使用TCP/IP四层模型进行网络传输的基本流程
SVN version management in use replacement release and connection reset
Basic DOS commands
Abnova循环肿瘤DNA丨全血分离,基因组DNA萃取分析
string(讲解)
软件测试到了35岁,真的就干不动了吗?
Knight defeats demon king (Backpack & DP)
dolphinscheduler3. X local startup
JWT certification
【从零开始】win10系统部署Yolov5详细过程(CPU,无GPU)
Haqi projection Black Horse posture, avec seulement six mois de forte pénétration du marché des projecteurs de 1000 yuans!