[release-4.22] OCPBUGS-111083: fix(hcco): run kas-connection-checker as non-root - #9320
Conversation
The Deployment set no securityContext, and kube-system is exempt from both SCC and Pod Security admission, so nothing assigned a UID and the cli image ran as root. The workload only reads the ServiceAccount token (mode 0644) and curls an endpoint, so it needs none of those privileges. The openshift.io/required-scc annotation was inert in kube-system, and once a UID is pinned it becomes a hazard: if that exemption ever changed, restricted-v2 (MustRunAsRange) would reject UID 1000 as outside the namespace uid-range and the checker would fail admission. Pin RunAsUser to 1000 at the pod level and add the restricted container security context (no privilege escalation, read-only rootfs, RunAsNonRoot, drop ALL capabilities), matching konnectivity-agent, which solves the same problem in the same namespace. Clear the required-scc annotation by setting the annotation map to nil rather than dropping the assignment, so it is also removed from Deployments created by earlier versions. Extend the unit tests to assert the security context, invert the annotation assertion, and add the stale annotation to the pre-existing Deployment fixture so the upgrade path is exercised. Signed-off-by: Máté Lajkó <mate.lajko@ibm.com> Commit-Message-Assisted-by: Claude (via Claude Code) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> (cherry picked from commit 02db6ac)
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
Skipping CI for Draft Pull Request. |
|
@matlaj: This pull request references Jira Issue OCPBUGS-105875, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
|
/verified by verifyKASCheckerSecurityContext, @matlaj I deployed a hosted cluster with this change and confirmed the UID on the kas-connection-checker pods. |
|
/auto-cc |
|
@matlaj: This PR has been marked as verified by DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release-4.22 #9320 +/- ##
================================================
+ Coverage 36.50% 36.51% +0.01%
================================================
Files 777 777
Lines 95244 95265 +21
================================================
+ Hits 34768 34789 +21
Misses 57637 57637
Partials 2839 2839
🚀 New features to boost your workflow:
|
|
/uncc |
|
Scheduling tests matching the |
|
/test e2e-aks |
|
@matlaj: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. I understand the commands that are listed here. |
|
/jira cherrypick OCPBUGS-105875 |
|
@TwoDCube: Jira Issue OCPBUGS-105875 has been cloned as Jira Issue OCPBUGS-111083. Will retitle bug to link to clone. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
@matlaj: This pull request references Jira Issue OCPBUGS-111083, which is valid. The bug has been moved to the POST state. 7 validation(s) were run on this bug
The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
/retitle [release-4.22] OCPBUGS-111083: fix(hcco): run kas-connection-checker as non-root |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: matlaj, muraee, rtheis The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
d6f475e
into
openshift:release-4.22
|
@matlaj: Jira Issue Verification Checks: Jira Issue OCPBUGS-111083 Jira Issue OCPBUGS-111083 has been moved to the MODIFIED state and will move to the VERIFIED state when the change is available in an accepted nightly payload. 🕓 DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
What this PR does / why we need it:
This is a manual backport of #9296. The test code is slightly different due to helpers introduced by #8309 missing from the
release-4.22branch.The Deployment set no securityContext, and kube-system is exempt from both SCC and Pod Security admission, so nothing assigned a UID and the cli image ran as root.
The workload only reads the ServiceAccount token (mode 0644) and curls an endpoint, so it needs none of those privileges.
The openshift.io/required-scc annotation was inert in kube-system, and once a UID is pinned it becomes a hazard: if that exemption ever changed, restricted-v2 (MustRunAsRange) would reject UID 1000 as outside the namespace uid-range and the checker would fail admission.
Pin RunAsUser to 1000 at the pod level and add the restricted container security context (no privilege escalation, read-only rootfs, RunAsNonRoot, drop ALL capabilities), matching konnectivity-agent, which solves the same problem in the same namespace.
Clear the required-scc annotation by setting the annotation map to nil rather than dropping the assignment, so it is also removed from Deployments created by earlier versions.
Extend the unit tests to assert the security context, invert the annotation assertion, and add the stale annotation to the pre-existing Deployment fixture so the upgrade path is exercised.
Which issue(s) this PR fixes:
Fixes OCPBUGS-105875
Special notes for your reviewer:
Checklist:
Signed-off-by: Máté Lajkó mate.lajko@ibm.com
Commit-Message-Assisted-by: Claude (via Claude Code)
Co-Authored-By: Claude Opus 5 noreply@anthropic.com