title: Kubernetes Pod container's websocket not reachable
body: <p>I've created a sample spring boot application that exposes a websocket endpoint at localhost:8080/ws. 
  Basically I followed this <a href="https://spring.io/guides/gs/messaging-stomp-websocket/" rel="nofollow noreferrer">guide</a> except for I am not using the .withSockJS Option. </p>
  
  <p>When I run this application locally, my sample angular app can connect to the websocket. </p>
  
  <p>Now I want to have both containers (spring boot app and angular app) in a single Kubernetes pod. 
  They both spin up when I run them. Then I expose the angular frontend's port to be able to view the app. But the logs tell me that it is not able to connect to the websocket backend via ws://localhost:8080/ws</p>
  
  <p>Even when I connect to the backend container, I can see that it is up and running, but my curl websocket test also always fails. </p>
  
  <p>This is my pod def:</p>
  
  <pre><code>---
   apiVersion: v1
   kind: Pod
   metadata:
     name: my-app.example.org
     labels:
       app: my-app-system
   spec:
     containers:
       - name: backend
         image: test/my-app-backend
         ports:
           - containerPort: 8080
         env:
         - name: SPRING_PROFILES_ACTIVE
           value: "dev-docker-postgres"
         - name: JAVA_OPTIONS
           value: "-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=n"
       - name: frontend
         image: test/my-app-frontend
         ports:
           - containerPort: 4200
         imagePullPolicy: Always
         command: ["/bin/sh"]
         args: ["-c", "npm run kubstart"]
  
     imagePullSecrets:
       - name: registrykey 
  </code></pre>
  
  <p>One more thing: </p>
  
  <p>When I additionally expose the backend container's port via NodePort type, and start the angular app locally on my machine with the service's url the websocket connection succeeds. </p>
  
  <p>It seems I am not able to let both containers in my pod communicate with each other via ws:// </p>