1.直接部署一个pod

需要挂载存储款, 可参考 之前文章设置 https://blog.csdn.net/weimeibuqieryu/article/details/140183843

2.部署yaml

创建部署文件 minio-deploy.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: minio-pv
  namespace: ruoyi #使用ns ruoyi
spec:
  capacity:
    storage: 10Gi #存储容量为 10 GiB
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain # 删除 PVC 后 PV 保留
  nfs:
    path: /nfs/minio   #使用 NFS 服务器的路径和地址, 使用自己定义的
    server: 139.159.140.xxx
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: minio-pvc
  namespace: ruoyi
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Gi
---
apiVersion: v1
kind: Secret
metadata:
  name: minio-secret
  namespace: ruoyi
type: Opaque
stringData:
  root-user: minio
  root-password: password  #明文密码, 记得改为自己的
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: minio
  namespace: ruoyi
spec:
  selector:
    matchLabels:
      app: minio
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: minio
    spec:
      nodeSelector:
        node-role.kubernetes.io/master: ""  # 指定 Pod 运行在 master 节点
      containers:
        - name: minio
          image: minio/minio:latest
          args:
            - server
            - /data
            - --console-address
            - ":9001"
          ports:
            - containerPort: 9000
            - containerPort: 9001
          env:
            - name: MINIO_ROOT_USER
              valueFrom:
                secretKeyRef:
                  name: minio-secret
                  key: root-user
            - name: MINIO_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: minio-secret
                  key: root-password
          volumeMounts:
            - name: storage
              mountPath: "/data"
      volumes:
        - name: storage
          persistentVolumeClaim:
            claimName: minio-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: minio-service
  namespace: ruoyi
spec:
  type: NodePort  # 暴露服务为 NodePort 类型
  ports:
    - name: api
      port: 9000
      targetPort: 9000
      nodePort: 30900
    - name: console
      port: 9001
      targetPort: 9001
      nodePort: 30901 # 节点端口 30901, 可外部访问
  selector:
    app: minio

部署该服务

kubectl apply -f minio-deploy.yaml

就可以使用节点的ip+30901来访问了. 公网记得防火墙的端口要打开

3.ruoyi-vue-plus项目配置minio

设置如下即可

在这里插入图片描述

Logo

快速构建 Web 应用程序

更多推荐