Integrating MinIO with Micronaut can be a great way to add reliable object storage to your application—especially since MinIO is lightweight, self-hosted, and fully S3-compatible. Whether you're working locally with Docker or deploying to Kubernetes, Micronaut makes it easy to manage different configurations using profile-specific
application.properties
files.
In this article, you'll learn how to set up MinIO in a Micronaut application using
application-dev.properties
for development and
application-prod.properties
for production, with Docker and Kubernetes as the respective environments.
Step 1: Add Required Dependencies
Start by updating your
pom.xml
with the required libraries:
<dependencies>
<!-- MinIO via AWS-compatible object storage -->
<dependency>
<groupId>io.micronaut.objectstorage</groupId>
<artifactId>micronaut-object-storage-aws</artifactId>
</dependency>
<!-- Micronaut runtime -->
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-runtime</artifactId>
</dependency>
<!-- Kubernetes client support -->
<dependency>
<groupId>io.micronaut.kubernetes</groupId>
<artifactId>micronaut-kubernetes-client</artifactId>
</dependency>
</dependencies>
These dependencies enable S3-compatible access (which works with MinIO), YAML/Properties configuration, and Kubernetes integration.
Step 2: Spin Up MinIO Using Docker (for Dev)
To quickly launch MinIO locally for development:
docker run -p 9000:9000 -p 9001:9001 \
-e MINIO_ROOT_USER=devuser \
-e MINIO_ROOT_PASSWORD=devpass123 \
-v minio-data:/data \
minio/minio server /data --console-address ":9001"
Step 3: Create application-dev.properties
Set up the development-specific configuration in
src/main/resources/application-dev.properties
:
micronaut.application.name=minio-app
micronaut.object-storage.default.provider=aws
micronaut.object-storage.default.region=us-east-1
micronaut.object-storage.default.access-key-id=devuser
micronaut.object-storage.default.secret-access-key=devpass123
micronaut.object-storage.default.endpoint=http://localhost:9000
micronaut.object-storage.default.path-style-access=true
To run your application with this configuration:
./mvnw mn:run -Dmicronaut.environments=dev
Micronaut will automatically use the
dev
profile and connect to your local MinIO instance.
Step 4: Configure Production with Kubernetes
In production, you should not hardcode secrets or environment-specific values. Kubernetes makes it easy to manage these settings using ConfigMaps and Secrets.
4.1: Create a Kubernetes ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: minio-config
data:
MINIO_ENDPOINT: http://minio-service:9000
4.2: Create a Kubernetes Secret
apiVersion: v1
kind: Secret
metadata:
name: minio-secret
type: Opaque
data:
MINIO_ACCESS_KEY: cHJvZHVzZXI= # 'produser' (base64)
MINIO_SECRET_KEY: cHJvZHBhc3MxMjM= # 'prodpass123' (base64)
Step 5: Create application-prod.properties
This file will use environment variables injected by Kubernetes:
micronaut.application.name=minio-app
micronaut.object-storage.default.provider=aws
micronaut.object-storage.default.region=us-east-1
micronaut.object-storage.default.access-key-id=${MINIO_ACCESS_KEY}
micronaut.object-storage.default.secret-access-key=${MINIO_SECRET_KEY}
micronaut.object-storage.default.endpoint=${MINIO_ENDPOINT}
micronaut.object-storage.default.path-style-access=true
Step 6: Use Environment Variables in Kubernetes Deployment
Update your Micronaut app's Kubernetes deployment to use these values:
env:
- name: MICRONAUT_ENVIRONMENTS
value: prod
- name: MINIO_ENDPOINT
valueFrom:
configMapKeyRef:
name: minio-config
key: MINIO_ENDPOINT
- name: MINIO_ACCESS_KEY
valueFrom:
secretKeyRef:
name: minio-secret
key: MINIO_ACCESS_KEY
- name: MINIO_SECRET_KEY
valueFrom:
secretKeyRef:
name: minio-secret
key: MINIO_SECRET_KEY
This ensures that your application will automatically pull MinIO configuration based on the production profile.
Step 7: Summary
By splitting your configurations into
application-dev.properties
and
application-prod.properties
, you create a clear separation between development and production. This makes your Micronaut app safer and easier to maintain.
- Docker handles your dev environment with hardcoded values in a local instance.
- Kubernetes handles production, securely injecting variables through Secrets and ConfigMaps.
- Micronaut’s native support for environment-specific properties simplifies switching between environments.
This setup is perfect for projects that need a fast, scalable, and reliable object storage solution without the overhead of managing AWS S3 directly.
image quote pre code