I yell at developers for hardcoding BS at least once a week, BUT, using service discovery and your use case it's actually a good time to do it. app1 connects to app2, it may as well connect to
http://app2:8080/ and let k8s service discovery find it for you, or consul or, etc..
For containerizing springboot specifically, addressing non mesh endpoints:
1. delete every dev.properties, qa.properties, etc.. Environment configuration does NOT belong in code. if java even knows what environment it's in, it's wrong.
2. in the application.properties .. or application.yaml . There is where you define the datasources you need as profiles. user-db, service-api, etc.. just the name.
3. deployment settings for the container: env: SPRING_CONFIG_ADDITIONAL_LOCATION = "file:/where/you/mount/the/volume" ex "file:/configmap"
4. in the deployed environment is where you configure those
datasources. a configmap in k8s, a secret for ECS, etc.. and mount
that config as a volume in the containers deployed.
configmap data:
- key: application-user-db.profile
value: |
user-db.user=whatever
user-db.pass=whatelseever
- key: application-service-api.yaml
value: |
etc..
or using the default springboot datasource object? whatever that's called:
value: |
spring.datasource.password=123!