gateway-api icon indicating copy to clipboard operation
gateway-api copied to clipboard

Webhook: Validate unique port, protocol per hostname for gateway listeners.

Open gyohuangxin opened this issue 3 years ago • 3 comments

What type of PR is this?

/kind feature

What this PR does / why we need it:

  1. Add validation to validate protocol is unique per hostname for gateway listeners
  2. Add validation to validate port is unique per hostname for gateway listeners

Which issue(s) this PR fixes:

Fixes #847

Does this PR introduce a user-facing change?:

NONE

gyohuangxin avatar Oct 14 '22 05:10 gyohuangxin

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: gyohuangxin Once this PR has been reviewed and has the lgtm label, please assign hbagdi for approval by writing /assign @hbagdi in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Oct 14 '22 05:10 k8s-ci-robot

Hi @gyohuangxin. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Oct 14 '22 05:10 k8s-ci-robot

@robscott I make it a draft PR because I have some question:

  1. As you mentioned in #847:

The validating webhook should ensure that port, protocol, and hostname are unique among Gateway listeners

but then you give an example:

"2 listeners for foo.com would be valid if they were on different ports or protocols, but not if port and protocol were also identical."

They are a bit inconsistent, but my understanding is the webhook should separately validate unique port, protocol per hostname for gateway listeners. Is it correct? Is it needed to verify unique port, protocol across hostnames? Is it needed to verify unique hostname per listener?

  1. I add validations in v1beta1 apis, should I add them in v1alpha1 apis too?

gyohuangxin avatar Oct 14 '22 05:10 gyohuangxin

@gyohuangxin: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Oct 20 '22 01:10 k8s-ci-robot

@gyohuangxin where are we at with this one? Is there anything we can do to help the progression here? Looks like maybe we're still waiting on some feedback requested from @robscott?

shaneutt avatar Jan 31 '23 14:01 shaneutt

Yes, it's on hold because I'm still confused with the first question, I'm not sure my thought is close to the reality.

@robscott I make it a draft PR because I have some question:

  1. As you mentioned in Webhook: Validate unique port, protocol, and hostname per listener #847:

The validating webhook should ensure that port, protocol, and hostname are unique among Gateway listeners

but then you give an example:

"2 listeners for foo.com would be valid if they were on different ports or protocols, but not if port and protocol were also identical."

They are a bit inconsistent, but my understanding is the webhook should separately validate unique port, protocol per hostname for gateway listeners. Is it correct? Is it needed to verify unique port, protocol across hostnames? Is it needed to verify unique hostname per listener?

gyohuangxin avatar Jan 31 '23 15:01 gyohuangxin

Thanks for the work on this @gyohuangxin! Sorry I lost track of this, don't hesitate to ping me if I can help explain anything better.

robscott avatar Mar 23 '23 22:03 robscott

@robscott @shaneutt Can you review this PR? Thanks

gyohuangxin avatar Apr 01 '23 18:04 gyohuangxin

Thanks @gyohuangxin ! This Looks good to me. We probably want to change the PR description to match the new logic - ensuring Listener's port-protocol-hostname combinations are unique within an individual Gateway.

over to @robscott for a final review and approval.

LiorLieberman avatar Apr 04 '23 08:04 LiorLieberman

Thanks @gyohuangxin ! This Looks good to me. We probably want to change the PR description to match the new logic - ensuring Listener's port-protocol-hostname combinations are unique within an individual Gateway.

over to @robscott for a final review and approval.

Sorry for missing the PR description, updated. Thanks for reminding 💯

gyohuangxin avatar Apr 04 '23 08:04 gyohuangxin

Based on this comment it seems like we should take into consideration the tls properties attached to a listener when determing uniqueness

https://github.com/kubernetes-sigs/gateway-api/issues/1842#issuecomment-1484615419

dprotaso avatar Apr 04 '23 19:04 dprotaso

Thanks for your comments @dprotaso . As said in @robscott 's https://github.com/kubernetes-sigs/gateway-api/issues/1842#issuecomment-1496560365, the "Hostname" can be different for shared Port and Protocol, like the TLS example on the website: https://gateway-api.sigs.k8s.io/guides/tls/#wildcard-tls-listeners

So, I think it can cover the use cases. Please let me know if there are some use cases that use the same combination of port, protocol and hostname but use distinct tls fields.

gyohuangxin avatar Apr 05 '23 13:04 gyohuangxin

Thanks @gyohuangxin!

/approve /ok-to-test

robscott avatar Apr 06 '23 18:04 robscott

/lgtm /approve

robscott avatar Apr 06 '23 18:04 robscott

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: arkodg, gyohuangxin, robscott

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Apr 06 '23 18:04 k8s-ci-robot