Skip to content

Instantly share code, notes, and snippets.

@balamurugana
Last active August 2, 2023 05:32
Show Gist options
  • Save balamurugana/c59e868a36bb8a549fe863d22d6f0678 to your computer and use it in GitHub Desktop.
Save balamurugana/c59e868a36bb8a549fe863d22d6f0678 to your computer and use it in GitHub Desktop.
Running minio in minikube

Prerequisites:

  • Run minikube with kvm driver by $ minikube start --vm-driver kvm

Minio FS mode:

  1. Deploy minio in fs mode with below yaml in a file like $ kubectl create -f my-minio-fs.yaml
## Create persistent volume claim for minio to store data.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-minio-fs-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
## Run minio fs deployment.
apiVersion: extensions/v1
kind: Deployment
metadata:
  name: my-minio-fs
spec:
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: my-minio-fs
    spec:
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: my-minio-fs-pvc
      containers:
      - name: my-minio-fs
        volumeMounts:
        - name: data 
          mountPath: "/data"
        image: minio/minio:RELEASE.2017-11-22T19-55-46Z
        args:
        - server
        - /data
        env:
        - name: MINIO_ACCESS_KEY
          value: "minio"
        - name: MINIO_SECRET_KEY
          value: "minio123"
        ports:
        - containerPort: 9000
          hostPort: 9000
  1. To make the above deployment accessible from outside network, run below command
$ kubectl expose deployment/my-minio-fs --type="NodePort" --port 9000
  1. Run below command to know the port the above service exposed.
kubectl get services/my-minio-fs -o go-template='{{(index .spec.ports 0).nodePort}}'
  1. Use this port in the endpoint http://minikube:<EXPOSED-PORT>

Minio Dist-XL mode:

  1. Deploy minio in dist-xl mode with below yaml in a file like $ kubectl create -f my-minio-dist-xl.yaml
## Create headless service to StatefulSet to work.
apiVersion: v1
kind: Service
metadata:
  name: my-minio-dist-xl-headless
  labels:
    app: my-minio-dist-xl-headless
spec:
  ports:
  - port: 9000
    name: my-minio-dist-xl
  clusterIP: None
  selector:
    app: my-minio-dist-xl-headless
---
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
  name: my-minio-dist-xl
spec:
  serviceName: "my-minio-dist-xl-headless"
  replicas: 4
  selector:
    matchLabels:
      app: my-minio-dist-xl-app
  template:
    metadata:
      labels:
        app: my-minio-dist-xl-app
    spec:
      containers:
      - name: my-minio-dist-xl
        env:
        - name: MINIO_ACCESS_KEY
          value: "minio"
        - name: MINIO_SECRET_KEY
          value: "minio123"
        image: minio/minio:RELEASE.2017-11-22T19-55-46Z
        args:
        - server
        - http://my-minio-dist-xl-0.my-minio-dist-xl-headless.default.svc.cluster.local/data
        - http://my-minio-dist-xl-1.my-minio-dist-xl-headless.default.svc.cluster.local/data
        - http://my-minio-dist-xl-2.my-minio-dist-xl-headless.default.svc.cluster.local/data
        - http://my-minio-dist-xl-3.my-minio-dist-xl-headless.default.svc.cluster.local/data
        ports:
        - containerPort: 9000
          name: my-minio-dist-xl
        volumeMounts:
        - name: data
          mountPath: /data
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 1Gi
  1. To make the above deployment accessible from outside network, run below yaml kubectl create -f my-minio-dist-xl-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: my-minio-dist-xl
spec:
  type: NodePort
  ports:
  - port: 9000
  selector:
    app: my-minio-dist-xl
  1. Run below command to know the port the above service exposed.
kubectl get services/my-minio-dist-xl -o go-template='{{(index .spec.ports 0).nodePort}}'
  1. Use this port in the endpoint http://minikube:<EXPOSED-PORT>
@saadzimat430
Copy link

Hi, first thanks for the effort for sharing this.
I followed the steps, Minio and its pods/services seem to be created successfully. But when I launch the service, I get redirected to minio/console Github page. How can I open Minio dashboard and create tenants?

@balamurugana
Copy link
Author

@saadzimat430 Please open an issue in respective project to get appropriate help.

@ottobricks
Copy link

@balamurugana thank you for sharing. Could you elaborate why minikube driver should be kvm and not docker?

@balamurugana
Copy link
Author

@ottok92 You would need to check minikube documentation. BTW This is quite old documentation, I don't think it is still relevant now.

@ottobricks
Copy link

Will check it, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment