Azure Kubernetes 保活 TCP 套接字
Azure Kubernetes keep-alive TCP socket
我想将打开 TCP 连接的移动设备连接到我的一项 kubernetes 服务。问题是在 10 分钟的心跳间隔之前连接被杀死。
下面是我的部署
apiVersion: apps/v1
kind: Deployment
metadata:
name: device-gateway
labels:
app: device-gateway
spec:
replicas: 1
strategy:
rollingUpdate:
maxUnavailable: 0
selector:
matchLabels:
app: device-gateway
template:
metadata:
labels:
app: device-gateway
spec:
containers:
- name: device-gateway
image: [IMAGE]
imagePullPolicy: Always
imagePullSecrets:
- name: myregistrykey
---
apiVersion: v1
kind: Service
metadata:
name: device-gateway
spec:
type: ClusterIP
ports:
- name: my-device-port
port: 8485
protocol: TCP
selector:
app: device-gateway
我尝试在 Ingress 中设置以下注释
nginx.ingress.kubernetes.io/proxy-socket-keepalive: "on"
nginx.ingress.kubernetes.io/proxy-send-timeout: "1800s"
nginx.ingress.kubernetes.io/proxy-stream-timeout: "1800s"
nginx.org/proxy-send-timeout: "1800s"
service.beta.kubernetes.io/azure-load-balancer-tcp-idle-timeout: "30"
此外,public IP 中的“空闲超时”设置为 30 分钟。 LoadBalancer 规则也是如此。
我这样安装入口控制器:
helm install nginx-ingress ingress-nginx/ingress-nginx \
--set tcp.8485="default/device-gateway:8485" \
--set [more irrelevant settings here]
我猜这与配置有关,那么如何将超时设置为 30 分钟?
我已经发布了社区维基答案来总结主题。
OP 已找到解决方法。他在评论中提到过:
I did not find the solution to the problem, but I did remove the problem by send a heartbeat the other way every 5 minutes to keep the line open.
我找到了关于 Configure TCP reset and idle timeout for Azure Load Balancer. It could help set tcp reset and idle timeout from the Azure portal 的文章。
我想将打开 TCP 连接的移动设备连接到我的一项 kubernetes 服务。问题是在 10 分钟的心跳间隔之前连接被杀死。
下面是我的部署
apiVersion: apps/v1
kind: Deployment
metadata:
name: device-gateway
labels:
app: device-gateway
spec:
replicas: 1
strategy:
rollingUpdate:
maxUnavailable: 0
selector:
matchLabels:
app: device-gateway
template:
metadata:
labels:
app: device-gateway
spec:
containers:
- name: device-gateway
image: [IMAGE]
imagePullPolicy: Always
imagePullSecrets:
- name: myregistrykey
---
apiVersion: v1
kind: Service
metadata:
name: device-gateway
spec:
type: ClusterIP
ports:
- name: my-device-port
port: 8485
protocol: TCP
selector:
app: device-gateway
我尝试在 Ingress 中设置以下注释
nginx.ingress.kubernetes.io/proxy-socket-keepalive: "on"
nginx.ingress.kubernetes.io/proxy-send-timeout: "1800s"
nginx.ingress.kubernetes.io/proxy-stream-timeout: "1800s"
nginx.org/proxy-send-timeout: "1800s"
service.beta.kubernetes.io/azure-load-balancer-tcp-idle-timeout: "30"
此外,public IP 中的“空闲超时”设置为 30 分钟。 LoadBalancer 规则也是如此。
我这样安装入口控制器:
helm install nginx-ingress ingress-nginx/ingress-nginx \
--set tcp.8485="default/device-gateway:8485" \
--set [more irrelevant settings here]
我猜这与配置有关,那么如何将超时设置为 30 分钟?
我已经发布了社区维基答案来总结主题。
OP 已找到解决方法。他在评论中提到过:
I did not find the solution to the problem, but I did remove the problem by send a heartbeat the other way every 5 minutes to keep the line open.
我找到了关于 Configure TCP reset and idle timeout for Azure Load Balancer. It could help set tcp reset and idle timeout from the Azure portal 的文章。