<p>I'm trying to access the following db in my flask app</p>

<pre><code>app.config['MONGO_DBNAME'] = 'pymongo_db'
app.config['MONGO_URI'] = 'mongodb://&lt;dbuser&gt;:&lt;dbpassword&gt;@ds163984.mlab.com:63984/pymongo_db'
</code></pre>

<p>but istio is blocking me so I created a <code>ServiceEntry</code> and a <code>VirtualService</code>. However, I think my config is wrong as it's not working correctly. Can somehow tell me what I'm doing wrong? <a href="https://istio.io/docs/tasks/traffic-management/egress/" rel="nofollow noreferrer">https://istio.io/docs/tasks/traffic-management/egress/</a></p>

<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: mlab
spec:
  hosts:
  - wwww.ds163984.mlab.com
  - ds163984.mlab.com
  ports:
  - number: 443
    name: https
    protocol: HTTPS
  resolution: DNS
  location: MESH_EXTERNAL
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: mlab
spec:
  hosts:
  - wwww.ds163984.mlab.com
  - ds163984.mlab.com
  tls:
  - match:
    - port: 443
      sni_hosts:
      - wwww.ds163984.mlab.com
      - ds163984.mlab.com
    route:
    - destination:
        host: ds163984.mlab.com
        port:
          number: 443
      weight: 100
</code></pre>

jor2
<p>Off hand, I see at least a couple of things wrong with your configuration. The port in your <code>ServiceEntry</code> and <code>VirtualService</code> should be the mongodb port (63984), not 443, and the protocol should be TLS, not HTTPS.</p>

<p>There is an <a href="https://preliminary.istio.io/blog/2018/egress-mongo/" rel="nofollow noreferrer">excellent blog post</a> on various ways to configure access to mongodb. It sounds like <a href="https://preliminary.istio.io/blog/2018/egress-mongo/#control-tls-egress-traffic-without-a-gateway" rel="nofollow noreferrer">this section</a> is what you are trying to do.</p>
