通過K8S部署對象存儲MinIO

MinIO 是全球領先的對象存儲先鋒,以 Apache License v2.0 發(fā)布的對象存儲服務器,是為云應用和虛擬機而設計的分布式對象存儲服務器。在標準硬件上,讀/寫速度上高達183GB/s和171GB/s。它與 Amazon S3 云存儲服務兼容。 它最適用于存儲非結構化數據,如照片、視頻、日志文件、備份和容器/虛擬機映像。 對象的大小可以從幾KB 到最大5TB。

  • 對象存儲,兼容Amazon S3協(xié)議
  • 安裝運維相對簡單,開箱即用
  • 后端除了本地文件系統(tǒng),還支持多種存儲系統(tǒng),目前已經包括 OSS
  • 原生支持bucket事件通知機制
  • 可通過多節(jié)點集群方式,支持一定的高可用和數據容災
  • 有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下部署

1、standalone模式

apiVersion: v1
kind: PersistentVolume
metadata:
  labels:
    app: minio
    release: minio
  name: minio
  namespace: default
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 10Gi
  volumeMode: Filesystem
  hostPath:
    path: /mnt/minio
---
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: 10Gi
  # Uncomment and add storageClass specific to your requirements below. Read more https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class-1
  #storageClassName:
---
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"
---
apiVersion: v1
kind: Service
metadata:
  name: minio-service
spec:
  type: NodePort
  ports:
    - port: 9000
      targetPort: 9000
      protocol: TCP
  selector:
    app: minio
image.png

由于service采用NodePort類型,通過主機IP:32593訪問web


image.png

image.png

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個,所以需要另外創(chuàng)建4個pv

image.png
image.png
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容