How to setup Kubernetes nodeport service timeout?

7/21/2020

How to change Kubernetes NodePort service timeout?

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

-- Ananta Dwi Prasetya Purna Yuda
kubernetes
kubernetes-service

2 Answers

7/21/2020

Most of the service aspects in Kubernetes are handled by the kube-proxy 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 TCP timeouts at the Linux kernel level ⏳, but typically those have defaults that are reasonable.

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 annotations or the configmap

✌️

-- Rico
Source: StackOverflow

7/21/2020

NodePort simply exposes pod's ports on the node, health checking is not its functionality.

I guess you are looking for livenessProbe that can be defined per container. Its purpose is to check whether a container is healthy and if that is not the case, it will kill it and then restart is so that the container is returned to its original/normal state.

Example of HTTP liveness probe that checks health of a container every 5 seconds by hitting port 80 and path / of the container.

livenessProbe:
      httpGet:
          port: 80
          path: /
      periodSeconds: 5 

more configuration detail here

-- Matus Dubrava
Source: StackOverflow