我有一个运行良好的Docker Python映像的POD,它是侦听并等待连接的“服务器”。
#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()
这是我与Linkerd一起运行的deployment.yaml(就我而言,这不是谁在影响程序)
---
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
因此,只要代码在Kubernetes中运行,“ print(“ Last checkpoint”)'就可以了。它之前运行2个线程,一个仅处理程序内部的一些数据,另一个运行flask REST API,两个线程都运行良好,但是代码没有超出这个范围。当我尝试连接时,它会连接它,但它会等待一条消息(这是行为),但是就像python代码从不发送该消息。就像客户端可以连接,但服务器不承认。