MinIO 是全球领先的对象存储先锋,以 Apache License v2.0 发布的对象存储服务器,是为云应用和虚拟机而设计的分布式对象存储服务器。在标准硬件上,读/写速度上高达183GB/s和171GB/s。它与 Amazon S3 云存储服务兼容。 它最适用于存储非结构化数据,如照片、视频、日志文件、备份和容器/虚拟机映像。 对象的大小可以从几KB 到最大5TB。

  • 对象存储,兼容Amazon S3协议
  • 安装运维相对简单,开箱即用
  • 后端除了本地文件系统,还支持多种存储系统,目前已经包括 OSS
  • 原生支持bucket事件通知机制
  • 可通过多节点集群方式,支持一定的高可用和数据容灾
  • 有WEB管理界面和CLI,可以用于测试或者管理
  • 公开bucket中的数据可以直接通过HTTP获取

MinIO是一个非常轻量的服务,可以很简单的和其他应用的结合,类似 NodeJS, Redis 或者 MySQL。
MinIO支持多种灵活的部署方式,支持Docker Compose、Docker Swam、Kubernetes等,详见官网:https://docs.min.io/docs/minio-deployment-quickstart-guide.html或者https://min.io/download#/linux

这里着重介绍K8S下部署

standalone模式

  1. apiVersion: v1
  2. kind: PersistentVolume
  3. metadata:
  4. labels:
  5. app: minio
  6. release: minio
  7. name: minio
  8. namespace: default
  9. spec:
  10. accessModes:
  11. - ReadWriteOnce
  12. capacity:
  13. storage: 10Gi
  14. volumeMode: Filesystem
  15. hostPath:
  16. path: /mnt/minio
  17. ---
  18. apiVersion: v1
  19. kind: PersistentVolumeClaim
  20. metadata:
  21. # This name uniquely identifies the PVC. Will be used in deployment below.
  22. name: minio-pv-claim
  23. labels:
  24. app: minio-storage-claim
  25. spec:
  26. # Read more about access modes here: https://kubernetes.io/docs/user-guide/persistent-volumes/#access-modes
  27. accessModes:
  28. - ReadWriteOnce
  29. resources:
  30. # This is the request for storage. Should be available in the cluster.
  31. requests:
  32. storage: 10Gi
  33. # Uncomment and add storageClass specific to your requirements below. Read more https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class-1
  34. #storageClassName:
  35. ---
  36. apiVersion: apps/v1
  37. kind: Deployment
  38. metadata:
  39. # This name uniquely identifies the Deployment
  40. name: minio-deployment
  41. spec:
  42. strategy:
  43. type: Recreate
  44. selector:
  45. matchLabels:
  46. app: minio
  47. template:
  48. metadata:
  49. labels:
  50. # Label is used as selector in the service.
  51. app: minio
  52. spec:
  53. # Refer to the PVC created earlier
  54. volumes:
  55. - name: storage
  56. persistentVolumeClaim:
  57. # Name of the PVC created earlier
  58. claimName: minio-pv-claim
  59. containers:
  60. - name: minio
  61. # Pulls the default MinIO image from Docker Hub
  62. image: minio/minio
  63. args:
  64. - server
  65. - /storage
  66. env:
  67. # MinIO access key and secret key
  68. - name: MINIO_ACCESS_KEY
  69. value: "admin123"
  70. - name: MINIO_SECRET_KEY
  71. value: "admin123"
  72. ports:
  73. - containerPort: 9000
  74. # Mount the volume into the pod
  75. volumeMounts:
  76. - name: storage # must match the volume name, above
  77. mountPath: "/storage"
  78. ---
  79. apiVersion: v1
  80. kind: Service
  81. metadata:
  82. name: minio-service
  83. spec:
  84. type: NodePort
  85. ports:
  86. - port: 9000
  87. targetPort: 9000
  88. protocol: TCP
  89. selector:
  90. app: minio

通过K8S部署对象存储MinIO - 图1

由于service采用NodePort类型,通过主机IP:32593访问web
通过K8S部署对象存储MinIO - 图2

distributed模式

apiVersion: v1
kind: Service
metadata:
  name: minio
  labels:
    app: minio
spec:
  clusterIP: None
  ports:
    - port: 9000
      name: minio
  selector:
    app: minio
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: minio
spec:
  serviceName: minio
  replicas: 4
  selector:
    matchLabels:
      app: minio
  template:
    metadata:
      labels:
        app: minio
    spec:
      containers:
      - name: minio
        env:
        - name: MINIO_ACCESS_KEY
          value: "admin123"
        - name: MINIO_SECRET_KEY
          value: "admin123"
        image: minio/minio
        args:
        - server
        - http://minio-{0...3}.minio.default.svc.cluster.local/data
        ports:
        - containerPort: 9000
        # These volume mounts are persistent. Each pod in the PetSet
        # gets a volume mounted based on this field.
        volumeMounts:
        - name: data
          mountPath: /data
  # These are converted to volume claims by the controller
  # and mounted at the paths mentioned above.
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 10Gi
      # Uncomment and add storageClass specific to your requirements below. Read more https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class-1
      #storageClassName:
---
apiVersion: v1
kind: Service
metadata:
  name: minio-service
spec:
  type: NodePort
  ports:
    - port: 9000
      targetPort: 9000
      protocol: TCP
  selector:
    app: minio

分布式部署,实例数至少4个,所以需要另外创建4个pv
通过K8S部署对象存储MinIO - 图3