Skip to content

fix: replace privileged mode with NET_ADMIN/NET_RAW capabilities in proxy-init - #234

Closed
Ladas wants to merge 1 commit into
mainfrom
fix/proxy-init-drop-privileged
Closed

Ladas wants to merge 1 commit into
mainfrom
fix/proxy-init-drop-privileged

Conversation

@Ladas

@Ladas Ladas commented Mar 15, 2026

Copy link
Copy Markdown

Summary

  • Replace privileged: true with capabilities: [NET_ADMIN, NET_RAW] in the proxy-init init container
  • The proxy-init only needs iptables manipulation, which requires NET_ADMIN and NET_RAW — not full privileged access
  • Aligns webhook injection with the static AuthBridge deployment manifest (AuthBridge/k8s/authbridge-deployment.yaml:269-273) which already uses capabilities
  • On OpenShift, this allows using a narrower custom SCC instead of the full privileged SCC

Context

On OpenShift (HyperShift CI), agent pods fail to start because the anyuid SCC doesn't allow privileged: true containers, and the privileged SCC isn't granted to dynamically-created agent service accounts. See rossoctl/rossoctl#933.

With this change, a custom SCC allowing only NET_ADMIN/NET_RAW capabilities is sufficient.

Test plan

  • CI builds and passes (Go compilation, unit tests)
  • Paired with kagenti/kagenti custom SCC change for E2E verification
  • Weather-service agent deploys successfully on OpenShift with custom SCC

🤖 Generated with Claude Code

…roxy-init

The proxy-init init container used privileged: true for iptables setup,
but only NET_ADMIN and NET_RAW capabilities are actually needed. This
matches the static AuthBridge deployment manifest and Istio's istio-init
pattern.

On OpenShift, privileged mode requires the privileged SCC which is overly
broad. With capabilities, a narrower custom SCC can be used instead.

Signed-off-by: Ladislav Smola <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
Ladas added a commit to Ladas/kagenti that referenced this pull request Mar 15, 2026
The AuthBridge webhook injects a privileged init container for iptables
traffic interception, which requires the full privileged SCC on OpenShift.
This is overly broad — only NET_ADMIN and NET_RAW capabilities are needed.

Changes:
- Add kagenti-authbridge custom SCC allowing NET_ADMIN/NET_RAW + RunAsAny
- Replace default-privileged-scc and agent-anyuid-scc RoleBindings with
  a single agent-authbridge-scc binding for all agent SAs
- Add CI script to build webhook from custom kagenti-extensions branch
- Add --extensions-ref option to /run-e2e comment trigger
- Add extensions_ref input to workflow_dispatch

Paired with rossoctl/cortex#234 which changes the webhook to
use capabilities instead of privileged mode.

To verify: /run-e2e --extensions-ref fix/proxy-init-drop-privileged

Signed-off-by: Ladislav Smola <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
@pdettori
pdettori requested a review from huang195 March 16, 2026 18:58

@huang195 huang195 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have a local branch (feat/remove-privileged-init) that addresses the same problem but takes a more comprehensive approach. Here's how they compare:

Same core change: Both replace privileged: true with NET_ADMIN/NET_RAW capabilities on the proxy-init container.

Key differences:

Aspect This PR My branch
Files changed 2 (webhook Go code + README) 7 files
Scope Webhook code only Webhook + init-iptables.sh + all static deployment manifests
iptables approach Keeps existing REDIRECT logic Switches to DNAT $POD_IP — eliminates need for sysctl route_localnet=1
sysctl removal Not touched Removes sysctl -w net.ipv4.conf.all.route_localnet=1 entirely
POD_IP env var Not added Adds via Downward API (status.podIP)
Static manifests Not updated Updates all 5 deployment YAMLs to match

Potential issue with this PR: init-iptables.sh still calls sysctl -w net.ipv4.conf.all.route_localnet=1, which requires privileged mode to write to /proc/sys. After this PR drops privileged mode, that sysctl call will fail — which could break Istio ambient mesh coexistence.

My branch avoids this by replacing REDIRECT with DNAT to the pod's own IP (routable, non-loopback), so route_localnet=1 is no longer needed at all.

Would you like me to open a PR using my branch instead? Happy to do so if that would be helpful.

@huang195

Copy link
Copy Markdown
Member

Opened #242 as a more comprehensive alternative that also addresses the sysctl route_localnet dependency by switching from REDIRECT to DNAT.

@huang195

Copy link
Copy Markdown
Member

Closing this in favor of #242

@huang195 huang195 closed this Mar 16, 2026
@pdettori
pdettori deleted the fix/proxy-init-drop-privileged branch March 19, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants