forked from kyverno/kyverno
-
Notifications
You must be signed in to change notification settings - Fork 2
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
fix(reports-controller): Allow UPDATE
Operation in Resource Validation for Reports Controller
#23
Open
Bhargav-InfraCloud
wants to merge
1
commit into
infracloudio:main
Choose a base branch
from
Bhargav-InfraCloud:br_include_update_op_in_resource_validation_in_bg_ctr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bhargav-InfraCloud
changed the title
WIP: fix(reports-controller): Allow UPDATE operation in validation
WIP: fix(reports-controller): Allow Feb 1, 2024
UPDATE
Operation in Resource Validation for Reports Controller
Bhargav-InfraCloud
force-pushed
the
br_include_update_op_in_resource_validation_in_bg_ctr
branch
2 times, most recently
from
February 1, 2024 21:41
d258fa8
to
8fe2c5c
Compare
Steps to Test
make kind-create-cluster build-all kind-load-all kind-deploy-all
kubectl apply -f - <<EOF
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-network-policy-with-create
spec:
validationFailureAction: Audit
background: true
rules:
- name: check-netpol
match:
resources:
kinds:
- Namespace
operations:
- CREATE
- UPDATE
context:
- name: network_policies_count
apiCall:
urlPath: "/apis/networking.k8s.io/v1/namespaces/{{request.namespace}}/networkpolicies"
jmesPath: "items[] | length(@)"
validate:
message: "Multi-Tenancy & Isolation Checks; The namespace must have a network policy"
deny:
conditions:
any:
- key: "{{network_policies_count}}"
operator: LessThan
value: 1
EOF Without kubectl apply -f - <<EOF
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-network-policy-without-create
spec:
validationFailureAction: Audit
background: true
rules:
- name: check-netpol
match:
resources:
kinds:
- Namespace
operations:
- UPDATE
context:
- name: network_policies_count
apiCall:
urlPath: "/apis/networking.k8s.io/v1/namespaces/{{request.namespace}}/networkpolicies"
jmesPath: "items[] | length(@)"
validate:
message: "Multi-Tenancy & Isolation Checks; The namespace must have a network policy"
deny:
conditions:
any:
- key: "{{network_policies_count}}"
operator: LessThan
value: 1
EOF
kubectl get event --field-selector involvedObject.name=require-network-policy-with-create
kubectl get event --field-selector involvedObject.name=require-network-policy-without-create |
Bhargav-InfraCloud
changed the title
WIP: fix(reports-controller): Allow
fix(reports-controller): Allow Feb 2, 2024
UPDATE
Operation in Resource Validation for Reports ControllerUPDATE
Operation in Resource Validation for Reports Controller
ApsTomar
approved these changes
Feb 2, 2024
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.
LGTM
Thanks @ApsTomar |
Bhargav-InfraCloud
force-pushed
the
br_include_update_op_in_resource_validation_in_bg_ctr
branch
from
February 2, 2024 13:30
8fe2c5c
to
8d8d72b
Compare
Bhargav-InfraCloud
force-pushed
the
br_include_update_op_in_resource_validation_in_bg_ctr
branch
from
February 14, 2024 16:33
8d8d72b
to
7136e7b
Compare
Pass operations list instead of one to check for resources that match policy's condition block. Also, decouple operation list for resource validation from the policy context's operation. Fixes kyverno#9562 Signed-off-by: Bhargav Ravuri <[email protected]>
Bhargav-InfraCloud
force-pushed
the
br_include_update_op_in_resource_validation_in_bg_ctr
branch
from
March 20, 2024 14:19
7136e7b
to
1affc43
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation
Allow
UPDATE
operation in validation.Pass operations list instead of one to check for resources that match the policy's condition block.
Also, decouple the operation list for resource validation from the policy context's operation.
Related issue
9562
Milestone of this PR
NA
Documentation (optional)
NA
What type of PR is this
/kind bug
Proposed Changes
Allow
UPDATE
operation in validation.Pass operations list instead of one to check for resources that match the policy's condition block.
Also, decouple the operation list for resource validation from the policy context's operation.
Proof Manifests
Included in issue 9562
Kyverno CLI test manifest (please see docs for latest manifest format at https://kyverno.io/docs/kyverno-cli/). See kyverno/policies for complete examples of all related test files.
NA
Checklist
Further Comments
NA