Skip to content
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

Fix upstream/service collisions for multi-port Kubernetes Services #404

Merged
merged 3 commits into from
Oct 17, 2019

Conversation

rainest
Copy link
Contributor

@rainest rainest commented Sep 17, 2019

What this PR does / why we need it:
Adds port to Kong service hostnames, in turn adding the port to the associated upstream name.

This prevents collisions and/or misdirected traffic when a Kubernetes Service exposes multiple ports, and Ingress rules use two or more of those ports. Previously, rules for different ports on the same Service would attempt to use the same Kong service/upstream hostname.

Which issue this PR fixes
Fixes #335

Special notes for your reviewer:
Tests cover Kong service generation only. I reviewed whether it would be useful to separately test Parser.getUpstreams() for this, but determined it unnecessary--we do not pass Kubernetes Services to it directly, but rather generate Kong services first and then get upstreams for each Kong service.

@rainest rainest requested a review from hbagdi September 17, 2019 17:50
@CLAassistant
Copy link

CLAassistant commented Sep 17, 2019

CLA assistant check
All committers have signed the CLA.

Travis Raines added 2 commits September 17, 2019 10:51
Include the port in upstream names, such that the format is
serviceName.namespace.port.svc, e.g. fooserv.default.80.svc. This
correctly handles cases where a service exposes multiple ports, whereas
previously both would attempt the same upstream and conflict.

Fix #335
Update tests to check that service hosts include their port.

Add test to confirm that a rule using multiple ports on the same
Kubernetes Service results in multiple Kong services with different
ports.
@rainest rainest force-pushed the fix/upstream-name-collision branch from a49c917 to 2ee7152 Compare September 17, 2019 17:53
@gmlp
Copy link

gmlp commented Sep 19, 2019

Hi @rainest,
Thanks for this PR. I'm facing the same issue. I would be great if we support another scenario. The problem I had is that I'm working with a headless service and the routing is done using headers.

Regards,
Gonzalo

Copy link
Member

@hbagdi hbagdi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @rainest!

@hbagdi hbagdi merged commit c5f79e6 into master Oct 17, 2019
@hbagdi hbagdi deleted the fix/upstream-name-collision branch October 17, 2019 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kong ingress controller need support for multiple ports per service
4 participants