Use Service port in generated Kong services #4503
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
Uses the Service port from the Ingress(like) backend for the Kong service port. Previously we used
80
as a universal default.This is a cosmetic change. As all KIC-generated services use upstreams, the service port is ignored in favor of the upstream's targets' ports, which are set to the Service's Endpoints' ports.
Which issue this PR fixes:
Fix #4470
Special notes for your reviewer:
This change still uses the
80
default when initially generating services, e.g. in the Ingress translator. Because Ingress(like) backends may use port names instead of numbers, we don't necessarily know the port number until we look up the Service.We look up Services when generating upstreams, so this moves upstream generation before service generation. I don't love updating the map values in place and returning a new copy, but we were already passing the map by value and don't use the Kong service during upstream generation (we use the attached ServicePort instead).
Moving upstream generation before the skipped services list also feels a bit weird, but apparently we were never using the skipped service list during upstream generation anyway? We were apparently generating some upstreams we weren't actually using, but this probably doesn't matter--worst case I guess you get a bunch of config bloat if you make tons of misconfigured Services, and the fix is "don't do that, it's silly".
PR Readiness Checklist:
Complete these before marking the PR as
ready to review
:CHANGELOG.md
release notes have been updated to reflect any significant (and particularly user-facing) changes introduced by this PR