Skip to content

Conversation

@dronenb
Copy link

@dronenb dronenb commented Nov 7, 2025

Fixes #2138

@openshift-ci openshift-ci bot requested review from bfournie and zaneb November 7, 2025 20:08
@coderabbitai
Copy link

coderabbitai bot commented Nov 7, 2025

Walkthrough

Adds SecurityContext configurations to the node-joiner and node-joiner-monitor containers in the oc adm node-image command's pod specifications. Both containers now enforce non-root execution, disallow privilege escalation, and drop all default capabilities.

Changes

Cohort / File(s) Change Summary
Security context enforcement
pkg/cli/admin/nodeimage/create.go, pkg/cli/admin/nodeimage/monitor.go
Adds SecurityContext to container specs with AllowPrivilegeEscalation: false, RunAsNonRoot: true, and Capabilities.Drop: ["ALL"]

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Changes are localized to two files with identical security context configurations applied consistently across both containers.
  • No logic changes, control flow modifications, or new functionality introduced.

Assessment against linked issues

Objective Addressed Explanation
Set SecurityContext on node-joiner container in create command [#2138]
Set SecurityContext on node-joiner-monitor container in monitor command [#2138]
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 7, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

@openshift-ci openshift-ci bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 7, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 7, 2025

Hi @dronenb. Thanks for your PR.

I'm waiting for a github.com 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-sigs/prow repository.

@dronenb dronenb changed the title fix(nodeimage): add PodSecurityContext to image creation and monitor pods fix(nodeimage): add SecurityContext to image creation and monitor containers Nov 7, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
pkg/cli/admin/nodeimage/monitor.go (1)

290-296: LGTM! Security context correctly addresses PodSecurity violations.

The SecurityContext configuration properly satisfies the "restricted:latest" PodSecurity requirements identified in issue #2138. All three mandatory fields are present.

Consider extracting the identical SecurityContext configuration shared with create.go (lines 748-754) into a common helper function to reduce duplication.

Optionally, the boolean pointer pattern &[]bool{false}[0] could be replaced with more idiomatic Go:

SecurityContext: &corev1.SecurityContext{
    AllowPrivilegeEscalation: ptr.To(false),
    RunAsNonRoot:             ptr.To(true),
    Capabilities: &corev1.Capabilities{
        Drop: []corev1.Capability{"ALL"},
    },
},

This requires importing k8s.io/utils/ptr.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 1c5f490 and 9318d57.

📒 Files selected for processing (2)
  • pkg/cli/admin/nodeimage/create.go (1 hunks)
  • pkg/cli/admin/nodeimage/monitor.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • pkg/cli/admin/nodeimage/create.go
  • pkg/cli/admin/nodeimage/monitor.go
🔇 Additional comments (1)
pkg/cli/admin/nodeimage/create.go (1)

748-754: LGTM! Security context matches monitor.go implementation.

The SecurityContext correctly addresses the PodSecurity violations for the node-joiner container. See the review comment on monitor.go lines 290-296 for suggested refactors regarding code duplication and the boolean pointer pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

oc adm node-image does not set container SecurityContext

1 participant