I have different Kubernetes namespaces... Like, 10... I do use dynamically assign pod ports for some of my pods. They are not "visible" by the user and only speaks to each other... Which is ok... Node vs Target... I get that...
However, for some of our pods, I want to manually assign a Node/Target port to make some of them accessible publicly, but I am afraid I will have some "collision" with the one already assigned by Kubernetes that I am not aware of...
My question: Is there a way to tell Kubernetes to use the entire 30000-32667 port range but keep a part of it for my "static" usage and the other part for the dynamic range ? Ans how to do that obviously.
I don't think there is a way to reserve a port range. The docs clearly state:
But if you check your currently used ports with
kubectl describe services
and then choose ports for your new manual NodePort services that are not in use you should be fine. Kubernetes will not try to assign the same Ports again.In the long term you probably want to either control all the service Ports manually or all dynamically. In the latter case you can achieve some more flexibility with using Load Balancers that forward to your service from a fixed port that you define.