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

Enforce Pod Security Standard restricted #2021

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

collivier
Copy link
Collaborator

@collivier collivier commented May 10, 2024

Description

https://kubernetes.io/docs/tutorials/security/cluster-level-pss/

Issues:

close: #1887

How has this been tested:

  • Covered by existing integration testing
  • Added integration testing to cover
  • Verified all A/C passes
    • develop
    • master
    • tag/other branch
  • Test environment
    • Shared Packet K8s cluster
    • New Packet K8s cluster
    • Kind cluster
  • Have not tested

@kosstennbl
Copy link
Collaborator

For ease of review:

TLDR: add PodSecurity: restricted as ClusterConfiguration to cluster.yml in github actions.

This PR creates file /tmp/pss/cluster-level-pss.yaml with contents:

apiVersion: apiserver.config.k8s.io/v1
        kind: AdmissionConfiguration
        plugins:
        - name: PodSecurity
          configuration:
            apiVersion: pod-security.admission.config.k8s.io/v1
            kind: PodSecurityConfiguration
            defaults:
              enforce: "restricted"
              enforce-version: "latest"
              audit: "restricted"
              audit-version: "latest"
              warn: "restricted"
              warn-version: "latest"
            exemptions:
              usernames: []
              runtimeClasses: []
              namespaces:
                - kube-system
                - local-path-storage

Then, during "Mirror setup", "sysctls specs kind config override" and "Mirror override" steps - it modifies the creation of cluster.yml: file cluster-level-pss.yaml is mounted as extra mount and used as ClusterConfiguration.
Also, image: kindest/node:v1.29.2@sha256:51a1434a5397193442f0be2a297b488b6c919ce8a3931be0ce822606ea5ca245 lines are removed from cluster.yml, intentions for which are not very clear.

@collivier
Copy link
Collaborator Author

collivier commented May 21, 2024

Also, image: kindest/node:v1.29.2@sha256:51a1434a5397193442f0be2a297b488b6c919ce8a3931be0ce822606ea5ca245 lines are removed from cluster.yml, intentions for which are not very clear.

It was discussed in the previous PR that double (image) pinning was useless as kind is already pinned. this will be precised in a second pending commit

@kosstennbl
Copy link
Collaborator

I don't have too much experience with Kubernetes and Helm and trying to review changes like this is new for me. Sorry if some of the questions are obvious or aren't making much sense.

  1. It seems that chaos and some other tests aren't covered by this change as they have their own creation of cluster.yml. Is it intentional?
  2. It's not quite clear to me how does this change help with functest issue, it seems that functest patches to the "baseline" security level, and it patches completely different namespaces. Litmus and cnf-testsuite namespaces are created during execution of cnf-testsuite tasks, and, to me - it seems, that they won't have any PodSecurity admission controls when tested with this change.
  3. I'm not sure, but maybe we could test functionality of testsuite with restricted PodSecurity as a separate job in a pipeline, not in "spec" job? It seems that controls, that are being done with this restricted policy - are colliding with some of the testsuite tests, and even through namespaces afflicted shouldn't have recources of installed cnf, I'm still worried that some of the spec test results could be unclear or incorrect.

It was discussed in the previous PR that double (image) pinning was useless as kind is already pinned. this will be precised in a second pending commit

Couldn't find the discussion, can you link it please?

@martin-mat
Copy link
Collaborator

gh actions failing:
image

@collivier collivier force-pushed the pss branch 3 times, most recently from fce9f6c to 329e025 Compare January 7, 2025 14:51
…atform

It's not really relevant in case of platform testing and both
Cluster API and sonobuoy (it fails if namespace exists) don't
work in this particular case.

Signed-off-by: Cédric Ollivier <[email protected]>
It adds "pod-security.kubernetes.io/enforce: privileged" in:
- both cnf-testsuite and litmus namespaces created by cnf-testsuite
- all manifest files used as samples for the cnf-testsuite workflows
- the namespace created by cnf-testsuite for the helm chart deployment
- the registry manifest files

It also fixes a couple of indent issues discovered during the changes
and slightly fixes litmus deployment logic.

Signed-off-by: Cédric Ollivier <[email protected]>
It allows running observability and platform:observability
when Pod Security Standard restricted is enforced.

It also sets the namespace cnf-space and the right label in
the sample-openmetrics manifest.

Signed-off-by: Cédric Ollivier <[email protected]>
It also uses the right constant instead of cnf-testsuite directly
and unifies all samples to use namespace cnfspace.

It also fixes a spec test in shared_database, installing now
the chart in a dedicated namespace with the right labels.

Signed-off-by: Cédric Ollivier <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Cover CNF Test Suite vs Clusters where Pod Security Standard restricted is enforced
3 participants