Edit on GitHub

Using NATS with Minio

NATS and Minio

Minio is a Golang-based object store, increasingly popular for cloud native deployments. Minio is S3 compatible, and runs across a wide variety of platforms.

This demonstration will show you how to run a Minio object store on a local machine, configure a local NATS instance, and finally replicate objects to other clouds.

Step 1: Install and run NATS Server

go get github.com/nats-io/gnatsd

Step 2: Install Minio

go get github.com/minio/minio

Step 3: Configure Minio to use NATS for event subscription

edit ~/.minio/config.json

Enable NATS in the configuration by setting: "nats"."1"."enable": true

For example:

{
  "nats": {
    "1": {
      "enable": true,
      "address": "0.0.0.0:4222",
      "subject": "bucketevents"
    }
  }
}

Step 4: Run Minio

minio server ~/minio-tmp/

Step 5: Run Minio-NATS

go run minionats/main.go -remote s3://accessKeyId:accessSecretKey@host:port -local s3://accessKeyId:accessSecretKey@host:port

Step 6: Try it out!

  • Go into your test bucket Minio Browser your S3 Bucket
  • Now when you upload or delete a file in Minio, these changes will be replicated on your S3 Bucket!

Usage flags

Usage of demo-minio-nats:
  -bucket string
    	bucket to test with (default "minio-nats-example")
  -local string
    	local S3 URL in format s3://accessKeyId:accessSecretKey@host:port
  -nats string
    	NATS URL in format nats://user:password@host:port (default "nats://localhost:4222")
  -region string
    	region to create and maintain bucket (default "us-east-1")
  -remote string
    	remote S3 URL in format s3://accessKeyId:accessSecretKey@host:port
  -tmpDir string
    	temporary directory for copying files (default "/tmp/")