Skip to content

Conversation

@ronething
Copy link
Contributor

@ronething ronething commented Sep 22, 2025

Type of change:

  • Bugfix
  • New feature provided
  • Improve performance
  • Backport patches
  • Documentation
  • Refactor
  • Chore
  • CI/CD or Tests

What this PR does / why we need it:

A warning is issued when the GatewayProxy resource referenced by Gateway or IngressClass does not exist

Because ValidatingWebhookConfiguration is a cluster resource, running test cases concurrently may lead to other test cases failing (for example, accessing a non-existent webhook server causing errors), so the test cases related to the webhook are tested separately.

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

Signed-off-by: Ashing Zheng <[email protected]>
Signed-off-by: Ashing Zheng <[email protected]>
Signed-off-by: Ashing Zheng <[email protected]>
Signed-off-by: Ashing Zheng <[email protected]>
@ronething ronething marked this pull request as ready for review September 23, 2025 07:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds webhook validation for IngressClass and Gateway resources to warn users when referenced GatewayProxy resources do not exist, improving user experience by providing early feedback on configuration issues.

  • Implements admission webhooks for IngressClass and Gateway resources that validate GatewayProxy references
  • Adds comprehensive end-to-end tests to verify webhook functionality
  • Updates webhook configuration manifests to register the new validation endpoints

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/webhook/v1/ingressclass_webhook.go Implements IngressClass admission webhook with GatewayProxy reference validation
internal/webhook/v1/gateway_webhook.go Implements Gateway admission webhook with GatewayProxy reference validation
internal/manager/webhooks.go Registers the new webhooks with the manager
test/e2e/ingress/ingressclass_webhook.go End-to-end tests for IngressClass webhook validation
test/e2e/gatewayapi/webhook.go End-to-end tests for Gateway webhook validation
test/e2e/framework/manifests/webhook.yaml Test webhook configuration for e2e tests
config/webhook/manifests.yaml Production webhook configuration manifest
PROJECT Kubebuilder project configuration updates

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type Gateway.
func (v *GatewayCustomValidator) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
gateway, ok := obj.(*gatewaynetworkingk8siov1.Gateway)
Copy link
Contributor

@AlinsRan AlinsRan Sep 23, 2025

Choose a reason for hiding this comment

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

Perhaps we only need to issue warnings for the resources managed by this ingress.
What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. I'll handle it later

Signed-off-by: Ashing Zheng <[email protected]>
@ronething ronething requested a review from AlinsRan September 23, 2025 09:39
Signed-off-by: Ashing Zheng <[email protected]>
Signed-off-by: Ashing Zheng <[email protected]>
@ronething ronething requested a review from bzp2010 September 24, 2025 02:38
)

var _ = Describe("Test Ingress Webhook", Label("networking.k8s.io", "ingress"), func() {
var _ = Describe("Test Ingress Webhook", Label("webhook"), func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about creating a separate directory for webhooks?
There are different resources inside.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I think we can handle this matter separately, in the future PR.

@ronething ronething merged commit 3b3bb2c into master Sep 24, 2025
35 of 41 checks passed
@ronething ronething deleted the feat/gateway_ingressclass_webhook branch September 24, 2025 07:34
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.

3 participants