Skip to content

feat: Add ValidatingAdmissionPolicy for managedresource#1179

Merged
nwnt merged 8 commits into
Azure:mainfrom
nwnt:nwnt/add-managed-resource-vap
Aug 25, 2025
Merged

feat: Add ValidatingAdmissionPolicy for managedresource#1179
nwnt merged 8 commits into
Azure:mainfrom
nwnt:nwnt/add-managed-resource-vap

Conversation

@nwnt

@nwnt nwnt commented Aug 21, 2025

Copy link
Copy Markdown
Contributor

Description of your changes

Jim had a discussion about this. We want to install this VAP into managed clusters via kubefleet crd install instead of onto CCP.

I have:

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

Unit tests.

Special notes for your reviewer

N/A

Signed-off-by: Nont <nont@duck.com>
Comment thread cmd/crdinstaller/utils/util.go Outdated
Comment thread cmd/crdinstaller/utils/util.go Outdated
@nwnt nwnt changed the title [feature] Add ValidatingAdmissionPolicy for managedresource [feat] Add ValidatingAdmissionPolicy for managedresource Aug 21, 2025
@nwnt nwnt changed the title [feat] Add ValidatingAdmissionPolicy for managedresource feat: Add ValidatingAdmissionPolicy for managedresource Aug 21, 2025
Comment thread cmd/crdinstaller/main.go Outdated
Comment thread cmd/crdinstaller/utils/util.go
Signed-off-by: Nont <nont@duck.com>
@nwnt
nwnt force-pushed the nwnt/add-managed-resource-vap branch from 90d3f41 to 6d2eee1 Compare August 21, 2025 16:13
Signed-off-by: Nont <nont@duck.com>
Comment thread cmd/crdinstaller/main.go
Signed-off-by: Nont <nont@duck.com>
Comment thread cmd/crdinstaller/utils/util.go
jim-minter
jim-minter previously approved these changes Aug 21, 2025

@jim-minter jim-minter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Comment thread pkg/webhook/managedresource/validatingadmissionpolicy_test.go
Comment thread pkg/webhook/managedresource/validatingadmissionpolicy.go
Comment thread cmd/crdinstaller/utils/util_test.go Outdated
Comment thread pkg/webhook/managedresource/validatingadmissionpolicy.go Outdated
Comment thread pkg/webhook/managedresource/validatingadmissionpolicy_test.go
Signed-off-by: Nont <nont@duck.com>
Comment thread pkg/webhook/managedresource/validatingadmissionpolicy.go Outdated
Comment thread pkg/webhook/managedresource/validatingadmissionpolicy_test.go
Comment thread pkg/webhook/managedresource/validatingadmissionpolicy.go
Comment thread pkg/webhook/managedresource/validatingadmissionpolicy_test.go
Signed-off-by: Nont <nont@duck.com>
Comment thread test/e2e/managed_resource_vap_test.go Outdated
Comment thread test/e2e/managed_resource_vap_test.go
Comment thread test/e2e/managed_resource_vap_test.go
Comment thread test/e2e/resources/managed-namespace.yaml Outdated
Signed-off-by: Nont <nont@duck.com>
@nwnt
nwnt force-pushed the nwnt/add-managed-resource-vap branch from 7002541 to e769fbf Compare August 21, 2025 23:29
jim-minter
jim-minter previously approved these changes Aug 21, 2025

@jim-minter jim-minter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Comment thread test/e2e/managed_resource_vap_test.go Outdated
Comment thread test/e2e/managed_resource_vap_test.go
Comment thread pkg/webhook/managedresource/validatingadmissionpolicy_test.go
Rule: admv1.Rule{
APIGroups: []string{""},
Resources: []string{"namespaces"},
APIVersions: []string{"*"},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is there any other version for namespace being used?

RuleWithOperations: admv1.RuleWithOperations{
Rule: admv1.Rule{
APIGroups: []string{"placement.kubernetes-fleet.io"},
Resources: []string{"clusterresourceplacements"},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just CRP? Why would we allow any resources managed by ARM to be touched?

Comment thread test/e2e/managed_resource_vap_test.go
Comment thread pkg/webhook/managedresource/validatingadmissionpolicy.go
Comment thread pkg/webhook/managedresource/validatingadmissionpolicy.go
Comment thread test/e2e/framework/cluster.go
Comment thread test/e2e/managed_resource_vap_test.go Outdated
Comment thread test/e2e/managed_resource_vap_test.go Outdated
Comment thread test/e2e/managed_resource_vap_test.go Outdated
Comment on lines +76 to +80
var vap admissionregistrationv1.ValidatingAdmissionPolicy
Expect(hubClient.Get(ctx, types.NamespacedName{Name: vapName}, &vap)).Should(Succeed(), "ValidatingAdmissionPolicy should be installed")

var vapBinding admissionregistrationv1.ValidatingAdmissionPolicyBinding
Expect(hubClient.Get(ctx, types.NamespacedName{Name: vapBindingName}, &vapBinding)).Should(Succeed(), "ValidatingAdmissionPolicyBinding should be installed")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BeforeAll is mostly for setups. These two are testing implementations rather than expected behavior.

Signed-off-by: Nont <nont@duck.com>
@nwnt
nwnt force-pushed the nwnt/add-managed-resource-vap branch from c1ed13d to 74eac8c Compare August 23, 2025 00:18
Comment thread test/e2e/setup_test.go
Comment thread test/e2e/managed_resource_vap_test.go
Comment thread test/e2e/managed_resource_vap_test.go
Comment thread test/e2e/managed_resource_vap_test.go
@nwnt
nwnt merged commit 4ca6ded into Azure:main Aug 25, 2025
27 of 30 checks passed
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.

4 participants