返回介绍

PART Ⅰ : 容器云OPENSHIFT

PART Ⅱ:容器云 KUBERNETES

PART Ⅲ:持续集成与持续部署

PART Ⅴ:日志/监控/告警

PART Ⅵ:基础

PART Ⅶ:数据存储、处理

PART VIII:CODE

PART X:HACKINTOSH

PART XI:安全

Glusterfs Provisioner

发布于 2024-06-08 21:16:47 字数 5762 浏览 0 评论 0 收藏 0

Prerequisite

配置ansible主机清单/etc/ansible/hosts

[OSEv3:children]
...
glusterfs
​
[OSEv3:vars]
...
openshift_storage_glusterfs_namespace=app-storage
openshift_storage_glusterfs_storageclass=true
openshift_storage_glusterfs_storageclass_default=false
openshift_storage_glusterfs_block_deploy=true
openshift_storage_glusterfs_block_host_vol_size=100
openshift_storage_glusterfs_block_storageclass=true
openshift_storage_glusterfs_block_storageclass_default=false
​
[glusterfs]
allinone311.okd.curiouser.com glusterfs_devices='[ "/dev/vdf" ]'
node1.okd.curiouser.com glusterfs_devices='[ "/dev/vdd" ]'
node2.okd.curiouser.com glusterfs_devices='[ "/dev/vdd" ]'
#至少是三个节点

glusterfs节点上安装软件

yum install glusterfs-fuse && \
yum update glusterfs-fuse

配置glusterfs节点上的Selinux

setsebool -P virt_sandbox_use_fusefs on && \
setsebool -P virt_use_fusefs on

执行openshift ansible playbook

ansible-playbook /root/openshift-ansible/playbooks/openshift-glusterfs/config.yml

配置ansible主机清单/etc/ansible/hosts

[OSEv3:children]
...
glusterfs
​
[OSEv3:vars]
...
openshift_storage_glusterfs_namespace=app-storage
openshift_storage_glusterfs_storageclass=true
openshift_storage_glusterfs_storageclass_default=false
openshift_storage_glusterfs_block_deploy=true
openshift_storage_glusterfs_block_host_vol_size=100
openshift_storage_glusterfs_block_storageclass=true
openshift_storage_glusterfs_block_storageclass_default=false
openshift_storage_glusterfs_is_native=false
openshift_storage_glusterfs_heketi_is_native=true
openshift_storage_glusterfs_heketi_executor=ssh
openshift_storage_glusterfs_heketi_ssh_port=22
openshift_storage_glusterfs_heketi_ssh_user=root
openshift_storage_glusterfs_heketi_ssh_sudo=false
openshift_storage_glusterfs_heketi_ssh_keyfile="/root/.ssh/id_rsa"
​
[glusterfs]
gluster1.example.com glusterfs_ip=192.168.10.11 glusterfs_devices='[ "/dev/xvdc", "/dev/xvdd" ]'
gluster2.example.com glusterfs_ip=192.168.10.12 glusterfs_devices='[ "/dev/xvdc", "/dev/xvdd" ]'
gluster3.example.com glusterfs_ip=192.168.10.13 glusterfs_devices='[ "/dev/xvdc", "/dev/xvdd" ]'

执行openshift ansible playbook

ansible-playbook /root/openshift-ansible/playbooks/openshift-glusterfs/config.yml
ansible-playbook -e "openshift_storage_glusterfs_wipe=true" /root/openshift-ansible/playbooks/openshift-glusterfs/uninstall.yml

1. 创建storage class

创建storage class(ansible playbook执行过程中会自动创建storageclass)

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: glusterfs-storage
provisioner: kubernetes.io/glusterfs
parameters:
  resturl: 'http://heketi-storage.app-storage.svc:8080'
  restuser: admin
  secretName: heketi-storage-admin-secret
  secretNamespace: app-storage
reclaimPolicy: Delete
volumeBindingMode: Immediate

如果使用的集群外的Glusterfs集群,需要手动创建storage class。

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: glusterfs-storage
provisioner: kubernetes.io/glusterfs
parameters:
  resturl: "http://10.42.0.0:8080"
  restauthenabled: "false"

2. 创建PVC时使用Glusterfs的storage class

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
 name: gluster1
spec:
 accessModes:
  - ReadWriteMany
 resources:
   requests:
        storage: 30Gi
 storageClassName: glusterfs-storage

挂载命令格式:

mount -t glusterfs GlusterFS容器化pod所在的节点IP地址:/volume_name /mnt/glusterfs

示例:

$ mount -t glusterfs 172.16.1.4:/vol_fe0de9d2f43731d1af7a5dc296041d83 /mnt/glusterfs && \
  df -mh 
172.16.1.4:/vol_fe0de9d2f43731d1af7a5dc296041d83            10G  136M  9.9G   2% /mnt/glusterfs

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文