- Replies:
- 0
- Words:
- 6597

application.yml
files. We’ll cover settings for both development and production environments. For production, we’ll show how to pull values from a Kubernetes ConfigMap.To connect Spring Boot with MinIO, you need to define the following:
url
: MinIO server endpointaccessKey
: your MinIO username or access IDsecretKey
: your MinIO password or secret keyThese values can live in your configuration files or be injected as environment variables—depending on your environment (dev vs prod).
Here’s how to set up MinIO settings in your application-dev.yml
:
minio:
url: http://localhost:9000
accessKey: minioadmin
secretKey: minioadmin123
Now your app knows how to connect to MinIO during development!
In production, you should never hardcode secrets or environment-specific values. Instead, use a Kubernetes ConfigMap to safely manage configuration.
Let’s create a ConfigMap called minio-config
. Here’s the YAML:
apiVersion:v1
kind:ConfigMap
metadata:
name:minio-config
namespace:your-namespace
data:
urlMinIO:http://minio-service:9000
accesskey:your-access-key
secretkey:your-secret-key
This ConfigMap holds the MinIO settings you’ll inject into your Spring Boot app.
In your deployment YAML, pass the values as environment variables to your app container:
containers:
- name: your-app
image: your-image
env:
- name: MINIO_URL
valueFrom:
configMapKeyRef:
name: minio-config
key: urlMinIO
- name: MINIO_ACCESS_KEY
valueFrom:
configMapKeyRef:
name: minio-config
key: accesskey
- name: MINIO_SECRET_KEY
valueFrom:
configMapKeyRef:
name: minio-config
key: secretkey
This will make the MinIO details available to Spring Boot as environment variables.
Update your Spring configuration files to use the environment variables.
minio:
url: ${MINIO_URL}
accessKey: ${MINIO_ACCESS_KEY}
secretKey: ${MINIO_SECRET_KEY}
Spring Boot will automatically replace the placeholders with the values from the environment.
To manage different settings for development and production, use Spring profiles.
Create separate config files:
application-dev.yml
→ used during local developmentapplication-prod.yml
→ used in production (e.g., in Kubernetes)Then, activate the correct profile by setting the SPRING_PROFILES_ACTIVE
environment variable.
For local:
SPRING_PROFILES_ACTIVE=dev
For Kubernetes:
env:
name: SPRING_PROFILES_ACTIVE
value: prod
Each profile loads its own settings, keeping dev and prod cleanly separated.
image quote pre code