tuban
tuban

Reputation: 5185

How set a fixed cluster port for nodePort service in k8s

How can I set a fix cluster port for a nodePort service. I need to validate the incoming port inside the pod, hence required the same port to be forwarded to the pod when message reached inside the currently it picks a random port and node ip to send the packet into pod from the service.

Upvotes: 0

Views: 1816

Answers (1)

Burak Serdar
Burak Serdar

Reputation: 51557

You can specify a fixed port for the nodeport when you define it:

https://kubernetes.io/docs/concepts/services-networking/service/#nodeport

If you want a specific port number, you can specify a value in the nodePort field. The control plane will either allocate you that port or report that the API transaction failed. This means that you need to take care of possible port collisions yourself. You also have to use a valid port number, one that’s inside the range configured for NodePort use.

Upvotes: 2

Related Questions