We have a simple setup where mongo is running in a very basic configuration on k8s.
From another pod in the same namespace I can login to mongodb with mongosh and the mongo logs look like this:
{"t":{"$date":"2022-08-04T13:11:13.414+00:00"},"s":"I", "c":"NETWORK", "id":51800, "ctx":"conn417","msg":"client metadata","attr":{"remote":"10.0.3.218:55322","client":"conn417","doc":{"driver":{"name":"nodejs|mongosh","version":"4.8.1"},"os":{"type":"Linux","name":"linux","architecture":"x64","version":"5.10.118"},"platform":"Node.js v16.16.0, LE (unified)","version":"4.8.1|1.5.4","application":{"name":"mongosh 1.5.4"}}}}
{"t":{"$date":"2022-08-04T13:11:13.420+00:00"},"s":"I", "c":"ACCESS", "id":20250, "ctx":"conn417","msg":"Authentication succeeded","attr":{"mechanism":"SCRAM-SHA-256","speculative":true,"principalName":"root","authenticationDatabase":"admin","remote":"10.0.3.218:55322","extraInfo":{}}}
When using the exact same URI in PyMongo, the connection succeeds, but never authenticates, so it ends up timing out after trying to find mongo at 127.0.0.1.
{"t":{"$date":"2022-08-04T13:14:18.711+00:00"},"s":"I", "c":"NETWORK", "id":22943, "ctx":"listener","msg":"Connection accepted","attr":{"remote":"10.0.3.218:40240","uuid":"fbc15467-2262-4f82-b563-dab6961e65ed","connectionId":421,"connectionCount":4}}
{"t":{"$date":"2022-08-04T13:14:18.712+00:00"},"s":"I", "c":"NETWORK", "id":51800, "ctx":"conn421","msg":"client metadata","attr":{"remote":"10.0.3.218:40240","client":"conn421","doc":{"driver":{"name":"PyMongo","version":"4.2.0"},"os":{"type":"Linux","name":"Linux","architecture":"x86_64","version":"5.10.118"},"platform":"CPython 3.10.4.final.0"}}}
{"t":{"$date":"2022-08-04T13:14:18.713+00:00"},"s":"I", "c":"NETWORK", "id":22944, "ctx":"conn421","msg":"Connection ended","attr":{"remote":"10.0.3.218:40240","uuid":"fbc15467-2262-4f82-b563-dab6961e65ed","connectionId":421,"connectionCount":3}}