User-Profile-Image
hankin
  • 5
  • centos7
  • docker
  • mysql
  • PostgreSQL
  • git/gitlab
  • ELK
  • python
    • python-Tornado
    • python-django
  • redis
  • nginx
  • kvm
  • proxmox
  • mongo
  • kubernetes
  • prometheus
  • GlusterFs
  • nfs
  • freeswitch
  • httpd
  • shell脚本
  • linux
  • fastdfs
  • nextcloud
  • openssl
  • openvpn
  • rabbitmq
  • sqlite
  • svn
  • java
  • ubuntu
  • vue2
  • wordpress
  • php
  • IOT物联网
  • 项目
  • 故障处理
  • 树莓派
  • 博客存档
  • 未分类
  • 杂项
  • #1742(无标题)
  • 新视野
  • 分类
    • 项目
    • 树莓派
    • 杂项
    • 未分类
    • 新视野
    • 故障处理
    • 博客存档
    • 交换机
    • wordpress
    • vue2
    • ubuntu
    • svn
    • sqlite
    • shell脚本
    • redis
    • rabbitmq
    • python-django
    • python
    • proxmox
    • prometheus
    • PostgreSQL
    • php
    • openvpn
    • openssl
    • nginx
    • nfs
    • nextcloud
    • mysql
    • mongo
    • linux
    • kvm
    • kubernetes
    • java
    • IOT物联网
    • httpd
    • GlusterFs
    • git/gitlab
    • freeswitch
    • fastdfs
    • ELK
    • docker
    • centos7
  • 页面
    • #1742(无标题)
  • 友链
      请到[后台->主题设置->友情链接]中设置。
Help?

Please contact us on our email for need any support

Support
    首页   ›   GlusterFs   ›   正文
GlusterFs

k8s使用glusterfs存储系统

2022-10-28 23:33:28
758  0 0

最近部署了k8s,默认使用的主机存储。主机/目录默认空间较小,并且部分容器对磁盘io要求较高。遂搭建glusterfs文件系统,并配置给k8s使用。
glusterfs搭建步骤见 https://www.cnblogs.com/tangshow/p/15930784.html

环境

cetons7已部署glusterfs主机三台(k8s也位于这三台上)
master1(node01) 192.168.2.134
master2(node01) 192.168.2.80
cli    (nfs)    192.168.2.131

注意:

默认情况下 Endpoints、pv 、pvc 都在default空间 ,在default使用glusterfs时不用指定空间
当需要在其他空间使用glusterfs时,需要创建Endpoints、pv 、pvc时都指定空间,例:
  metadata:
    namespace: kube-system

1 创建Endpoints 和对应的service

kubectl apply -f glusterfs-cluster.yaml

glusterfs-cluster.yam内容如下:

apiVersion: v1
kind: Endpoints
metadata:
  name: glusterfs-cluster
subsets:
- addresses:
  - ip: 192.168.2.134
  ports:
  - port: 49152
- addresses:
  - ip: 192.168.2.131
  ports:
  - port: 49152
- addresses:
  - ip: 192.168.2.80
  ports:
  - port: 49152

---
apiVersion: v1
kind: Service
metadata:
  name: glusterfs-cluster
spec:
  ports:
  - port: 49152

2 创建容器指定使用gluster做存储

kubectl apply -f nginx_test.yaml
# 为方便测试,此方法没有使用pv/pvc 直接指定"endpoints: glusterfs-cluster"


nginx_test.yaml内容如下:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment-test
spec:
  replicas: 1
  selector:
    matchLabels:
      name: nginx
  template:
    metadata:
      labels:
        name: nginx
    spec:
      containers:
        - name: nginx
          image: nginx
          ports:
            - containerPort: 80
          volumeMounts:
            - name: storage001
              mountPath: "/usr/share/nginx/html"
      volumes:
      - name: storage001
        glusterfs:
          endpoints: glusterfs-cluster
          path: models
          readOnly: false
评论 (0)

点击这里取消回复。

欢迎您 游客  

Copyright © 2025 网站备案号 : 蜀ICP备2022017747号
smarty_hankin 主题. Designed by hankin
主页
页面
  • #1742(无标题)
博主
tang.show
tang.show 管理员
linux、centos、docker 、k8s、mysql等技术相关的总结文档
213 文章 2 评论 202065 浏览
测试
测试