首页 > 其他分享 >k8s高级存储-GlusterFS存储类(StorageClass)实战

k8s高级存储-GlusterFS存储类(StorageClass)实战

时间:2022-12-21 16:01:36浏览次数:46  
标签:存储 name kubernetes mongodb GlusterFS StorageClass io MONGODB heketi

      GlusterFS是一个开源的分布式文件系统,具有强大的横向扩展能力,通过扩展能够支持数PB存储容量和处理数千客户端。集成来自多台服务器上的磁盘存储资源到单一全局命名空间,已提供共享文件存储。

      GlusterFS 具有高扩展性、高可用性、高性能、可横向扩展等特点,并且其没有元数据服务器的设计,让整个服务没有单点故障的隐患。

  • GlusterFS 安装环境要求
  • 三个节点(k8s-master03 k8s-node01 k8s-node02)
  • 每个节点必须至少连接一个原始块设备(如空的本地磁盘)供 heketi 使用。这些设备上不得有任何数据,因为它们将由 heketi 格式化和分区。简单意思就是需要一个没有数据的空的本地硬盘。

部署GlusterFS

  1. K8s-master03 k8s-node01 k8s-node02 添加三块50G的硬盘三台机器已经添加了一块硬盘/dev/sdd
[root@k8s-master03 ~]# lsblk 

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sdd 8:48 0 50G 0 disk
  1. 三台节点安装
yum -y install centos-release-gluster7.noarchyum -y install glusterfs-server glusterfs-cli glusterfs-geo-replicationsystemctl enable glusterd && systemctl start glusterd && systemctl status glusterd
  1. 在master01节点安装hekeit
modprobe dm_snapshot && modprobe dm_mirror && modprobe dm_thin_pool

yum install -y centos-release-gluster
yum install -y heketi heketi-client
  1. 配置heketi.json
[root@k8s-master01 heketi]# cat heketi.json


{


"_port_comment": "Heketi Server Port Number",


"port": "8080",






"_use_auth": "Enable JWT authorization. Please enable for deployment",


"use_auth": false,






"_jwt": "Private keys for access",


"jwt": {


"_admin": "Admin has access to all APIs",


"admin": {


"key": "admin@com"


},


"_user": "User only has access to volumes endpoint",


"user": {


"key": "user@admin"


}


},






"_glusterfs_comment": "GlusterFS Configuration",


"glusterfs": {


"_executor_comment": [


"Execute plugin. Possible choices: mock, ssh",


"mock: This setting is used for testing and development.",


" It will not send commands to any node.",


"ssh: This setting will notify Heketi to ssh to the nodes.",


" It will need the values in sshexec to be configured.",


"kubernetes: Communicate with GlusterFS containers over",


" Kubernetes exec api."


],


"executor": "ssh",






"_sshexec_comment": "SSH username and private key file information",


"sshexec": {


"keyfile": "/etc/heketi/heketi_key",


"user": "root",


"port": "22",


"fstab": "/etc/fstab"


},






"_kubeexec_comment": "Kubernetes configuration",


"kubeexec": {


"host" :"https://kubernetes.host:8443",


"cert" : "/path/to/crt.file",


"insecure": false,


"user": "kubernetes username",


"password": "password for kubernetes user",


"namespace": "OpenShift project or Kubernetes namespace",


"fstab": "Optional: Specify fstab file on node. Default is etc/fstab"


},






"_db_comment": "Database file name",


"db": "/var/lib/heketi/heketi.db",






"_loglevel_comment": [


"Set log level. Choices are:",


" none, critical, error, warning, info, debug",


"Default is warning"


],


"loglevel" : "debug"


}


}


[root@k8s-master01 heketi]# ssh-keygen -t rsa -q -f etc/heketi/heketi_key -N ""


[root@k8s-master01 heketi]# chown heketi:heketi etc/heketi/heketi_key


[root@k8s-master01 heketi]# ssh-copy-id -i etc/heketi/heketi_key.pub [email protected]

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/etc/heketi/heketi_key.pub"

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

Number of key(s) added: 1
Now try logging into the machine, with: "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.

[root@k8s-master01 heketi]# ssh-copy-id -i etc/heketi/heketi_key.pub [email protected]

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/etc/heketi/heketi_key.pub"

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

Number of key(s) added: 1
Now try logging into the machine, with: "ssh '[email protected]'"

and check to make sure that only the key(s) you wanted were added.

[root@k8s-master01 heketi]# ssh-copy-id -i etc/heketi/heketi_key.pub [email protected]

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/etc/heketi/heketi_key.pub"

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys


Number of key(s) added: 1

Now try logging into the machine, with: "ssh '[email protected]'"

and check to make sure that only the key(s) you wanted were added.


[root@k8s-master01 heketi]#systemctl enable heketi

[root@k8s-master01 heketi]# systemctl start heketi

[root@k8s-master01 heketi]# systemctl status heketi


[root@k8s-master01 heketi]# curl http://127.0.0.1:8080/hello


Hello from Heketi


  1. 设置gfs集群

创建topology.json文件

# vim topology.json






{


"clusters": [


{


"nodes": [


{


"node": {


"hostnames": {


"manage": [


"192.168.102.73"


],


"storage": [


"192.168.102.73"


]


},


"zone": 1


},


"devices": [


"/dev/sdd"


]


},


{


"node": {


"hostnames": {


"manage": [


"192.168.102.74"


],


"storage": [


"192.168.102.74"


]


},


"zone": 1


},


"devices": [


"/dev/sdd"


]


},


{


"node": {


"hostnames": {


"manage": [


"192.168.102.75"


],


"storage": [


"192.168.102.75"


]


},


"zone": 1


},


"devices": [


"/dev/sdd"


]


}


]


}


]


}
  1. 初始化heketi
[root@k8s-master01 ~]# heketi-cli --server http://127.0.0.1:8080  --user admin --secret admin@com topology load --json=/root/topology.json 






Creating cluster ... ID: 449e2bf90d0035fb773adc14e8fa6c58


Allowing file volumes on cluster.


Allowing block volumes on cluster.


Creating node 192.168.102.73 ... ID: 4a49fa88df44baab4459e81cc99cb9da


Adding device dev/sdd ... OK


Creating node 192.168.102.74 ... ID: 0aa3789e12d2894284051035e675f0b5


Adding device dev/sdd ... OK


Creating node 192.168.102.75 ... ID: 2c609ca994b4b5a1ee925b7184138eb4


Adding device dev/sdd ... OK














[root@k8s-master01 ~]# heketi-cli --user admin --secret admin@com topology info --server http://localhost:8080






Cluster Id: 449e2bf90d0035fb773adc14e8fa6c58






File: true


Block: true






Volumes:






Nodes:






Node Id: 0aa3789e12d2894284051035e675f0b5


State: online


Cluster Id: 449e2bf90d0035fb773adc14e8fa6c58


Zone: 1


Management Hostnames: 192.168.102.74


Storage Hostnames: 192.168.102.74


Devices:


Id:d399d7d2446c2ed0237011387c2f7391 Name:/dev/sdd State:online Size (GiB):49 Used (GiB):0 Free (GiB):49


Bricks:






Node Id: 2c609ca994b4b5a1ee925b7184138eb4


State: online


Cluster Id: 449e2bf90d0035fb773adc14e8fa6c58


Zone: 1


Management Hostnames: 192.168.102.75


Storage Hostnames: 192.168.102.75


Devices:


Id:51b4e5810f2ac199404377132c805666 Name:/dev/sdd State:online Size (GiB):49 Used (GiB):0 Free (GiB):49


Bricks:






Node Id: 4a49fa88df44baab4459e81cc99cb9da


State: online


Cluster Id: 449e2bf90d0035fb773adc14e8fa6c58


Zone: 1


Management Hostnames: 192.168.102.73


Storage Hostnames: 192.168.102.73


Devices:


Id:cc6ab4e8472db465cf59dff58a626015 Name:/dev/sdd State:online Size (GiB):49 Used (GiB):0 Free (GiB):49


Bricks:


[root@k8s-master01 ~]#


  1. 创建secret和storageclass
#生成secret资源,其中”key”值需要转换为base64编码格式


[root@k8s-master01 ~]# echo -n "admin@com"|base64


YWRtaW5AY29t






[root@k8s-master01 ~]# vim heketi-secret.yaml


apiVersion: v1


kind: Secret


metadata:


name: heketi-secret


namespace: default


data:


# base64 encoded password. E.g.: echo -n "mypassword" | base64


key: YWRtaW5AY29t


type: kubernetes.io/glusterfs


[root@k8s-master01 ~]# kubectl create -f heketi-secret.yaml


secret/heketi-secret created










#配置storageclass






[root@k8s-master01 ~]# vim gluster-heketi-storageclass.yaml






apiVersion: storage.k8s.io/v1beta1


kind: StorageClass


metadata:


name: gluster-heketi-storageclass


provisioner: kubernetes.io/glusterfs


reclaimPolicy: Delete


parameters:


resturl: "http://192.168.102.71:8080"


restauthenabled: "true"


restuser: "admin"


secretNamespace: "default"


secretName: "heketi-secret"


volumetype: "replicate:3"





[root@k8s-master01 ~]# kubectl create -f gluster-heketi-storageclass.yaml














[root@k8s-master01 ~]# kubectl describe storageclass gluster-heketi-storageclass


Name: gluster-heketi-storageclass


IsDefaultClass: No


Annotations: <none>


Provisioner: kubernetes.io/glusterfs


Parameters: restauthenabled=true,resturl=http://192.168.102.71:8080,restuser=admin,secretName=heketi-secret,secretNamespace=default,volumetype=replicate:3


AllowVolumeExpansion: <unset>


MountOptions: <none>


ReclaimPolicy: Delete


VolumeBindingMode: Immediate


Events: <none>


标签:存储,name,kubernetes,mongodb,GlusterFS,StorageClass,io,MONGODB,heketi
From: https://blog.51cto.com/u_14966640/5959947

相关文章

  • Linux Docker 修改存储位置及镜像存储位置
    转发:修改Docker存储位置......
  • SQL存储过程与自定义函数
    --execsp_databases--execsp_helpdbmaster--execsp_renamedb原名,新名--go--系统命令的改变/*execsp_configure'showadvancedoptions',1goreconfigureexecsp_conf......
  • SharedPreferences存储
    不同于文件存储的方式,SharedPreferences是使用键值对的方式来存储数据的。也就是说,当保存一条数据的时候,需要给这条数据提供一个对应的键,这样在读取数据的时候就可以通过......
  • 数据存储全方案,详解持久化技术
    Android系统主要提供了三种方式用于简单的实现数据持久化功能,即文件存储,ShareedPreference存储以及数据库存储.当然,除了这三种方式之外,你还可以将数据保存在手机的SD卡......
  • 用ThreadLocal来存储Session
    /***用ThreadLocal来存储Session,以便实现Sessionanywhere.**/publicclassThreadLocalUtil{protectedfinalLoggerlogger=LoggerFactory.getLogger(this......
  • 构建一个应用程序,用于在基于内存的数据库中存储 POJO(普通旧 Java 对象)
    本指南将引导您完成构建应用程序的过程,该应用程序使用SpringDataJPA在关系数据库中存储和检索数据。您将构建什么您将构建一个应用程序,用于在基于内存的数据库中存储PO......
  • Android 设置存储修改
    源码8.1packages/apps/Settings/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceController.java/***Updatesthestateofthe......
  • 技术分享 | MySQL 存储过程中的只读语句超时怎么办?
    作者:杨涛涛资深数据库专家,专研MySQL十余年。擅长MySQL、PostgreSQL、MongoDB等开源数据库相关的备份恢复、SQL调优、监控运维、高可用架构设计等。目前任职于爱可生,为......
  • jz2440存储管理实验【学习笔记】
    平台:jz2440作者:庄泽彬(欢迎转载,请注明作者)说明:韦东山一期视频学习笔记简介:先来简单的说明一下这次的实验,看看下图,我们的程序通过烧录器下载到nandflash当中去,之后在启动......
  • MySQL使用--存储过程篇
    查看存储过程:select`name`frommysql.procwheredb='your_db_name'and`type`='PROCEDURE'SHOWprocedurestatus;查看存储过程的创建代......