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

Kube Gateway Policy Validation #9456

Merged
merged 54 commits into from May 16, 2024
Merged

Kube Gateway Policy Validation #9456

merged 54 commits into from May 16, 2024

Conversation

lgadban
Copy link
Contributor

@lgadban lgadban commented May 7, 2024

Description

Implements webhook validation for Gloo Gateway Policies in the context of Kubernetes Gateway API.
RouteOption and VirtualHostOption CRs will be hermetically validated to prevent admission for semantically incorrect resources. Referential errors (i.e. "warnings" in the Gloo Edge API) will not be checked.

Context

Validation is implemented in the existing webhook but does NOT do a full translation like the original Gloo Edge API validation. There are many challenges associated with performing a full translation (see design doc for more analysis).
This approach gives us semantic validation/rejection via a. webhook without needing a snapshot-based full translation.

Testing steps

Manually verified with resources such as:

apiVersion: gateway.solo.io/v1
kind: RouteOption
metadata:
  name: policy-attached
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: example-route
  options:
    faults:
      abort:
        percentage: 100
        # httpStatus: 500 <-- commented out to break plugin, this causes error
Error from server: error when creating "projects/gateway2/examples/example-http-route-with-attached-options.yaml": admission webhook "gloo.gloo-system.svc" denied the request: resource incompatible with current Gloo snapshot: [Validating *v1.RouteOption failed: 1 error occurred:
	* Validating *v1.RouteOption failed: validating *v1.RouteOption name:"policy-attached" namespace:"default": 1 error occurred:
	* Route Error: ProcessingError. Reason: *faultinjection.plugin: invalid abort status code '0', must be in range of [200,600). Route Name:
apiVersion: gateway.solo.io/v1
kind: VirtualHostOption
metadata:
  name: policy-attached
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: Gateway
    name: gw
  options:
    bufferPerRoute:
      buffer: {}
Error from server: error when creating "projects/gateway2/examples/example-http-route-with-attached-vhost-options.yaml": admission webhook "gloo.gloo-system.svc" denied the request: resource incompatible with current Gloo snapshot: [Validating *v1.VirtualHostOption failed: 1 error occurred:
	* Validating *v1.VirtualHostOption failed: validating *v1.VirtualHostOption name:"policy-attached" namespace:"default": 1 error occurred:
	* VirtualHost Error: ProcessingError. Reason: invalid virtual host [vhost]: invalid BufferPerRoute.Buffer: embedded message failed validation | caused by: invalid Buffer.MaxRequestBytes: value is required and must not be nil.

Still exploring how we can test this in the new e2e testing framework

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

BOT NOTES:
resolves https://github.com/solo-io/solo-projects/issues/6063

@github-actions github-actions bot added the keep pr updated signals bulldozer to keep pr up to date with base branch label May 7, 2024
@solo-changelog-bot
Copy link

Issues linked to changelog:
https://github.com/solo-io/solo-projects/issues/6063

@lgadban lgadban changed the title Ggv2 validation Kube Gateway Policy Validation May 7, 2024
@lgadban lgadban marked this pull request as ready for review May 7, 2024 20:04
@lgadban lgadban requested a review from a team as a code owner May 7, 2024 20:04
Copy link

github-actions bot commented May 7, 2024

Visit the preview URL for this PR (updated for commit 79f32a6):

https://gloo-edge--pr9456-ggv2-validation-9fqddthj.web.app

(expires Thu, 23 May 2024 17:29:06 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 77c2b86e287749579b7ff9cadb81e099042ef677

Copy link
Contributor

@sam-heilbron sam-heilbron left a comment

Choose a reason for hiding this comment

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

Looking great! I like the direction, accepting it as a viable solution in the short-term

@npolshakova npolshakova mentioned this pull request May 10, 2024
2 tasks
Copy link
Contributor

@sam-heilbron sam-heilbron left a comment

Choose a reason for hiding this comment

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

LGTM!

@sam-heilbron
Copy link
Contributor

Per standup, @jbohanon @npolshakova @sam-heilbron are happy to have this merge as is.

Sam is going to resolve the comments to allow the PR to merge

@npolshakova
Copy link
Contributor

/kick build-bot

@soloio-bulldozer soloio-bulldozer bot merged commit fd331e5 into main May 16, 2024
25 checks passed
@soloio-bulldozer soloio-bulldozer bot deleted the ggv2-validation branch May 16, 2024 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep pr updated signals bulldozer to keep pr up to date with base branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants