-
Notifications
You must be signed in to change notification settings - Fork 54
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 policy-controller annotations #732
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Andrés Torres <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #732 +/- ##
==========================================
+ Coverage 55.37% 55.94% +0.57%
==========================================
Files 45 45
Lines 4791 5069 +278
==========================================
+ Hits 2653 2836 +183
- Misses 1934 2018 +84
- Partials 204 215 +11 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Andrés Torres <[email protected]>
Signed-off-by: Andrés Torres <[email protected]>
Signed-off-by: Andrés Torres <[email protected]>
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.
We need to add a new github action worklflow to test this functionality on a running cluster similar to what we did with kind-cluster-image-policy-tsa.yaml or kind-cluster-image-policy-no-tuf.
ImagePullSecrets: imagePullSecrets, | ||
} | ||
|
||
v.annotatePodSpec(ctx, ns, p.Kind, p.APIVersion, &p.ObjectMeta, &p.Spec, opt) |
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.
We could get from the context whether annotate-results- configuration is enabled or not.
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.
Sorry, I am not sure what you are referring to. I make the check from the context in one place in line 1206.
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! This comment was related to this other one #732 (comment). I believe we could simply get from the context whether our system had enabled the annotations on resources or not.That'd reduce the amount of code for this feature while keeping the behaviour configurable.
@elfotografo007 Let me know if you have any questions or need help. |
Signed-off-by: Andrés Torres <[email protected]>
Signed-off-by: Andrés Torres <[email protected]>
Signed-off-by: Andrés Torres <[email protected]>
Signed-off-by: Andrés Torres <[email protected]>
Signed-off-by: Andrés Torres <[email protected]>
Signed-off-by: Andrés Torres <[email protected]>
@hectorj2f Can you re-run the tests? I believe they failed due to a GH outage. |
@elfotografo007 Done |
Signed-off-by: Andrés Torres <[email protected]>
Thanks, @hectorj2f Everything is passing now 😃 |
Just to make sure I understand, does this mean that we run through the policy evaluations twice if the annotations are enabled? Once during defaulting (and that's when the annotation gets applied), and again once all the defaultings are done and the actual admission check happens we run through the same evaluations again? |
You are totally right, everything you are mentioning is what is happening. Is there a way to evaluate and create annotations at the same time? |
I don't believe so in a sense that you want to do the admission / create annotations at the same time. I thought there was a way to return more information along the admission webhook response. It really depends on what behaviour we want to provide. One option that I was thinking was using the 'AuditAnnotations' from here: |
Looking forward to this feature 🤞🏻 |
@elfotografo007 Do you have any update about this one ? Are you still working on these changes ? :) |
@elfotografo007 @hectorj2f Did someone look at this part of the admission controller documentation? Where you could do a JSON Patch to an admitted object. I really need this feature so I tried looking in the code where a response is returned but didn't manage to understand. Basically Base64 encoding this
|
@ElementTech no, we didn't. How do you want to use it? |
Summary
Add annotations to a resource with the validation results.
Closes #611
Example Output
Given the following policy, and enabling the policy-controller in the namespace
my-secure-namespace
:Creating a pod with
kubectl run cosign --image=gcr.io/projectsigstore/cosign:v1.2.1 --dry-run=server -n my-secure-namespace -o yaml
will generate the following annotation:The annotations are in JSON format.
Release Note
Added annotations to validated resources.
Documentation
Docs PR