docker、k8s安装minio集群

集群至少需要4个节点

一、docker直接安装minio
首先要编辑hosts文件
[root@app01 minio]# cat >> /etc/hosts << eof
> 192.168.180.45 minio-1
> 192.168.180.46 minio-2
> 192.168.180.47 minio-3
> 192.168.180.48 minio-4
> eof

[root@app01 minio]# cat /etc/hosts
#127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.180.45 app01 dev-server salesdata.bitp.cn
192.168.180.46 test1
192.168.180.47 test2
192.168.180.48 test3
192.168.180.32 sinoeyes.io
192.168.230.112  mdm-dev1 git-server config-server
192.168.17.13 services-server
192.168.230.113 mdm-dev2 redis

192.168.180.45 minio-1
192.168.180.46 minio-2
192.168.180.47 minio-3
192.168.180.48 minio-4
在192.168.180.45、46、47、48上创建run.sh文件,并依次执行该文件
[root@app01 minio]# cat run.sh
docker run -d --name minio \
  --restart=always --net=host \
  -e MINIO_ACCESS_KEY=minio \
  -e MINIO_SECRET_KEY=minio123 \
  -v /home/simon/minio/minio-data1:/data1 \
  minio/minio server \
  --address 192.168.180.45:9000 \
  http://minio-{1...4}/data1
二、k8s用daemonset安装minio
---
apiVersion: v1
kind: Namespace
metadata:
   name: minio
---
apiVersion: v1
kind: Namespace
metadata:
   name: minio
---
apiVersion: v1
kind: Service
metadata:
  name: minio-service
  namespace: minio
  labels:
    app: minio
spec:
  type: NodePort
  ports:
    - port: 9000
      name: minio
      nodePort: 30900
  selector:
    app: minio
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: minio-daemonset
  namespace: minio
spec:
  selector:
    matchLabels:
      app: minio
  template:
    metadata:
      labels:
        app: minio
    spec:
      hostNetwork: true
      containers:
      - name: minio
        env:
        - name: MINIO_ACCESS_KEY
          value: "admin"
        - name: MINIO_SECRET_KEY
          value: "Qwe@1245"
        image: minio/minio:RELEASE.2021-06-09T18-51-39Z
        args:
        - server
        - http://minio-{1...4}/data1
        ports:
        - containerPort: 9000
        volumeMounts:
        - name: volume1
          mountPath: /data1
        #- name: volume2
        #  mountPath: /data2
      volumes:
      - name: volume1
        hostPath:
          path: /home/simon/minio/volume/data1
      #- name: volume2
      #  hostPath:
      #    path: /home/simon/minio/volume/data2
三、k8s用statefulset安装minio

vim statefulset_minio.yaml

---
apiVersion: v1
kind: Namespace
metadata:
   name: minio
---
apiVersion: v1
kind: Service
metadata:
  name: minio
  namespace: minio
  labels:
    app: minio
spec:
  type: NodePort
  ports:
    - port: 9000
      name: minio
      nodePort: 30900
  selector:
    app: minio
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: minio-statefulset
  namespace: minio
spec:
  serviceName: minio
  podManagementPolicy: Parallel
  replicas: 4
  selector:
    matchLabels:
      app: minio
  template:
    metadata:
      labels:
        app: minio
    spec:
      hostNetwork: true
      containers:
      - name: minio
        env:
        - name: MINIO_ACCESS_KEY
          value: "admin"
        - name: MINIO_SECRET_KEY
          value: "Qwe@1245"
        image: minio/minio:RELEASE.2021-06-09T18-51-39Z
        args:
        - server
        - http://minio-{1...4}/data1
        ports:
        - containerPort: 9000
        volumeMounts:
        - name: volume1
          mountPath: /data1
      volumes:
      - name: volume1
        hostPath:
          path: /home/simon/minio/volume/data1
四、k8s用statefulset安装新版的minio,独立出web访问端口
apiVersion: v1
kind: Service
metadata:
  name: minio
  namespace: paas-basic
  labels:
    app: minio
spec:
  selector:
    app: minio
  type: NodePort
  ports:
    - name: minio-api
      port: 9000
      targetPort: 9000
      nodePort: 31900
      protocol: TCP
    - name: minio-ui
      port: 9001
      targetPort: 9001
      nodePort: 31901
      protocol: TCP  	  
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: minio
  namespace: paas-basic
spec:
  serviceName: minio
  podManagementPolicy: Parallel
  replicas: 4
  selector:
    matchLabels:
      app: minio
  template:
    metadata:
      labels:
        app: minio
    spec:
      nodeSelector: 
        minio: "true"
      containers:
      - name: minio
        env:
        - name: MINIO_ACCESS_KEY
          value: "admin"
        - name: MINIO_SECRET_KEY
          value: "Sinoeyes@2021"
        image: minio/minio:RELEASE.2022-03-22T02-05-10Z
        args:
        - server
        - http://minio-{0...3}.minio.paas-basic.svc.cluster.local/miniodata
        - '--console-address'
        - ':9001'
        ports:
        - containerPort: 9000
        - containerPort: 9001
        volumeMounts:
        - name: data
          mountPath: /miniodata
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 200Gi
#      storageClassName: ${StorageClass}
      storageClassName: minio-storageclass
五、k8s用deployment安装minio

vim deployment_minio.yaml

---
apiVersion: v1
kind: Namespace
metadata:
   name: minio
---
apiVersion: v1
kind: Service
metadata:
  name: minio-service
  namespace: minio
  labels:
    app: minio
spec:
  type: NodePort
  ports:
    - port: 9000
      name: minio
  selector:
    app: minio
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: minio-deployment
  namespace: minio
spec:
  replicas: 4
  selector:
    matchLabels:
      app: minio
  template:
    metadata:
      labels:
        app: minio
    spec:
      hostNetwork: true
      containers:
      - name: minio
        env:
        - name: MINIO_ACCESS_KEY
          value: "admin"
        - name: MINIO_SECRET_KEY
          value: "Qwe@1245"
        image: minio/minio:RELEASE.2021-06-09T18-51-39Z
        args:
        - server
        - http://minio-{1...4}/data1
        ports:
        - containerPort: 9000
        volumeMounts:
        - name: volume1
          mountPath: /data1
        #- name: volume2
        #  mountPath: /data2
      volumes:
      - name: volume1
        hostPath:
          path: /home/simon/minio/volume/data1
      #- name: volume2
      #  hostPath:
      #    path: /home/simon/minio/volume/data2

你可能感兴趣的:(FastDFS,minio)