Kubernetes POD can't send messages via websockets

8/13/2019

I've got a POD using a Docker Python Image that runs fine, it's a 'server' listening and waiting for a connection.

#Main
    try:
        s = socket.socket()
        host = "0.0.0.0"
        port = 24000
        s.bind((host, port))
        s.listen(5)
        while True:
            print("Last checkpoint")
            c, addr = s.accept()
            print('Got connection from', addr)
            c.send(("Connection accepted!").encode('utf-8'))
            thread3 = Thread( target=on_new_client, args=(c, addr,  ) )
            thread3.start()
    except:
        print("Oops!",sys.exc_info(),"occured.")
    s.close()

And this is a deployment.yaml which I run along with Linkerd (which it's not who is affecting the program as far as I am concerned)

---
apiVersion: v1
kind: Namespace
metadata:
  name: linkerd-test
---
 apiVersion: v1
 kind: Pod
 metadata:
   annotations:
        config.linkerd.io/proxy-log-level: "debug"
   name: equipment-service
   namespace: linkerd-test
   labels:
     app: equipment-app
 spec:
   containers:
     - name: equipment-container
       image: tcnl/equipment:1.0
       ports:
        - containerPort: 24001
        - containerPort: 24000

So the 'print("Last checkpoint")' is as far as the code runs inside Kubernetes. It runs 2 threads before, one that just manipulates some data inside the program and other running a flask REST API, both threads run fine, but the code does not go beyond that point. When I try to connect, IT CONNECTS but it waits for a message (which is the behaviour), but it's like the python code never sends that message. It's like the clients can connect but the server doesn't acknowledge that.

-- Thiago Casa Nova
kubernetes
linkerd
python
websocket

0 Answers