#1
Integrating MinIO, a high-performance object storage system, into your Quarkus application can enhance its capability to handle large-scale data storage. This guide walks you through setting up MinIO using Docker for development and Kubernetes for production, leveraging application.properties files tailored for each environment.

1. Adding MinIO and Kubernetes Dependencies

First, ensure your pom.xml includes the necessary dependencies:
<dependencies>
  <!-- MinIO SDK for Java -->
  <dependency>
    <groupId>io.minio</groupId>
    <artifactId>minio</artifactId>
    <version>8.5.3</version>
  </dependency>

  <!-- Quarkus Kubernetes Config Extension -->
  <dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-kubernetes-config</artifactId>
  </dependency>
</dependencies>
These dependencies enable MinIO communication and Kubernetes integration within your Quarkus application.

2. Setting Up MinIO with Docker for Development

For development, you can use Docker to run MinIO. Create a docker-compose.yml file with the following content:
version: '3.7'
services:
  minio:
    image: minio/minio
    ports:
      - "9000:9000"
      - "9001:9001"
    environment:
      MINIO_ROOT_USER: minioadmin
      MINIO_ROOT_PASSWORD: minioadmin
    volumes:
      - minio-data:/data
    command: server /data --console-address ":9001"

volumes:
  minio-data:
Start MinIO:
docker-compose up
This setup provides a local MinIO instance accessible for testing and development purposes.

3. Configuring application-dev.properties

Create a file named application-dev.properties in src/main/resources/ with the following content:
quarkus.profile=dev
minio.endpoint=http://localhost:9000
minio.access-key=minioadmin
minio.secret-key=minioadmin
minio.bucket=dev-bucket
This configuration sets up the MinIO client to connect to the local instance.
To run the application with the development profile:
./mvnw quarkus:dev -Dquarkus.profile=dev
Quarkus will automatically use the application-dev.properties file for configuration.

4. Preparing for Production with Kubernetes

In a production environment, it's advisable to manage sensitive information like MinIO configurations using Kubernetes Secrets and ConfigMaps.

4.1. Create Kubernetes Secret for MinIO Credentials

kubectl create secret generic minio-credentials \
  --from-literal=minio-access-key=prodadmin \
  --from-literal=minio-secret-key=prodsecret

4.2. Create Kubernetes ConfigMap for MinIO Endpoint

kubectl create configmap minio-config \
  --from-literal=minio-endpoint=http://minio-service:9000 \
  --from-literal=minio-bucket=prod-bucket
These resources store your MinIO configuration securely and make it accessible to your application.

5. Configuring application-prod.properties

Create a file named application-prod.properties in src/main/resources/ with the following content:
quarkus.profile=prod
minio.endpoint=${MINIO_ENDPOINT}
minio.access-key=${MINIO_ACCESS_KEY}
minio.secret-key=${MINIO_SECRET_KEY}
minio.bucket=${MINIO_BUCKET}
quarkus.kubernetes-config.enabled=true
quarkus.kubernetes-config.config-maps=minio-config
quarkus.kubernetes-config.secrets=minio-credentials
This configuration uses environment variables provided by Kubernetes to set up the MinIO client for production.

6. Deploying Quarkus Application to Kubernetes

When deploying your Quarkus application to Kubernetes, ensure the environment variables are correctly set using the previously created Secret and ConfigMap:
env:
  - name: QUARKUS_PROFILE
    value: prod
  - name: MINIO_ENDPOINT
    valueFrom:
      configMapKeyRef:
        name: minio-config
        key: minio-endpoint
  - name: MINIO_BUCKET
    valueFrom:
      configMapKeyRef:
        name: minio-config
        key: minio-bucket
  - name: MINIO_ACCESS_KEY
    valueFrom:
      secretKeyRef:
        name: minio-credentials
        key: minio-access-key
  - name: MINIO_SECRET_KEY
    valueFrom:
      secretKeyRef:
        name: minio-credentials
        key: minio-secret-key
This setup ensures that your application retrieves the necessary configuration from Kubernetes resources during deployment.
By separating your MinIO configuration into application-dev.properties and application-prod.properties, you can maintain clean and secure environments for development and production.
Utilizing Docker for local development and Kubernetes for production allows for scalable and manageable deployments.
Remember to:
  • Use Docker to run a local MinIO instance during development.
  • Store configuration data in Kubernetes Secrets and ConfigMaps.
  • Reference these Kubernetes resources in your application's environment variables.
This approach provides a robust and flexible setup for integrating MinIO into your Quarkus applications across different environments.

image quote pre code