Skip to content

How to use MinIO in k8s without Operator

Cesar Celis Hernandez edited this page Jun 8, 2023 · 3 revisions

Objective:

To show a way to use MinIO in k8s without an Operator.

Steps:

  1. Have your cluster ready, either k8s Vanilla or OpenShift.

  2. Deploy the StatefulSet:

apiVersion: apps/v1 #  for k8s versions before 1.9.0 use apps/v1beta2  and before 1.8.0 use extensions/v1beta1
kind: StatefulSet
metadata:
  name: minio
  labels:
     app: minio
spec:
  selector:
    matchLabels:
      app: minio
  serviceName: minio
  replicas: 2
  template:
    metadata:
      labels:
        app: minio
    spec:
      containers:
      - name: minio
        env:
        - name: MINIO_KMS_SECRET_KEY
          value: "my-minio-key:oyArl7zlPECEduNbB1KXgdzDn2Bdpvvw0l8VO51HQnY=" # dummy value change-me
        image: minio/minio:RELEASE.2023-05-27T05-56-19Z
        args:
        - server
        - http://minio-{0...1}.minio.default.svc.cluster.local/data
        ports:
        - containerPort: 9000
          hostPort: 9000
        # These volume mounts are persistent. Each pod in the StatefulSet
        # 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
      storageClassName: standard
      resources:
        requests:
          storage: 1Ti
  1. Deploy its service:
apiVersion: v1
kind: Service
metadata:
  name: minio
  labels:
    app: minio
spec:
  type: NodePort
  ports:
    - port: 9000
      name: minio
      nodePort: 30080
  selector:
    app: minio
  1. Use MinIO via mc:
$ mc alias set myminio http://localhost:30080 minioadmin minioadmin --insecure
Added `myminio` successfully.
$ mc mb myminio/testing --insecure
Bucket created successfully `myminio/testing`.
$ mc cp a.txt  myminio/testing/a.txt --insecure
...s/cniackz/minio/a.txt: 4 B / 4 B ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 53 B/s 
$ mc ls myminio/testing --insecure
[2023-06-08 12:11:39 EDT]     4B STANDARD a.txt

OpenShift Route to Expose the Service:

WIP

Clone this wiki locally