Skip to content
Advertisement

Unable to load config data to springboot application from mounted volume in kubernetes

I have springboot application and I am trying to load additional configuration from a volume mounted location /tmp/secret-config.yaml and getting below error: java.lang.IllegalStateException: Unable to load config data from ‘/tmp/secret-config.yaml’

I do not want to use configmap or secrets for this. It’s a simple json file which I am trying to load.

I am trying to pass it like this from shell script. java -jar /opt/app.jar –spring.config.additional-location=/tmp/secret-config.yaml

Can anyone please help ?

Advertisement

Answer

I would suggest to verify the volume mount of the file inside your pod. You can verify it with the following commands:

kubectl exec -it <podName> -- cat /tmp/secret-config.yaml

kubectl exec -it <podName> -- ls /tmp

In addition, the volume mount configuration in your yaml file would be interesting. Did you specify a mountPath for the volumeMount in your pod configuration? You can also check the mountPath with the following command:

# for a pod with a single container and only one volumeMount
kubectl get pods <podName> -o jsonpath='{.spec.containers[0].volumeMounts[0].mountPath}'
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement