<p>How to change Kubernetes NodePort service timeout?</p>
<p>I have tested it by running infinite loop php code using apache2 webserver but after 3 minutes it ended up with 504 gateway timeout from nginx. I can guess that it handled by NodePort service Kubernetes</p>

<p>Most of the service aspects in Kubernetes are handled by the <a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kube-proxy/" rel="nofollow noreferrer"><code>kube-proxy</code></a> and/or regular iptables, so there is not a TCP connection timeout per se. If you are looking at lower-level primitives you could look at <a href="https://unix.stackexchange.com/a/136921/54556">TCP timeouts</a> at the Linux kernel level ⏳, but typically those have defaults that are reasonable.</p>
<p>You provided very few details on your question 🤷 but assuming you are using an Nginx ingress controller, you can weather the services/pods that actually service traffic are actually up and receiving traffic at the specific moment that you are getting those timeouts.  You can also tweak the timeouts ⏳ at the Nginx ingress controller level using <a href="https://unix.stackexchange.com/a/136921/54556">annotations</a> or the <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#configuration-options" rel="nofollow noreferrer">configmap</a></p>
<p>✌️</p>
