I'm trying to reference an external properties file to override the default spring properties file.
Dockerfile
FROM eclipse-temurin:latest
VOLUME /tmp
COPY ./target/basicRestApp-0.0.1-SNAPSHOT.jar app/app.jar
ENTRYPOINT ["java","-jar","app/app.jar"]
Deployment
volumeMounts:
- name: config-volume
mountPath: /app/config
volumes:
- name: config-volume
configMap:
name: test-config-map
Configmap
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config-map
namespace: default
data:
application.yaml: |-
key: value .....
I've tried to reference the external properties file with a @Configuration class with @PropertySource("file:$/config/application.yaml")
and attempt to build the program (maven) I get the error "$/config/application.yaml (No such file or directory)"
and I'm unable to build.
I've also tried adding the command line argument --spring.config.location=file:/app/config/application.yaml in my docker file. This results in another error java.lang.IllegalStateException: Could not load store from '/root/rins_common/rins_service_config/rins-keystore'
I was expecting to be able to build the application and have the application reference the later-created properties file. But this makes sense because that file path does not exist till the manifests are applied to the cluster.
instead of using @PropertySource you could try to add the command line argument --spring.config.location=file:/app/config/application.yaml
to the entrypoint, if you want override the default spring properties file.
you can also add this to your K8 Deployment YAML instead of the Dockerfile.