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

🌱 tilt: remove securityContext for live_update #7846

Merged

Conversation

bengentil
Copy link
Contributor

What this PR does / why we need it:

As of now, tilt live_update feature requires the pod to run as root, see tilt-dev/tilt#3060

This PR removes any securityContext in manager manifests during tilt-prepare.
it allows every providers to add securityContext in manifests (like in #7831)

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 4, 2023
@k8s-ci-robot k8s-ci-robot requested a review from enxebre January 4, 2023 16:19
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jan 4, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @bengentil. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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.

@@ -775,6 +775,10 @@ func prepareWorkload(name, prefix, binaryName, containerName string, objs []unst
cmd := []string{"sh", "/start.sh", "/" + binaryName}
args := append(container.Args, []string(ts.ExtraArgs[name])...)

// remove securityContext for tilt live_update, see https://github.com/tilt-dev/tilt/issues/3060
d.Spec.Template.Spec.SecurityContext = nil
Copy link
Member

Choose a reason for hiding this comment

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

nit: let's move this line before the for loop so we do it only once for the deployment (please add the comment in both places)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I wasn't sure because if I set it out of the loop, it means removing .spec.securityContext for every deployments returned by kustomize without taking in account the containerName arg. (updateDeployment iterates on all objects and execute this function)

This means that all deployments won't have .spec.template.spec.securityContext but may have spec.template.spec.containers[].securityContext.
This shouldn't be an issue per say but may be misleading if a provider adds more deployments.

As is only container matching containerName will have the securityContext, and it will be ensure on its parent template spec.

I can add a comment to explain why it's modified in the loop or make the change globally on all deployments (+every containers maybe so it's not misleading), let me know

Copy link
Member

@sbueringer sbueringer Jan 4, 2023

Choose a reason for hiding this comment

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

Oh I missed that. Thx for the explanation :)

Maybe a short comment that this is only intentionally done for Deployments that have a container with the name containerName would be good

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just pushed a new revision, let me know if that comment is clear enough 😉

Copy link
Member

Choose a reason for hiding this comment

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

Perfect, thx!

Copy link
Member

Choose a reason for hiding this comment

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

Mostly just a safeguard if someone else comes along in the future and wants to "optimize" it :)

@bengentil bengentil force-pushed the ben/tilt-securitycontext branch from d5eb23a to 850794a Compare January 4, 2023 20:45
@sbueringer
Copy link
Member

/ok-to-test
/lgtm

/assign @fabriziopandini

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 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 Jan 5, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 3a0c921a2f50ebd60e1f6fe73e100c9f30fafe8c

Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

/lgtm

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

nice work
/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

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:

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 5, 2023
@k8s-ci-robot k8s-ci-robot merged commit 901d520 into kubernetes-sigs:main Jan 5, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.4 milestone Jan 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. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants