Skip to content

Conversation

@hurzelpurzel
Copy link
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

Set SecurityContext to the Container by its name

Which issue(s) this PR fixes:

Fixes #2054

Special notes for your reviewer:

Please be kind. I'm a frequent contributor

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 3, 2025
@k8s-ci-robot k8s-ci-robot requested a review from cdrage November 3, 2025 21:15
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: hurzelpurzel
Once this PR has been reviewed and has the lgtm label, please assign cdrage 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

@k8s-ci-robot k8s-ci-robot requested a review from TessaIO November 3, 2025 21:15
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 3, 2025
Copy link
Member

@cdrage cdrage left a comment

Choose a reason for hiding this comment

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

Just need a simple test added to test the functionality, and this LGTM!

if *securityContext != (api.SecurityContext{}) {
podSpec.Containers[0].SecurityContext = securityContext
//podSpec.Containers[0].SecurityContext = securityContext
for i := range podSpec.Containers {
Copy link
Member

Choose a reason for hiding this comment

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

Are you able to instead add a comment above saying something like...

"Search through all the containers, find the one that matches the container name and set the security context appropriately"?

And remove the commented out code.

This implementation LGTM (sucks we have to loop through all the containers... but that's a nitpick), but otherwise this is 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.

Changed as requested.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Multi-container Pod settings gets applied to the first container

3 participants