背景概况
MinIO 是全球领先的对象存储先锋,以 Apache License v2.0 发布的对象存储服务器,是为云应用和虚拟机而设计的分布式对象存储服务器。在标准硬件上,读/写速度上高达183GB/s和171GB/s。它与 Amazon S3 云存储服务兼容。 它最适用于存储非结构化数据,如照片、视频、日志文件、备份和容器/虚拟机映像。 对象的大小可以从几KB 到最大5TB。
- 对象存储,兼容Amazon S3协议
- 安装运维相对简单,开箱即用
- 后端除了本地文件系统,还支持多种存储系统,目前已经包括 OSS
- 原生支持bucket事件通知机制
- 可通过多节点集群方式,支持一定的高可用和数据容灾
- 有WEB管理界面和CLI,可以用于测试或者管理
- 公开bucket中的数据可以直接通过HTTP获取
Minio 资源
# 项目工作展示目录
cd /home/work/minio-demo/
- minio-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
# This name uniquely identifies the Deployment
name: minio-deployment
spec:
strategy:
type: Recreate
selector:
matchLabels:
app: minio
template:
metadata:
labels:
# Label is used as selector in the service.
app: minio
spec:
# Refer to the PVC created earlier
volumes:
- name: storage
persistentVolumeClaim:
# Name of the PVC created earlier
claimName: minio-pv-claim
containers:
- name: minio
# Pulls the default MinIO image from Docker Hub
image: minio/minio
args:
- server
- /storage
env:
# MinIO access key and secret key
- name: MINIO_ACCESS_KEY
value: "admin123"
- name: MINIO_SECRET_KEY
value: "admin123"
ports:
- containerPort: 9000
# Mount the volume into the pod
volumeMounts:
- name: storage # must match the volume name, above
mountPath: "/storage"
- minio-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
labels:
app: minio
release: minio
name: minio
namespace: default
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 20Gi
volumeMode: Filesystem
hostPath:
path: /mnt/minio
- minio-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
# This name uniquely identifies the PVC. Will be used in deployment below.
name: minio-pv-claim
labels:
app: minio-storage-claim
spec:
# Read more about access modes here: https://kubernetes.io/docs/user-guide/persistent-volumes/#access-modes
accessModes:
- ReadWriteOnce
resources:
# This is the request for storage. Should be available in the cluster.
requests:
storage: 20Gi
# Uncomment and add storageClass specific to your requirements below. Read more https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class-1
# storageClassName: minio
- minio-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: minio-service
spec:
type: NodePort
ports:
- port: 9000
targetPort: 9000
protocol: TCP
selector:
app: minio
- minio-ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: traefik-minio
namespace: default
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- host: traefik.minio-minio-standalone.io
http:
paths:
- backend:
serviceName: minio-service
servicePort: 9000
资源创建过程:
# 创建pv
kubectl apply -f minio-pv.yaml
# 创建pvc
kubectl apply -f minio-pv.yaml
# 创建deployment
kubectl apply -f minio-deployment.yaml
# 创建service
kubectl apply -f minio-svc.yaml
# 创建ingress
kubectl apply -f minio-ingress.yaml
Helm 改造
资源改造目录如下:
[root@vm3290 helm]# tree minio-standalone/
minio-standalone/
├── Chart.yaml
├── README.md
├── templates
│ ├── minio-deployment.yaml
│ ├── minio-ingress.yaml
│ ├── minio-pvc.yaml
│ ├── minio-pv.yaml
│ └── minio-svc.yaml
└── values.yaml
1 directory, 8 files
定义 values.yaml 内容如下:
replicas: 1
strategy: Recreate
resources:
limits:
cpu: "1"
memory: 1Gi
requests:
cpu: 200m
memory: 200Mi
pv:
name: minio
accessModes: ReadWriteOnce
storage: 20Gi
pvc:
name: minio-pv-claim
service:
name: minio-service
ingress:
name: minio-ingress
host: traefik.minio-minio-standalone.io
# 请不要轻易修改此配置
global:
namespace: minio-ns
minio:
name: minio-ds
image: minio/minio
tag: latest
port: 9000
项目部署
1. 安装
helm install -n <YOUR-NAMESPACE> standalone standalone
2. 更新
helm upgrade -n <YOUR-NAMESPACE> standalone standalone
3. 卸载
helm delete -n <YOUR-NAMESPACE> standalone
minio 部署资源查看
image
配置 hosts 文件:
image
浏览器打开访问:
image
拓展阅读
本次改造的 minio 是单实例节点副本的 helm 化改造,主要用于机器资源不足,没有进行全盘虚拟化的场景下的资源调度管理上的应用部署,针对应用的场景不同,所以需要结合不同的项目需求进行设计。minio 可以支持单实例副本,同时也支持最小的四节点集群模式(所以在资源较少时建议采用单副本的minio,在集群中可以调度的机器节点资源大于等于4时,minio的集群模式才可以正常使用,后续将会开展集群模式的改造部署)
网友评论