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

PodSecurity Admission #6339

Closed
4 tasks done
kadel opened this issue Nov 23, 2022 · 14 comments · Fixed by #6679
Closed
4 tasks done

PodSecurity Admission #6339

kadel opened this issue Nov 23, 2022 · 14 comments · Fixed by #6679
Assignees
Labels
kind/user-story An issue of user-story kind priority/High Important issue; should be worked on before any other issues (except priority/Critical issue(s)).
Milestone

Comments

@kadel
Copy link
Member

kadel commented Nov 23, 2022

/kind user-story

User Story

As an odo user, I want to be able to run my application with standard Devfile even if the cluster that I'm using enforces security policies using PodSecurity Admission controller.

Acceptance Criteria

Details:

  • what should odo do
    • For now we will focus only on enforce policy. Other policies audit and warn should not effect the ability to run the container that doesn't meet the set policies.
    • The mechanism for checking what policies are in effect should be done by checking labels on the current namespace.
    • if there is no pod-security.kubernetes.io/enforce label
      • do nothing special
    • if pod-security.kubernetes.io/enforce is set
      • check what policy is set to be enforced
      • Pod Security Standards are hardcoded in the admission plugin. Changes to the standards are tied to the Kubernetes version that they were introduced in. Odo needs to support multiple versions of Pod Security Standards. There is a ../enforce-version label that indicates what version is being used. If not set odo should assume the latest version it knows.

https://kubernetes.io/docs/concepts/security/pod-security-admission/
https://kubernetes.io/docs/concepts/security/pod-security-standards/

/kind user-story

@openshift-ci openshift-ci bot added the kind/user-story An issue of user-story kind label Nov 23, 2022
@github-actions github-actions bot added the needs-triage Indicates an issue or PR lacks a `triage/*` and requires one. label Nov 23, 2022
@kadel kadel added the priority/Medium Nice to have issue. Getting it done before priority changes would be great. label Nov 29, 2022
@kadel kadel changed the title PodSecurity Admission [TODO] PodSecurity Admission Nov 29, 2022
@kadel kadel added priority/High Important issue; should be worked on before any other issues (except priority/Critical issue(s)). and removed priority/Medium Nice to have issue. Getting it done before priority changes would be great. labels Jan 12, 2023
@rm3l
Copy link
Member

rm3l commented Jan 19, 2023

Grooming (2023-01-19)

  • Check if there is some library
    • Might be good to add this in the Devfile library (later)
  • The point here (automatic way) is to have a Pod which is guaranteed to be created
    • Enable this behavior via a flag (only when requested)

=> TODO for Sprint 231 (3 days): More research with concrete examples

@feloy
Copy link
Contributor

feloy commented Jan 26, 2023

On IBM Cloud, PodSecurity feature gate is active on Kubernetes clusters >= 1.25 (ref: https://cloud.ibm.com/docs/containers?topic=containers-service-settings#feature-gates)

@kadel
Copy link
Member Author

kadel commented Jan 26, 2023

On IBM Cloud, PodSecurity feature gate is active on Kubernetes clusters >= 1.25 (ref: https://cloud.ibm.com/docs/containers?topic=containers-service-settings#feature-gates)

Do you know if anything is set to enforce by default?

@feloy
Copy link
Contributor

feloy commented Jan 26, 2023

Do we want to mutate the Pod before or after pod/container-overrides?

for example, if the user sets securityContext.privileged=true using container-override, do we want to set it back to undefined or false?

@feloy
Copy link
Contributor

feloy commented Jan 27, 2023

The use of k8s.io/pod-security-admission library (https://github.com/kubernetes/pod-security-admission) can help to detect which policies are not respected by a Pod for a given namespace.

PoC: https://github.com/feloy/podsecurity-admission-test

@feloy
Copy link
Contributor

feloy commented Jan 27, 2023

On IBM Cloud, PodSecurity feature gate is active on Kubernetes clusters >= 1.25 (ref: https://cloud.ibm.com/docs/containers?topic=containers-service-settings#feature-gates)

Do you know if anything is set to enforce by default?

On IBM Cloud:

  • On Kubernetes v1.25, no annotations are added to namespaces.
  • On OpenShift v4.11 (based on Kubernetes v1.24), these annotations are automatically added by default:
    pod-security.kubernetes.io/audit: restricted
    pod-security.kubernetes.io/audit-version: v1.24
    pod-security.kubernetes.io/warn: restricted
    pod-security.kubernetes.io/warn-version: v1.24
    

So, no enforce added by default in any cluster

@kadel
Copy link
Member Author

kadel commented Jan 27, 2023

Do we want to mutate the Pod before or after pod/container-overrides?

for example, if the user sets securityContext.privileged=true using container-override, do we want to set it back to undefined or false?

before, users should have the ability to override it in devfile.

@kadel
Copy link
Member Author

kadel commented Feb 10, 2023

valaparthvi moved this from In Progress 🚧 to Done ✅ in odo Project last week

@valaparthvi Why was this moved to done?

@valaparthvi
Copy link
Contributor

IIRC, the work on the issue for that particular sprint was done, so it was marked as Done. We should be able to set it back to To Do once we move it to a new sprint.

@feloy feloy removed their assignment Feb 13, 2023
@rm3l rm3l modified the milestones: v3.7.0 🚀, v3.8.0 🚀 Feb 15, 2023
@feloy
Copy link
Contributor

feloy commented Feb 15, 2023

As discussed during the devfile cabal, this feature can be implemented in the devfile library, passing the policy we want to enforce when calling ParseDevfileAndValidate

@feloy feloy self-assigned this Feb 15, 2023
@feloy
Copy link
Contributor

feloy commented Feb 16, 2023

I realize that it won't be easy to patch the pod for security admission before container-overrides, without changing the way the container-overrides are handled for the moment.

As a matter of fact, the containers are overridden when generator.GetContainers() is called, then pod is overriden when generator.GetDeployment() is called.

Pod Security Admission rules are defined for pods, not at the container level, and so they don't really make sense at the time of calling generator.GetContainers()

@feloy feloy added the sprint demo Indicates an issue for which a demo should be recorded and presented at the end of the sprint. label Feb 16, 2023
@rm3l rm3l removed the needs-triage Indicates an issue or PR lacks a `triage/*` and requires one. label Mar 1, 2023
@rm3l rm3l modified the milestones: v3.8.0 🚀, v3.9.0 🚀 Mar 7, 2023
@rm3l rm3l added status/blocked Denotes an issue or PR that is blocked on something (e.g., issue/PR in different repo) and removed sprint demo Indicates an issue for which a demo should be recorded and presented at the end of the sprint. labels Mar 23, 2023
@rm3l
Copy link
Member

rm3l commented Mar 23, 2023

/status blocked

Marking this as waiting for devfile/library#167

@rm3l rm3l removed the status/blocked Denotes an issue or PR that is blocked on something (e.g., issue/PR in different repo) label Mar 24, 2023
@feloy feloy reopened this Mar 28, 2023
@github-actions github-actions bot added the needs-triage Indicates an issue or PR lacks a `triage/*` and requires one. label Mar 28, 2023
@rm3l rm3l removed the needs-triage Indicates an issue or PR lacks a `triage/*` and requires one. label Mar 30, 2023
@rm3l
Copy link
Member

rm3l commented Mar 30, 2023

Closing this issue as implemented by #6679.

The new issue added will be handled separately in #6699

/close

@openshift-ci
Copy link

openshift-ci bot commented Mar 30, 2023

@rm3l: Closing this issue.

In response to this:

Closing this issue as implemented by #6679

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot closed this as completed Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/user-story An issue of user-story kind priority/High Important issue; should be worked on before any other issues (except priority/Critical issue(s)).
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants