<p>I want to expose 2 services:</p>
<ul>
<li>web application at <strong>example.com</strong> port <strong>80</strong></li>
<li>web sockets at <strong>example.com/app/ws</strong> port <strong>8000</strong></li>
</ul>
<p>with given configuration:</p>
<hr />
<pre><code>apiVersion: &quot;v1&quot;
kind: &quot;Service&quot;
metadata:
  name: &quot;web-app-service&quot;
  annotations:
    cloud.google.com/load-balancer-type: &quot;Internal&quot;
spec:
  type: &quot;LoadBalancer&quot;
  selector:
    app.kubernetes.io/instance: &quot;web-app&quot;
  ports:
    - protocol: &quot;TCP&quot;
      port: 80
      targetPort: 80
      name: &quot;http&quot;
---
apiVersion: &quot;v1&quot;
kind: &quot;Service&quot;
metadata:
  name: &quot;web-sockets-service&quot;
spec:
  type: &quot;NodePort&quot;
  selector:
    app.kubernetes.io/instance: &quot;web-sockets&quot;
  ports:
    - protocol: &quot;TCP&quot;
      port: 8000
      targetPort: 8000
      name: &quot;http&quot;
---
apiVersion: &quot;networking.k8s.io/v1&quot;
kind: &quot;Ingress&quot;
metadata:
  name: &quot;web-app-ingress&quot;
  annotations:
    kubernetes.io/ingress.class: &quot;gce&quot;
spec:
  rules:
    - host: &quot;example.com&quot;
      http:
        paths:
          - path: &quot;/app/ws&quot;
            pathType: &quot;Prefix&quot;
            backend:
              service:
                name: &quot;web-sockets-service&quot;
                port:
                  number: 8000
          - path: &quot;/&quot;
            pathType: &quot;Prefix&quot;
            backend:
              service:
                name: &quot;web-app-service&quot;
                port:
                  number: 80
---
</code></pre>
<p>I can reach web application at <strong>example.com</strong>, but trying to communicate with <strong>example.com/app/ws</strong> results with failed to connect - timeout. Curl call to internal service IP at port 8000 results with success, so im misconfigured something at ingress configuation of web sockets</p>
<pre><code>curl -i -N -H &quot;Connection: Upgrade&quot; -H &quot;Upgrade: websocket&quot; example.com/app/ws:8000
</code></pre>
<p>results with timeout</p>
<p>internal cluster call (different pod than websocket server):</p>
<pre><code>curl -i -N -H &quot;Connection: Upgrade&quot; -H &quot;Upgrade: websocket&quot; &lt;web-sockets-service ip&gt;/app/ws:8000
</code></pre>
<p>result with success websocket server response</p>
<p>Websocat:</p>
<p>request to service:</p>
<pre><code>&gt; websocat ws://&lt;web-sockets-service ip&gt;:8000/app/ws
{&quot;event&quot;:&quot;connection_established&quot;,&quot;data&quot;:&quot;{\&quot;socket_id\&quot;:\&quot;620572367.722478523\&quot;,\&quot;activity_timeout\&quot;:30}&quot;}
</code></pre>
<p>request to ingress:</p>
<pre><code>&gt; websocat ws://example.com:8000/app/ws
websocat: WebSocketError: I/O Failure
websocat: error running
</code></pre>

<p>I found the problem was with used port 8000 for websocket server. Used port was not open on firewall, after changing websocket server port to 80, everything started working.</p>
