【问题标题】:Azure Kubernetes keep-alive TCP socketAzure Kubernetes 保持活动 TCP 套接字
【发布时间】:2021-12-26 15:20:17
【问题描述】:

我想将一个打开 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"

此外,公共 IP 中的“空闲超时”设置为 30 分钟。 LoadBalancer 规则也是如此。

我是这样安装入口控制器的:

helm install nginx-ingress ingress-nginx/ingress-nginx \
    --set tcp.8485="default/device-gateway:8485" \
    --set [more irrelevant settings here]

我猜它与配置有关,那么如何让超时为 30 分钟?

【问题讨论】:

  • 您使用的是哪个版本的 Kubernetes,您是如何设置集群的?您是否使用裸机安装或某些云提供商?重现您的问题很重要。
  • 我使用 Azure 作为云提供商。我会在一分钟内找到的版本
  • 我没有找到问题的解决方案,但我确实通过每隔 5 分钟发送一次心跳以保持线路畅通,从而消除了问题。
  • 您是否尝试像in this example那样设置空闲超时?

标签: azure nginx kubernetes timeout kubernetes-ingress


【解决方案1】:

我已发布社区 wiki 答案以总结主题。

OP 找到了解决方法。他在评论中提到过:

我没有找到问题的解决方案,但我确实通过每隔 5 分钟发送一次检测信号以保持线路畅通,从而消除了问题。

我找到了关于Configure TCP reset and idle timeout for Azure Load Balancer 的文章。它可以从Azure portal 帮助set tcp reset and idle timeout

【讨论】:

  • 感谢您发布答案。不过,我已经设置了文章中提到的超时。我将继续尝试解决超时问题,并在找到答案后发布。
猜你喜欢
  • 2020-12-20
  • 2020-01-12
  • 2014-02-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-03
  • 2015-10-17
  • 2010-09-23
相关资源
最近更新 更多