-
Notifications
You must be signed in to change notification settings - Fork 611
Vap for updates #4165
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
base: main
Are you sure you want to change the base?
Vap for updates #4165
Conversation
|
Hi @chris-kaiser-7. 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 Once the patch is verified, the new status will be reflected by the 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-sigs/prow repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of very minor nits -- thanks very much for digging into this!
| api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/3328 | ||
| gateway.networking.k8s.io/bundle-version: v1.4.0 | ||
| gateway.networking.k8s.io/channel: standard | ||
| name: "gateway-api-safe-upgrades.gateway.networking.k8s.io" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Should we drop the domain here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You think it should be named "safe-upgrades.gateway.networking.k8s.io"? Yea it is a little redundant to have gateway api twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You think it should be named "safe-upgrades.gateway.networking.k8s.io"? Yea it is a little redundant to have gateway api twice.
Yep, I think that would be a nice simplification here
config/crd/standard/gateway.networking.k8s.io_safeUpgradesVAP.yaml
Outdated
Show resolved
Hide resolved
|
/approve Looks good to me with a couple of minor comments, leaving the final LGTM for someone else -- thanks, @chris-kaiser-7! 🙂 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: chris-kaiser-7, kflynn 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 |
|
/ok-to-test |
…yaml Co-authored-by: Flynn <[email protected]>
| operations: ["CREATE", "UPDATE"] | ||
| resources: ["*"] | ||
| validations: | ||
| - expression: "object.spec.group != 'gateway.networking.k8s.io' || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't block XListenerSet, XMesh, etc. Is that intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No its not. I'll fix that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @chris-kaiser-7, this is a really great change! Any chance that you could include some basic tests for this VAP?
I'm thinking that we'd want them to validate the following behavior when the VAP is installed:
- Experimental CRDs that are part of x-k8s.io can be installed
- Experimental CRDs that are part of k8s.io can NOT be installed
- Standard CRDs with an old version can NOT be installed
- Standard CRDs with the current version can be installed
It might actually be possible in https://github.com/kubernetes-sigs/gateway-api/blob/150554d3a55b731d3261525cf265bc930d2d5d85/pkg/test/crd/crd_test.go, but I'll defer to @rikatz on the best home for this.
config/crd/standard/gateway.networking.k8s.io_safeUpgradesVAP.yaml
Outdated
Show resolved
Hide resolved
config/crd/standard/gateway.networking.k8s.io_safeUpgradesVAP.yaml
Outdated
Show resolved
Hide resolved
config/crd/standard/gateway.networking.k8s.io_safeUpgradesVAP.yaml
Outdated
Show resolved
Hide resolved
| message: "Installing experimental CRDs on top of standard channel CRDs is prohibited by default. Uninstall ValidatingAdmissionPolicy gateway-api-safe-upgrades.gateway.networking.k8s.io to install experimental CRDs on top of standard channel CRDs." | ||
| reason: Invalid | ||
| - expression: "(object.spec.group != 'gateway.networking.k8s.io' && object.spec.group != 'gateway.networking.x-k8s.io') || | ||
| (!matches(object.metadata.annotations['gateway.networking.k8s.io/bundle-version'], 'v1.[0-3].\\\\d+') && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind adding a note to RELEASE.md to include a step to update this value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yea good idea. The logic is a bit weird because CEL doesn't allow match groups in regex as far as I can tell so the regex gets a bit long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a note in RELEASE.md. I was thinking I could add a script in hack to update this regex based on the bundle version. That would make the process easier.
config/crd/standard/gateway.networking.k8s.io_safeUpgradesVAP.yaml
Outdated
Show resolved
Hide resolved
| annotations: | ||
| api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/3328 | ||
| gateway.networking.k8s.io/bundle-version: v1.4.0 | ||
| gateway.networking.k8s.io/channel: standard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure if this should be part of a release channel or not. Fine for now, but may want to adjust if we make a VAP that is meant to be included with both release channels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering about this too.
config/crd/standard/gateway.networking.k8s.io_safeUpgradesVAP.yaml
Outdated
Show resolved
Hide resolved
| annotations: | ||
| api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/3328 | ||
| gateway.networking.k8s.io/bundle-version: v1.4.0 | ||
| gateway.networking.k8s.io/channel: standard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above - unsure if this is necessary
|
/cc |
Thanks for the review. I just started working on the tests. |
| matchResources: | ||
| objectSelector: {} | ||
|
|
||
| # !has(object.metadata.annotations['gateway.networking.k8s.io/channel']) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this something required or something that was on file and was left behind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I didn't notice that. I cleaned it up.
| policyName: gateway-api-safe-upgrades.gateway.networking.k8s.io | ||
| validationActions: [Deny] | ||
| matchResources: | ||
| objectSelector: {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add the object selector of CRDs here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say something like:
spec.matchResources.resourceRules.apiGroups = apiextensions.k8s.io
spec.matchResources...apiVersions=v1
spec.matchResources...resources=customresourcedefinitions
Not sure this would properly work, but if so the idea is at least to filter out this binding and not send every resource validation to our VAP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did look into this but had issues selecting crds with this. I'll look into again tho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK never mind it seems to be working as you said. I must have done something wrong before when testing resourcerRules in binding.
I pushed some tests in CRD_test. I can move them to a separate test file if that is better. I also made a few changes to that. I pulled some of the init tests up a level so you can run isolated tests like. "make test.crds-validation GO_TEST_FLAGS="-run TestCRDValidation/safeupgrades_VAP_should_validate_correctly"". |
|
I noticed a race condition and spent a while trying to fix it without time.sleep. I'm going to look at this some more but figured I should push what I got. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @chris-kaiser-7!
| @@ -0,0 +1,10611 @@ | |||
| # Copyright 2025 The Kubernetes Authors. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of including the entire release manifest from previous releases, let's just add some very lightweight manifests with a variety of annotations (different release channels, versions, etc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1! Or pick some existing manifest from https://github.com/kubernetes-sigs/gateway-api/tree/main/config/crd and mutate it accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call! I work on this.
| t.Run("should be able to set kubectl and kubeconfig and connect to the cluster", func(t *testing.T) { | ||
| kubectlLocation = testEnv.ControlPlane.KubectlPath | ||
| require.NotEmpty(t, kubectlLocation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for removing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put this logic in the parent test so that you could run targeted tests without issue. for example "make test.crds-validation GO_TEST_FLAGS="-run TestCRDValidation/safeupgrades_VAP_should_validate_correctly"". would not work as well as a few other tests because it depended on logic in this test.
| (has(object.metadata.annotations) && object.metadata.annotations.exists(k, k == 'gateway.networking.k8s.io/bundle-version') && | ||
| !matches(object.metadata.annotations['gateway.networking.k8s.io/bundle-version'], 'v1.[0-3].\\\\d+') && | ||
| !matches(object.metadata.annotations['gateway.networking.k8s.io/bundle-version'], 'v0'))" | ||
| message: "Installing CRDs with version before v1.4.0 is prohibited by default. Uninstall ValidatingAdmissionPolicy gateway-api-safe-upgrades.gateway.networking.k8s.io to install older versions." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the goal here is to block the installation of older CRDs (avoid downgrade), right?
Can we add a note/comment that on Kubernetes 1.37 we should migrate this to something like https://kubernetes.io/docs/reference/using-api/cel/#kubernetes-semver-library instead?
This way, instead of having this bump as part of the release process, we can probably extract the version directly and check if it is older than the current existing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea this is good. I didn't know this was in CEL for Kubernetes. I was just working off the base CEL documentation and that was kind of frustrating to say the least. I'll update it to this for 1.37. There is a lot of other good stuff in that doc too I didn't know about.
| kind: ValidatingAdmissionPolicyBinding | ||
| metadata: | ||
| annotations: | ||
| gateway.networking.k8s.io/bundle-version: v1.4.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this will be released with main, should we make this v1.5.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea that makes sense. I'll fix that.
|
overall lgtm, thanks. I just want to be sure that:
|
@rikatz @robscott |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This is required for the release changes https://docs.google.com/document/d/1iG6RKVJFZUxG1mZ4NbUL5Tm09n_zDck-LukYmUXoQ7c/edit?tab=t.0
Which issue(s) this PR fixes:
Fixes #
VAP for Upgrades #4162
Does this PR introduce a user-facing change?: