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

Auto-select selinuxd image based on nodeInfo.OSImage #1600

Merged
merged 1 commit into from
Apr 5, 2023

Conversation

jhrozek
Copy link
Contributor

@jhrozek jhrozek commented Apr 4, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

Cluster nodes might be upgraded between major OS releases where the
libselinux major version is incompatible. This means that the selinuxd
image must be based on images matching the OS release and the libselinux
major version.

But SPO must also be able to select the images based on what OS are the
cluster nodes running.

To implement that, this patch adds a new key to the
security-profiles-operator-profile configmap that maps regexes matching
nodeInfo.OSImage to selinuxd images. The operator then selects the right
selinuxd image, falling back to using the RELATED_IMAGE_SELINUXD environment
variable.

Which issue(s) this PR fixes:

Fixes #1576

Does this PR have test?

some unit tests

Special notes for your reviewer:

I'll hold this patch before I can install a RHEL-9 based cluster - I've
been having issues with that. But I wanted to get some early feedback.

Does this PR introduce a user-facing change?

SPO now autoselects the appropriate selinuxd image based on mapping in the
security-profiles-operator-profile. If none of the entries match, SPO falls back
to the image provided by `RELATED_IMAGE_SELINUXD`.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. 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. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 4, 2023
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 4, 2023
@jhrozek
Copy link
Contributor Author

jhrozek commented Apr 4, 2023

/hold
for RHEL-9 testing (the installer is having issues it seems)

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 4, 2023
Cluster nodes might be upgraded between major OS releases where the
libselinux major version is incompatible. This means that the selinuxd
image must be based on images matching the OS release and the libselinux
major version.

But SPO must also be able to select the images based on what OS are the
cluster nodes running.

To implement that, this patch adds a new key to the
security-profiles-operator-profile configmap that maps regexes matching
nodeInfo.OSImage to selinuxd images. The operator then selects the right
selinuxd image, falling back to using the RELATED_IMAGE environment
variable.
@@ -1,3 +1,3 @@
---
- path: /rules/2
- path: /rules/3
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case someone is going wtf is this change..because I changed the spo role by adding a new permission, this overlay would have removed a permission at the wrong index:

diff --git a/deploy/webhook-operator.yaml b/deploy/webhook-operator.yaml
index cad32631..ed2ae5f8 100644
--- a/deploy/webhook-operator.yaml
+++ b/deploy/webhook-operator.yaml
@@ -2171,9 +2171,9 @@ rules:
   - list
   - watch
 - apiGroups:
-  - ""
+  - admissionregistration.k8s.io
   resources:
-  - services
+  - mutatingwebhookconfigurations
   verbs:
   - create

@jhrozek
Copy link
Contributor Author

jhrozek commented Apr 5, 2023

/hold cancel
I finally got hold of a RHEL-9 cluster and the right image was selected and a smoke test passed (a SELinux policy was installed)

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 5, 2023
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 5, 2023
@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

@k8s-ci-robot k8s-ci-robot merged commit e2574b2 into kubernetes-sigs:main Apr 5, 2023
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.

Automatic selinuxd image selection
3 participants