-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[Enhancement]: Service definitions use named ports rather than port numbers #11393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@jcpunk Out of curiosity ... could please share where did you find this recommendation? What is the expected advantage? Thanks |
Ideally, this would prevent hard coding port mappings. In practice the kafka ports are pretty static and well known, but use of names means, if at some point you need to fiddle with the mappings simply altering the pod's listed export port is all that is required. Essentially, using the numbers means storing the numbers twice and needing to manually be sure they match up. I'll need to retrace my steps to find where I found this recommendation. I'd swear it was under https://docs.kubelinter.io/#/generated/checks but I'm not seeing it now... |
Interesting. Not sure this really matters that much when you have an operator generate Kubernetes resources. Also, in our case the names are basically meaning less for most people reading it, but so are the port numbers. Thanks for the explanation. Hopefully, all the various tools out there expect this and are ready to handle it so that there are no ugly surprises if it is done 🤔. |
Feature wise, use of port names has been stable for all the versions of kubernetes you support. portNames were added way back in the past. |
Triaged on 29.5.2025: As you mentioned in the example, the names of the ports are also mentioned in the name field of the particular port of the Service. But anyway, we can keep it opened and implement it. |
I will try to implement it in the following days |
Related problem
Current Kubernetes best practices suggest use of named ports for connecting services to containers rather than port numbers. Currently the created services use explicit port numbers when connecting to the generated containers.
Suggested solution
Use the assigned port names in the created service definitions.
Alternatives
It currently works.
Additional context
from the container:
from a service:
The text was updated successfully, but these errors were encountered: