<p>I have several <a href="https://stackoverflow.com/questions/58167618/exception-has-occurred-mongodarterror-mongodart-error-invalid-scheme-in-uri?rq=1">pages</a> that I found with similar question and most answer tell us to white list our IP. However I have allowed access from anywhere <code>0.0.0.0/0</code> in the atlas, and have installed the latest version of <code>mongoose</code>(6.2.6 ; which is supposed to have support for the protocol (mongodb+srv).</p>
<p>The connection works perfectly when I run locally using <code>npm start</code> or even from a dockerized container. But, when I deploy to a k8s cluster, I get an error saying:</p>
<pre><code>querySrv ENOTFOUND _mongodb._tcp.mongodb-cluster0.zvnxj.mongodb.net
</code></pre>
<p>The deployment and service file are as:</p>
<p><code>deployment.yml</code></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: ns-my-workflow-api
  name: my-workflow-api
spec:
  replicas: 2
  selector:
    matchLabels:
      app: my-workflow-api
  template:
    metadata:
      labels: 
        app: my-workflow-api
    spec:
      containers:
        - name: my-workflow-api
          image: &quot;myname/my-workflow-api:1.0.0&quot;
          ports:
            - containerPort: 3000
          imagePullPolicy: IfNotPresent
          resources:
              limits:
                cpu: &quot;256m&quot;   
</code></pre>
<p>The <code>service.yaml</code> has the contents:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  namespace: ns-my-workflow-api
  name: my-workflow-api
spec:
  selector:
    app: my-workflow-api
  type: LoadBalancer
  ports:
    - name: http
      port: 8000
      targetPort: 3000
      protocol: TCP  
</code></pre>
<p>The <code>namespace.yaml</code> has the contents:</p>
<pre><code>apiVersion: v1
kind: Namespace
metadata:
  name: ns-my-workflow-api
</code></pre>
<p>I also tried the <code>deployment.yaml</code> with the <code>dns</code> rule:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: ns-my-workflow-api
  name: my-workflow-api
spec:
  replicas: 2
  selector:
    matchLabels:
      app: my-workflow-api
  template:
    metadata:
      labels: 
        app: my-workflow-api
    spec:
      dnsPolicy: Default            # &lt;------ this rule
      containers:
        - name: my-workflow-api
          image: &quot;myname/my-workflow-api:1.0.0&quot;
          ports:
            - containerPort: 3000
          imagePullPolicy: IfNotPresent
          resources:
              limits:
                cpu: &quot;256m&quot;
</code></pre>
<p>Once I changed the connection url to use <code>2.0.14 or earlier</code> I was able to connect. The connection string started with <code>mongodb://....</code></p>
<p>While I have managed to make the connection work with the workaround using an old-style connection string, and it seems to be some sort of dns resolution issue, how do I make the newer protocols work to connect to atlas from inside the cluster?  Thanks in advance</p>

juztcode
<p>I was able to solve it using this to start <code>minikube</code>:</p>
<p><code>minikube start --driver=docker</code></p>
<p>It seems there's some dns resolution issue with the underlying oracle's virtualbox driver(Maybe some configuration and setup issue as well)</p>
