-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add a proposal for generating VAPs given an exception #55
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Mariam Fahmy <[email protected]>
- expression: "'app' in object.metadata.labels" | ||
``` | ||
|
||
However, using a `namespaceSelector` will be applied for both matching and excluding deployemnts. The above VAP matches all deployments whose namespace labels set to `environment: staging`, and it also excludes all deployments named `important-tool` whose namespace labels set to `environment: staging`. It means that matching/excluding resources is done in the same namespace. There is no option to match deployments in all namespaces and exclude some in a specific namespace. |
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.
@MariamFahmy98 - isn't this the same as what this Kyverno declaration would do?
...
rules:
- name: check-deployment-labels
match:
all:
- resources:
namespaceSelector:
matchLabels:
environments: staging
exclude:
all:
- resources:
name: important-tool
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.
The corresponding VAP could be something like this:
apiVersion: admissionregistration.k8s.io/v1beta1
kind: ValidatingAdmissionPolicy
metadata:
name: "check-deployment-labels"
spec:
failurePolicy: Fail
matchConstraints:
excludeResourceRules:
- apiGroups: ['*']
apiVersions: ['*']
resources: ['*']
resourceNames: ["important-tool"]
namespaceSelector:
matchLabels:
environment: staging
validations:
- expression: "'app' in object.metadata.labels"
But I need to double-check if this is correct.
|
||
- An exception that matches resources based on annotations, subjects, roles, or clusterRoles cannot be converted to VAPs. | ||
|
||
In conclusion, exceptions provide the flexibility to exclude resources that VAPs lack, making it impossible to generate a VAP from an exception. As a result, if an exception is created for a Kyverno policy that uses `validate.cel` subrule, the Kyverno engine will handle the resource validation itself instead of generating the corresponding VAPs. |
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.
Can we allow use of some subset of exceptions?
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.
For the following cases, I think a VAP can be generated:
- Matching all resources and excluding a specific one.
- Matching and excluding in the same namespace.
However, there are a lot of limitations and I don't know if it is worth considering this feature.
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.
Can we clarify the limitations and propose changes to ValidatingAdmissionPolicy resources?
This PR includes the latest investigation report on the generation of VAP in case of a policy exception.