<p>I have a Ruby script that connects to MongoDB Atlas for getting some data. It does work perfectly if I:</p>

<ol>
<li>Run the script locally</li>
<li>Run the script locally with docker</li>
<li>Run the script in a separated AWS EC2 Instance</li>
<li>Run the script in docker inside a seperated AWS EC2 instance</li>
<li>Run the script inside local cluster with minikube.</li>
</ol>

<p>However it doesn't work inside kubernetes, I am using EKS.</p>

<p>I have tried all items listed before and make sure the user exists on MongoDB Atlas.</p>

<p>This is pretty much the output that I receive:</p>

<pre><code>User moon (mechanism: scram) is not authorized to access test (used mechanism: SCRAM-SHA-1) (Mongo::Auth::Unauthorized)
</code></pre>

<p>I'd appreciate any input.</p>

xorb
<p>Solved by adding <code>&amp;authSource=admin</code> to the connection string.</p>
