Skip to content
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

Make the SPO webhooks opt-in #1207

Merged
merged 3 commits into from
Oct 14, 2022
Merged

Conversation

jhrozek
Copy link
Contributor

@jhrozek jhrozek commented Oct 6, 2022

This is a work-in-progress. I want to get early feedback before I fix up tests
and adds docs etc. Feedback is appreciated!

As a fallback if others are not happy with this change, I can always just change
the OCP default namespace selector, since that's the distro I care about the most,
but I think for stability reasons, this change might be beneficial for upstream
as a whole.

What type of PR is this?

/kind feature

What this PR does / why we need it:

The SPO webhooks have been cluster-wide by default. This is great for
functionality as both recording and binding just works, but might be
dangerous - if there is a bug in the webhook or the webhook is not
replying, then all namespaces might be affected.

This patch switches the default to opt-in, meaning that only namespaces
labeled with spo.x-k8s.io/enable-binding or
spo.x-k8s.io/enable-recording would be listened on.

Which issue(s) this PR fixes:

None

Does this PR have test?

Not yet (it's a WIP)

Special notes for your reviewer:

N/A

Does this PR introduce a user-facing change?

SPO changed the way the webhooks are enabled from listening on all namespaces by default
to explicitly listening for activity on namespaces labeled with spo.x-k8s.io/enable-binding
and spo.x-k8s.io/enable-recording respectively.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 6, 2022
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 6, 2022
@jhrozek jhrozek changed the title WIP: Make the SPO webhooks opt-in Make the SPO webhooks opt-in Oct 11, 2022
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 11, 2022
@jhrozek
Copy link
Contributor Author

jhrozek commented Oct 11, 2022

No longer a WIP.
Since this is a breaking change, I'd prefer a thorough review.

@ccojocar your opinion is also welcome because you worked on the static webhook configuration. Do you think the static webhooks would benefit from being opt-in, too?

@saschagrunert
Copy link
Member

/test pull-security-profiles-operator-test-e2e

Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

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

Code LGTM and I'd like to see that as part of 0.5.0. Can we add an e2e test which verifies that it does not work when the label is not set?

@ccojocar
Copy link
Contributor

@ccojocar your opinion is also welcome because you worked on the static webhook configuration. Do you think the static webhooks would benefit from being opt-in, too?

Definitely, we already made this change in our clusters to prevent availability issues when the webhook is down. We made it even on a pod level basis. The webhook listens only to pods with a certain label.

Copy link
Contributor

@ccojocar ccojocar left a comment

Choose a reason for hiding this comment

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

The implementation looks good to me. I am wondering if we should add in the docs that the object selector can be also add to the static webhook configuration. We did exactly the same change but on the static webhook manifest.

@jhrozek
Copy link
Contributor Author

jhrozek commented Oct 12, 2022

Code LGTM and I'd like to see that as part of 0.5.0. Can we add an e2e test which verifies that it does not work when the label is not set?

Will do, thank you for the review.

@jhrozek
Copy link
Contributor Author

jhrozek commented Oct 12, 2022

@ccojocar your opinion is also welcome because you worked on the static webhook configuration. Do you think the static webhooks would benefit from being opt-in, too?

Definitely, we already made this change in our clusters to prevent availability issues when the webhook is down.

I'm not sure if I'm reading your "definitely" right :-) do I understand correctly that you're saying that I should fixup the static webhook manifest by only making it listen for the labels?

We made it even on a pod level basis. The webhook listens only to pods with a certain label.

Oh nice, we should suggest that in docs as well as additional "hardening".

@ccojocar
Copy link
Contributor

I'm not sure if I'm reading your "definitely" right :-) do I understand correctly that you're saying that I should fixup the static webhook manifest by only making it listen for the labels?

yeah, that's even better than just documenting. Let's add it to the static webhook to be consistent.

@jhrozek
Copy link
Contributor Author

jhrozek commented Oct 12, 2022

I'm not sure if I'm reading your "definitely" right :-) do I understand correctly that you're saying that I should fixup the static webhook manifest by only making it listen for the labels?

yeah, that's even better than just documenting. Let's add it to the static webhook to be consistent.

I agree, will do. Thanks!

This was causing flakes in the test in case the order of the returned
webhook configuration changed.
The SPO webhooks have been cluster-wide by default. This is great for
functionality as both recording and binding just works, but might be
dangerous - if there is a bug in the webhook or the webhook is not
replying, then all namespaces might be affected.

This patch switches the default to opt-in, meaning that only namespaces
labeled with spo.x-k8s.io/enable-binding or
spo.x-k8s.io/enable-recording would be listened on.
Synchronizes the defaults for the SPO managed webhook with the static
webhook
@jhrozek
Copy link
Contributor Author

jhrozek commented Oct 13, 2022

Another iteration: I haven't amended the docs with object selector yet, but the tests are amended now. I've only had the chance to run the local fedora based tests so far, let's see how the other fare in CI.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 14, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jhrozek, saschagrunert

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [jhrozek,saschagrunert]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants