Kubernetes NodePort service port change

1/4/2019

Can the Kubernetes NodePort service port change upon service restart or pod crash? How do you ensure that the port of NodePort service remains the same?

-- randhir singh
kubernetes

1 Answer

1/4/2019

From documentation

If you set the type field to NodePort, the Kubernetes master will allocate a port from a range specified by --service-node-port-range flag (default: 30000-32767), and each Node will proxy that port (the same port number on every Node) into your Service. That port will be reported in your Service’s .spec.ports[*].nodePort field.

Pod crash or restart will not change your NodePort. Re-creating your service will.

You can specify a custom NodePort as described in this answer, this will keep Service's NodePort the same

-- edbighead
Source: StackOverflow