kubernets 部署 Minio Operator 部署

本贴最后更新于 1121 天前,其中的信息可能已经物是人非

一、系统架构

12.png

实现机制

基于 kuberntes 中的 CSI 中的 stroageClass,实现动态申请 pvc 作为 minio 的存储节点,来实现 minio 对象存储的动态扩容机制。

二、测试环境准备

  1. 服务器硬件和软件

硬件

型号 CPU Memory Disk Network
Dell R410 Intel E5620 16GB SATA 300GB*1 Nic 1GB
Dell R410 Intel E562 16GB SATA 300GB*2 Nic 1GB
Dell R410 Intel E562 16GB SATA 300GB*2 Nic 1GB
Dell R410 Intel E562 16GB SATA 300GB*2 Nic 1GB

软件

Role IP Kubernetes Docker OS
Master 192.168.1.240 V1.18.16 19.03.15 CentOS Linux release 7.9.2009 (Core)
Worker 192.168.1.241 V1.18.16 19.03.15 CentOS Linux release 7.9.2009 (Core)
Worker 192.168.1.242 V1.18.16 19.03.15 CentOS Linux release 7.9.2009 (Core)
Worker 192.168.1.243 V1.18.16 19.03.15 CentOS Linux release 7.9.2009 (Core)

三、安装 minio/operator

github 项目地址 https://github.com/minio/operator/

部署前提条件

  1. 准备好 kubernetes 集群,本次测试使用 4 节点集群

    [root@ds-n1 ~]# kubectl get node
    NAME    STATUS   ROLES                      AGE   VERSION
    ds-n1   Ready    controlplane,etcd,worker   46h   v1.18.16
    ds-n2   Ready    worker                     46h   v1.18.16
    ds-n3   Ready    worker                     46h   v1.18.16
    ds-n4   Ready    worker                     46h   v1.18.16
    
  2. 查看准备好的动态存储,测试用的是 longhorn(longhorn,openebs)

[root@ds-n1 ~]# kubectl get sc
NAME                 PROVISIONER          RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
longhorn (default)   driver.longhorn.io   Delete          Immediate           true                   46h

部署 minio operator

  1. 安装 minio 插件

本次使用二进制安装,从 github 下载安装。

# Opertator Version 4.0.3
wget https://github-releases.githubusercontent.com/154578184/e9d8c680-87f4-11eb-89a6-68250108d7b0?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210319%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210319T021956Z&X-Amz-Expires=300&X-Amz-Signature=4610252db79ae812f349682609152a0f2000cff77c111bb392da3e0ac8d49006&X-Amz-SignedHeaders=host&actor_id=30251247&key_id=0&repo_id=154578184&response-content-disposition=attachment%3B+filename%3Dkubectl-minio_4.0.3_linux_amd64&response-content-type=application%2Foctet-stream

给 kubectl-minio_4.0.3_linux_amd64 赋予执行权限,并 copy 到/usr/local/bin 目录下并重命名

chmod +x kubectl-minio_4.0.3_linux_amd64
cp kubectl-minio_4.0.3_linux_amd64 /usr/local/bin/kubectl-minio

通过 kubectl plugin list 命令查看 minio 插件安装状态

[root@ds-n1 ~]# kubectl plugin list
The following compatible plugins are available:

/usr/local/bin/kubectl-minio
Unable read directory "/root/bin" from your PATH: open /root/bin: no such file or directory. Skipping...

如果不显示插件,手动添加环境变量

  1. 初始化 Minio operator

首先需要初始化 minio operator,opertator 创建完成后,便可以继续进行 Tenant 创建

[root@ds-n1 ~]# kubectl minio init
[root@ds-n1 ~]# kubectl get pod -n minio-operator
NAME                             READY   STATUS    RESTARTS   AGE
console-5fcbf4b7df-m6wfg         1/1     Running   0          46h
minio-operator-9c79bb668-djvn5   1/1     Running   0          46h

部署 minio 存储服务

kubectl minio tenant create tenant1 --namespace minio-tenant-1 --storage-class longhorn --servers 4 --volumes 4 --capacity 480Gi 

查看创建的资源

[root@ds-n1 ~]# kubectl get pod -n minio-tenant-1
NAME                                      READY   STATUS    RESTARTS   AGE
minio-tenant-1-console-7df4467c65-hvzf8   1/1     Running   0          45h
minio-tenant-1-console-7df4467c65-z6qpf   1/1     Running   0          45h
minio-tenant-1-ss-0-0                     1/1     Running   0          45h
minio-tenant-1-ss-0-1                     1/1     Running   0          45h
minio-tenant-1-ss-0-2                     1/1     Running   0          45h
minio-tenant-1-ss-0-3                     1/1     Running   0          45h

修改 service 类型为 NodePort,方便访问 minio UI 以及 tenant-console UI:

kubectl -n minio-tenant-1 patch svc minio -p '{"spec": {"type": "NodePort"}}'
kubectl -n minio-tenant-1 patch svc minio-tenant-1-console -p '{"spec": {"type": "NodePort"}}'

查看 service,记录 minio 及 tenant1-console 中的 nodeport

[root@ds-n1 ~]# kubectl get svc -n minio-tenant-1
NAME                     TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
minio                    NodePort    10.43.126.203   <none>        443:30488/TCP    45h
minio-tenant-1-console   NodePort    10.43.174.32    <none>        9443:31672/TCP   45h
minio-tenant-1-hl        ClusterIP   None            <none>        9000/TCP         45h

使用 nodeport 访问 minio UI,使用 https 方式:

image.png

使用 nodeport 访问 tenant-console UI,使用 https 方式:

image.png

五、Minio 扩容

使用 kubectl minio 插件向租户添加容量

kubectl minio tenant expand minio-tenant-1 longhorn --servers 8 --volumes 8 --capacity 480Gi --namespace minio-tenant-1 ----storage-class

查看资源创建结果

[root@ds-n1 ~]# kubectl get pod -n minio-tenant-1
NAME                                      READY   STATUS    RESTARTS   AGE
minio-tenant-1-console-7df4467c65-hvzf8   1/1     Running   0          45h
minio-tenant-1-console-7df4467c65-z6qpf   1/1     Running   0          45h
minio-tenant-1-ss-0-0                     1/1     Running   0          45h
minio-tenant-1-ss-0-1                     1/1     Running   0          45h
minio-tenant-1-ss-0-2                     1/1     Running   0          45h
minio-tenant-1-ss-0-3                     1/1     Running   0          45h
minio-tenant-1-ss-1-0                     1/1     Running   0          45h
minio-tenant-1-ss-1-1                     1/1     Running   0          45h
minio-tenant-1-ss-1-2                     1/1     Running   0          45h
minio-tenant-1-ss-1-3                     1/1     Running   0          45h
minio-tenant-1-ss-1-4                     1/1     Running   0          45h
minio-tenant-1-ss-1-5                     1/1     Running   0          45h
minio-tenant-1-ss-1-6                     1/1     Running   0          45h
minio-tenant-1-ss-1-7                     1/1     Running   0          45h

这将为租户增加 8 个驱动器,这些驱动器均匀分布在 4 台服务器上 tenant1,并具有 480Gi 的额外容量

至此,完成了 Minio Operator 的部署,bucket 新建和文件上传;完成了 minio 的容量扩容。

  • Kubernetes

    Kubernetes 是 Google 开源的一个容器编排引擎,它支持自动化部署、大规模可伸缩、应用容器化管理。

    108 引用 • 54 回帖 • 1 关注

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...