Repository navigation
Conversation
linkerd-init adds NET_ADMIN and NET_RAW but keeps the container runtime's default capabilities, unless the workload's first container drops them. iptables only needs the two added capabilities, and the proxy image grants exactly those as file capabilities on the binaries linkerd-init runs. Drop ALL in linkerd-init, then add NET_ADMIN, NET_RAW and any capabilities the workload adds. When proxyInit.privileged or proxyInit.closeWaitTimeoutSecs is set, the container is privileged and gets every capability regardless, so the existing behaviour is kept there. Signed-off-by: Ilia Lazebnik <ilia.lazebnik@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
linkerd-initaddsNET_ADMINandNET_RAWbut doesn't drop anything (charts/partials/templates/_proxy-init.tpl). Unless the workload's first container dropsALL, whichinjectProxyInitthen copies over, the init container also keeps every default capability of the container runtime:CHOWN,DAC_OVERRIDE,FOWNER,SETUID,SETGID,KILLand so on.With the default non-root user (65534) those stay in the bounding set only, because the proxy image grants
cap_net_raw,cap_net_admin+eipas file capabilities onlinkerd2-proxy-initand thextables-*-multibinaries (Dockerfile.proxy). WithproxyInit.runAsRoot: true, the process has all of them.Solution
When
linkerd-initis not privileged, it now dropsALLand then addsNET_ADMIN,NET_RAWand any capabilities copied from the workload, as before. This is already what gets rendered when the workload's first container dropsALL(inject_emojivoto_deployment_capabilities.golden.yml), so the combination isn't new.When
proxyInit.privilegedorproxyInit.closeWaitTimeoutSecsis set, the container is privileged and gets every capability regardless ofdrop, so the existing rendering is kept there.Validation
go test ./cli/cmd/... --updateand updated the proxy injector fixtures incontroller/proxy-injector/fake/data. The only change in them is the addeddrop: [ALL]onlinkerd-init.go testpasses for every package outsidetest/integration.linkerd installwith default values,proxyInit.runAsRoot=true,proxyInit.runAsRoot=true,proxyInit.closeWaitTimeoutSecs=10andproxyInit.privileged=true. The first two getdrop: [ALL], and the two privileged ones are unchanged.edge-26.11.3images, and injected a sample client and server withlinkerd inject --manualfrom the same CLI:linkerd-initcontainer rendered withadd: [NET_ADMIN, NET_RAW]anddrop: [ALL](plusNET_BIND_SERVICEfor the client, which adds it) and exited 0.tls="true"and the client's identity.linkerd upgrade --set proxyInit.runAsRoot=true, the control plane'slinkerd-initcontainers ran as UID 0 with the same capabilities, exited 0, and the pods became ready.The proxy injector in the cluster ran the released image, so the webhook path is covered by the fixture tests rather than the kind run.
This PR was prepared with an AI assistant (Claude Code) and reviewed by me.
🤖 Generated with Claude Code