spring-data-mongodb/k8s "Database name must not contain slashes, dots, spaces, quotes, or dollar signs"

4/27/2018

I'm at a real loss on this one. I've been attempting to get my application running with a replica set in Kubernetes for awhile. I'm setting: spring.data.mongodb.uri=${MYAPP_MONGODB}:mongodb://localhost:27017/myapp in application.properties and using Spring Data to access my objects.

Locally using a local MongoDB container it works fine even if I set the env var to my remote databases locally I can connect to them and work just fine. But when I put the value of MYAPP_MONGODB into k8s secrets when the container boots I get quoted error from the title. The value is like this:

mongodb://myuser:mypasswd@1.1.1.1:27017,2.2.2.2:27017,3.3.3.3:27017,4.4.4.4:27017,5.5.5.5:27017/myapp

I reviewed the source and still baffled as to why this is happening. Pulling the secret from the k8s environment it is correct.

Any help is much appreciated!

-- lemoney
kubernetes
mongodb
spring
spring-boot
spring-data-mongodb

1 Answer

4/27/2018

It sounds like your secret in k8s might be setup incorrectly. I would try uploading your secrets again and decoding them to make sure they are correct. Careful for random line breaks :)

-- Dustin G
Source: StackOverflow