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

[CIS] Check for PSP compatibility in target cluster #39851

Closed
MKlimuszka opened this issue Dec 9, 2022 · 9 comments
Closed

[CIS] Check for PSP compatibility in target cluster #39851

MKlimuszka opened this issue Dec 9, 2022 · 9 comments
Assignees
Labels
area/charts feature/charts-cis-benchmark kind/enhancement Issues that improve or augment existing functionality priority/0 release-note Note this issue in the milestone's release notes team/infracloud
Milestone

Comments

@MKlimuszka
Copy link
Collaborator

Parent ticket: #39366

Kubernetes 1.25 drops support for PSP, so additional checks need to be added.

Rancher team 3 is following the proposal outlined in "Kubernetes v1.25 PSP to PSA migration proposal document"

Every chart that ships with a PSP must be changed to add a new condition checking for the PSP capability in the target cluster:

Capabilities check for Helm

{{- if .Capabilities.APIVersions.Has "policy/v1beta1/PodSecurityPolicy" }}

This change allows the charts to still work with PSPs in Kubernetes versions prior to v1.25, and work in Kubernetes v1.25 or higher by skipping installation of PSPs.

Charts that need updating:

  • rancher-cis-benchmark 

If a cluster role in a chart contains PSP's along with other permissions extra work may be needed to achieve the intended behavior of that role.

@prachidamle
Copy link
Member

We dont have a CIS scan profile supported for k8s 1.25 yet in the upstream kube-bench tool https://github.com/aquasecurity/kube-bench/blob/main/docs/platforms.md#cis-kubernetes-benchmark-support

So we need to hold off supporting PSP removal and tests for k8s 1.25.

@MKlimuszka
Copy link
Collaborator Author

We do, however, need to make sure the behavior is appropriate.

@Jono-SUSE-Rancher Jono-SUSE-Rancher added the release-note Note this issue in the milestone's release notes label Dec 20, 2022
@zube zube bot removed the [zube]: Working label Dec 26, 2022
@doflamingo721
Copy link
Contributor

doflamingo721 commented Jan 2, 2023

@prachidamle @MKlimuszka Following is the behaviour seen on 1.25 clusters:

  1. RKE:
  • rke-profile-permissive-1.23: The scans are working as expected. The scan is passing with the expected behaviour.
    209547832-616d4b31-3be3-47a2-9cb3-ff7a853085b0

  • rke-profile-hardened-1.23: The scans are working as expected. There are some tests which fail mentioned in the screenshot below. The reason for their failures is because these tests run PSP related audit commands and in k8s 1.25 there isn't a PSP resource found.

Screenshot from 2022-12-29 15-00-08

  1. K3s:
  • k3s-profile-permissive-1.23: The scans are working as expected. The scan is passing with the expected behaviour.
    Screenshot from 2022-12-27 15-21-35

  • k3s-profile-hardened-1.23: The scans are working as expected. The scan is passing with the expected behaviour.
    Screenshot from 2022-12-27 16-26-48

  1. RKE2:
  • rke2-profile-permissive-1.23: The scans are working as expected. The scan is passing with the expected behaviour.
    Screenshot from 2022-12-27 15-21-58

  • rke2-profile-hardened-1.23: We were not able to verify the scan results for hardened rke2 cluster because the cluster provisioning for rke2 hardened cluster was failing consistently. For k8s 1.25, the 1.6 cis-profile was showing incorrect while cluster provisioning. Also after changing the profile to 1.23, the cluster provisioning was stuck on updating state. There is already an issue logged for this here.

cc: @mitulshah-suse

@zube zube bot removed the team/area3 label Jan 19, 2023
@vardhaman22
Copy link
Contributor

vardhaman22 commented Feb 15, 2023

tested running scan for profile rke2-profile-hardened-1.23 on rke2-hardened cluster k8s: v1.25.6+rke2r1 using cis-benchmark 4.0.0-rc1 chart.
The scan failed but all the failure cases have audit commands which try to do operation on psp so that is expected.
rke2-cis-hardened
@prachidamle @MKlimuszka
cc: @mitulshah-suse

@martyav
Copy link
Contributor

martyav commented Apr 4, 2023

@MKlimuszka I'm on the docs team, helping with the 2.7.2 release notes. If the linked PRs are merged, why is this still open? Is there more to be done?

@mitulshah-suse
Copy link

mitulshah-suse commented Apr 5, 2023

@martyav The comments above need to be documented in the release notes as expected failures for CIS scans on 1.25 clusters.
#39851 (comment)
#39851 (comment)

@prachidamle
Copy link
Member

@ronhorton can we close this as CIS chart has been tested with k8s 1.25?

@ronhorton
Copy link

Pass We've tested this thoroughly ;)
Going out with rancher 2.7.2

@martyav
Copy link
Contributor

martyav commented May 16, 2023

@ronhorton Working on release notes. Are the expected failures described above for RKE and RKE2 still valid, or can this be moved to bug fixes?

@zube zube bot removed the [zube]: Done label Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/charts feature/charts-cis-benchmark kind/enhancement Issues that improve or augment existing functionality priority/0 release-note Note this issue in the milestone's release notes team/infracloud
Projects
None yet
Development

No branches or pull requests

9 participants