2 min read

Minio Cluster

Self hosted Object storage cluster

Info

An easy guide to install minio and put in cluster mode

Installation

First lets prep the environment with the neccesary packages

1
2
apt update && apt install curl
curl -L https://get.docker.com |sh

Here is the docker-compose.yml I used

 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
services:
  minio:
    container_name: minio
    image: minio/minio:latest
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.api.rule=Host(`minio-api.example.com`)"
      - "traefik.http.routers.api.entrypoints=websecure,web"
      - "traefik.http.routers.api.tls.certresolver=default"
      - "traefik.http.routers.api.service=api"
      - "traefik.http.services.api.loadbalancer.server.port=9000"
    environment:
      MINIO_ROOT_USER: minioadmin
      MINIO_ROOT_PASSWORD: "minio"
      MINIO_SERVER_URL: https://minio-api.example.com
      MINIO_VOLUMES: "http://minio1:9000/data http://minio2:9000/data http://minio3:9000/data"
    volumes:
      - ./data:/data
      - ./config:/root/.minio
    ports:
      - "9000:9000"
    networks:
      - traefik
    restart: unless-stopped
    command: ["server", "/data"]

networks:
  traefik:

Repeat this for all 3+ containers with MINIO_VOLUMES pointing to them

Configuration

Enter into the container

1
2
3
docker compose exec -it minio bash

mc alias set local http://localhost:9000 admin YourStrongPassword123

Create bucket

1
mc mb local/${BUCKET_NAME} --ignore-existing

Create user

1
mc admin user add local ${USER} ${PASS}

Grant user permission to bucket

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
cat <<POLICY > /tmp/policy.json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:*"],
      "Resource": [
        "arn:aws:s3:::terraform",
        "arn:aws:s3:::terraform/*"
      ]
    }
  ]
}
POLICY

mc admin policy create local terraform-policy /tmp/policy.json
mc admin policy attach local terraform-policy --user ${USER}