<p>It can connect fine whenever I try to access it via the worker node's address, but not when I try access via the ingress gateway. I get the following error:</p>
<pre><code>pymongo.errors.ServerSelectionTimeoutError
pymongo.errors.ServerSelectionTimeoutError: mongo:27017: timed out, Timeout: 30s, Topology Description: &lt;TopologyDescription id: 60119598e7c0e0d52f58c52c, topology_type: Single, servers: [&lt;ServerDescription ('mongo', 27017) server_type: Unknown, rtt: None, error=NetworkTimeout('mongo:27017: timed out',)&gt;]&gt;
</code></pre>
<p>This is how I connect to MongoDB via python which works fine when not accessing over the ingress url.</p>
<pre><code>mongo = MongoClient(&quot;mongodb://mongo:27017/user_data&quot;)
</code></pre>
<p>This is my ingress.yaml file</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: weasel-ingress
spec:
  rules:
  - host: {host-address}
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          serviceName: weasel
          servicePort: 5000
      - path: /
        pathType: Prefix
        backend:
          serviceName: mongo
          servicePort: 27017
</code></pre>
<p>Any idea's on how to get it to connect via ingress? I guess I need to add mongo to the ingress?</p>
<p>Both services are already exposed via external ip's.</p>
<pre><code>kubectl get svc
NAME         TYPE           CLUSTER-IP       EXTERNAL-IP      PORT(S)           AGE
kubernetes   ClusterIP      172.21.0.1       &lt;none&gt;           443/TCP           19h
mongo        LoadBalancer   172.21.218.91    {exposed-ip}   27017:31308/TCP   17h
weasel       LoadBalancer   172.21.152.134   {exposed-ip}   5000:32246/TCP    17h
</code></pre>
<p>ingress logs:</p>
<pre><code>kubectl describe ingress weasel-ingress
Name:             weasel-ingress
Namespace:        default
Address:          
Default backend:  default-http-backend:80 (&lt;error: endpoints &quot;default-http-backend&quot; not found&gt;)
Rules:
  Host                                                                                  Path  Backends
  ----                                                                                  ----  --------
  {host-address}  
                                                                                        /   weasel:5000 (172.30.27.69:5000)
                                                                                        /   mongo:27017 (&lt;none&gt;)
Annotations:                                                                            &lt;none&gt;
Events:
  Type    Reason  Age   From                      Message
  ----    ------  ----  ----                      -------
  Normal  CREATE  27s   nginx-ingress-controller  Ingress default/weasel-ingress
  Normal  CREATE  27s   nginx-ingress-controller  Ingress default/weasel-ingress
  Normal  CREATE  27s   nginx-ingress-controller  Ingress default/weasel-ingress
</code></pre>

<p>Ingress are mostly for HTTP connections, ingress is not option to access mongodb.</p>
<p>You can use the Service type <strong>LoadBalancer</strong> or service type <strong>Node port</strong>.</p>
<p>Ingress controllers(ex Nginx-ingress) can support plain TCP load balancers.</p>
