ingress-nginx: TCP connection to Azure K8S always killed in 600 seconds

What happened:

We are running a k8s cluster in Azure and one of the services is a TCP server with which clients are connecting and communicating. These devices send out heartbeats every ~600s (+/- 10s) to keep the connection alive. After our migration from VPS to Azure, the are disconnecting a lot.
After loads of troubleshooting with Azure support engineers, they came to the conclusion that it must be the nginx-ingress controller.

We tested with a basic client-server application that tries to strip every external factor. The conclusion of this test was that it disconnected at 600,000ms. Having a 599,990ms heartbeat, it never disconnected. The basic TCP app can be found here (https://gitlab.com/cuebly/tcptest)

install-ingress.sh This is the file that we use to install the ingress with:
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm uninstall nginx-ingress
helm install nginx-ingress ingress-nginx/ingress-nginx \
    --set controller.replicaCount=2 \
    --set controller.service.externalTrafficPolicy=Local \
    --set controller.nodeSelector."kubernetes\.io/os"=linux \
    --set defaultBackend.nodeSelector."kubernetes\.io/os"=linux \
    --set controller.admissionWebhooks.patch.nodeSelector."kubernetes\.io/os"=linux \
    --set controller.service.loadBalancerIP="[PUBLIC-IP]" \
    --set controller.service.annotations."service\.beta\.kubernetes\.io/azure-dns-label-name"="[DNS-NAME]" \
    --set controller.service.annotations."service\.beta\.kubernetes\.io/azure-load-balancer-resource-group"="[RG-NAME]" \
    --set controller.service.annotations."service\.beta\.kubernetes\.io/azure-load-balancer-tcp-idle-timeout"="30" \
    --set tcp.9900="default/tcp-server-test:9900" \
    --set podLabels.app='nginx'

As you can see, we have set the azure-load-balancer-tcp-idle-timeout to 30m, but this does not work.

The deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: tcp-server-test
  labels:
    app: tcp-server-test
spec:
  replicas: 1
  strategy:
    rollingUpdate:
      maxUnavailable: 0
  selector:
    matchLabels:
      app: tcp-server-test
  template:
    metadata:
      labels:
        app: tcp-server-test
    spec:
      containers:
      - name: tcp-server-test
        image: registry.gitlab.com/cuebly/tcptest:latest
        imagePullPolicy: Always
        env:
        - name: env
          value: "test"
      imagePullSecrets:
      - name: myregistrykey
---
apiVersion: v1
kind: Service
metadata:
  name: tcp-server-test
spec:
  type: ClusterIP
  ports:
  - name: test-port
    port: 9900
    targetPort: 9900
    protocol: TCP
  selector:
    app: tcp-server-test

What you expected to happen:

I expect the TCP connection to remain open for 30 minutes, considering the annotations.

NGINX Ingress controller version (exec into the pod and run nginx-ingress-controller --version.): 4.2.3

Kubernetes version (use kubectl version): 1.22.6

Environment:

  • Cloud provider or hardware configuration: Azure K8S

  • OS (e.g. from /etc/os-release): Ubuntu 18.04.1 LTS

  • Kernel (e.g. uname -a): Linux device-gateway-7cdc889bcf-lwc9j 5.4.0-1073-azure #76~18.04.1-Ubuntu SMP Thu Mar 10 11:17:35 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

  • Install tools:

    • We used the deployment yaml like above
  • Basic cluster related info:

    • kubectl version: Client Version: version.Info{Major:“1”, Minor:“23”, GitVersion:“v1.23.1”, GitCommit:“86ec240af8cbd1b60bcc4c03c20da9b98005b92e”, GitTreeState:“clean”, Buil dDate:“2021-12-16T11:41:01Z”, GoVersion:“go1.17.5”, Compiler:“gc”, Platform:“linux/amd64”} Server Version: version.Info{Major:“1”, Minor:“22”, GitVersion:“v1.22.6”, GitCommit:“ece9ecf2f9aecbd86d3eba31f0be62e4b6353a5a”, GitTreeState:“clean”, Buil dDate:“2022-07-28T23:33:17Z”, GoVersion:“go1.16.12”, Compiler:“gc”, Platform:“linux/amd64”}

    • kubectl get nodes -o wide: aks-agentpool-27422430-vmss00000d Ready agent 60d v1.22.6 10.240.0.4 <none> Ubuntu 18.04.6 LTS 5.4.0-1073-azure containerd://1.5.11+azure- 1 aks-agentpool-27422430-vmss00000e Ready agent 60d v1.22.6 10.240.0.5 <none> Ubuntu 18.04.6 LTS 5.4.0-1073-azure containerd://1.5.11+azure- 1

  • How was the ingress-nginx-controller installed:

    • helm ls -A | grep -i ingress: nginx-ingress default 1 2022-04-14 13:52:21.131050271 +0000 UTC deployed ingress-nginx-4.0.19 1.1.3
  • Current State of the controller:

I believe this is not applicable

  • Current state of ingress object, if applicable:

I believe this is not applicable

  • Others:

I believe this is not applicable

How to reproduce this issue:

  • Create a new resource group
  • Create a new cluster in the RG
  • Create a new public IP in the RG
  • Create the nginx-ingress controller with the public IP in the RG
  • Deploy the TCP server in the K8S cluster
  • Fill out the .env file in the TCP client
  • Run the TCP client locally
  • Wait 600s and see that the connection will disconnect

Anything else we need to know:

The Azure support engineer wishes to arrange a meeting with him, me and one of the kubernetes/ingress-nginx team for him to understand the issue and be able to deliver better support in the future. Please let me know if this is possible.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 31 (20 by maintainers)

Most upvoted comments

@hanselsen its been a long time so I will close the issue for now. In case there are updates with recent releases of the controller, and new information, please feel free to re-open the issue.

/close