前提条件

  • 集群安装StorageClass作为数据存储

安装MinIO StatefulSet

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
cat > minio.yaml << EOF
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: minio
spec:
serviceName: "minio-headless"
replicas: 4
selector:
  matchLabels:
    app: minio
template:
  metadata:
    labels:
      app: minio
  spec:
    # nodeSelector:
    #   minio: true
    containers:
    - name: minio
      env:
      - name: MINIO_ROOT_USER
        value: "admin"
      - name: MINIO_ROOT_PASSWORD
        value: "123456"
      image: minio/minio:RELEASE.2024-07-04T14-25-45Z
      imagePullPolicy: IfNotPresent
      command:
        - /bin/sh
        - -c
        - minio server --console-address ":5000" http://minio-{0...3}.minio-headless:9000/data
      ports:
      - name: data
        containerPort: 9000
        protocol: "TCP"
      - name: console
        containerPort: 5000
        protocol: "TCP"
      volumeMounts:
      - name: data
        mountPath: /data
      - name: time-mount
        mountPath: /etc/localtime
    volumes:
    - name: time-mount
      hostPath:
        path: /usr/share/zoneinfo/Asia/Shanghai
volumeClaimTemplates:
- metadata:
    name: data
  spec:
    storageClassName: "rook-ceph-block"
    accessModes:
      - ReadWriteOnce
    resources:
      requests:
        storage: 200Gi
EOF
1
kubectl apply -f minio.yaml
1
2
3
4
# 可选,如果取消掉nodeSelector注释时,需要在node打标签
kubectl label node k8s-worker01 minio=true
kubectl label node k8s-worker02 minio=true
kubectl label node k8s-worker03 minio=true

配置Headless和NodePort

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
cat > minio-svc.yaml << EOF
apiVersion: v1
kind: Service
metadata:
name: minio-headless
labels:
  app: minio
spec:
clusterIP: None
ports:
  - port: 9000
    name: data
selector:
  app: minio
---
apiVersion: v1
kind: Service
metadata:
name: minio-service
spec:
type: NodePort
ports:
  - name: data
    nodePort: 30009
    port: 9000
    targetPort: 9000
  - name: console
    nodePort: 31901
    port: 5000
    targetPort: 30005
selector:
  app: minio
EOF
1
kubectl apply -f minio-svc.yaml

访问WebUI