Skip to content

added PodSecurityContext #2174

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

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

Conversation

Sanket-0510
Copy link
Contributor

Changes

Schema for PodSecurityContext so that users can define fields like fsGroup

/kind Enhancement

Fixes #2108

Copy link

knative-prow bot commented Feb 20, 2024

Hi @Sanket-0510. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@knative-prow knative-prow bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 20, 2024
@matejvasek matejvasek requested review from a team and lkingland and removed request for maximilien and jrangelramos February 21, 2024 02:08
@lkingland
Copy link
Member

I am grateful for this contribution.
Could we please run gofmt on the files? there's a few formatting problems that are causing our linters to complain.

Copy link
Contributor

This Pull Request is stale because it has been open for 90 days with
no activity. It will automatically close after 30 more days of
inactivity. Reopen with /reopen. Mark as fresh by adding the
comment /remove-lifecycle stale.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 29, 2024
@github-actions github-actions bot closed this Jul 29, 2024
@lkingland
Copy link
Member

This PR is in the right ballpark. Can we get the code formatted with gofmt and then we can have a discussion about the implementation itself?

@lkingland lkingland reopened this Feb 28, 2025
Copy link

knative-prow bot commented Feb 28, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Sanket-0510
Once this PR has been reviewed and has the lgtm label, please assign dprotaso for approval. For more information see the Code Review Process.

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

Needs approval from an approver in each of these files:

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

@lkingland lkingland removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 28, 2025
@Sanket-0510
Copy link
Contributor Author

Hey @lkingland I will do the needed and we can discuss it further

Copy link

linux-foundation-easycla bot commented Apr 29, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@Sanket-0510
Copy link
Contributor Author

hey sorry for the delay in response but I have formatted the code and pushed the changes

Copy link
Member

@lkingland lkingland left a comment

Choose a reason for hiding this comment

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

Thanks for coming back to help finish.

For the Unit tests to pass, I think all that needs to be done here is to remove the extraneous whitespace, and run $ make to get a regenerated schema yaml.

However, I looked into the error from the validator says it disallows setting the pod security context.

The security context may need to be set at the container level instead. We can confirm with the Knative Serving folks on Slack, but it would effectively be this:

spec:
  template:
    spec:
      containers:
      - image: my-image
        securityContext:  # This is correct - at container level
          runAsUser: 1000
          allowPrivilegeEscalation: false

@@ -168,6 +168,8 @@ type RunSpec struct {
// Env variables to be set
Envs Envs `yaml:"envs,omitempty"`

// PodSecurityContext to be set for read and write permission
PodSecurityContext PodSecurityContext `yaml:"podSecurityContext, omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

You can remove the extraneous space prepended to "omitempty" here

@@ -0,0 +1,8 @@
package functions

type PodSecurityContext struct {
Copy link
Member

Choose a reason for hiding this comment

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

We should confirm with the Serving team, but this may need to be renamed SecurityContext and set at the Container level in the Knative Deployer in order to clear up the validation webhook error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add pod security context from func.yaml
2 participants