Strangeness with MONGO_URL SSL on K8S/Docker

I am seeing strange behavior strange behavior where a MONGO_URL with the ssl=true parameter is not working in a docker container with the MONGO_URL being passed in as an environment variable.

Meteor 1.8 application being built and packaged as a pure Node.js app (Node.js 8.11). When run on an node application server with MONGO_URL passed in as an environment variable, the system works as expected. When run as a docker container under kubernetes with MONGO_URL passed in as an environment variable, Meteor seems to be ignoring the ssl=true parameter on the MONGO_URL.

If I add code to force the ssl encryption…

Mongo.setConnectionOptions({
ssl: true,
sslValidate: false
});

then the container version works as desired.

Does anyone have any insight into what may be going on?

What’s the exact connection string you’re specifying? Is it possible you need to escape an ampersand?

I wrote a quick sample app that demonstrates the issue. Inside its Meteor.startup method, I have

  console.log(process.env.MONGO_URL);

when this runs I see the following (as a single line) in the log

mongodb://USER:PASSWORD@mongo1:27017,mongo2:27017,mongo3:27017/DB?replicaSet=RS&readPreference=primaryPreferred&w=majority&autoReconnect=true&ssl=true

At that point we are past all shell manipulation, etc.

=============================
Kept digging… Leaving this here just in case anyone else runs into a similar wall in the future.

There is some difference between how k8s pulls in env variables using envFrom.secretRef and from env with a secretKeyRef value. Even though everything looks good.

Not sure what the difference is, but switching to the latter made everything work.