Skip to content

fix(inject): inherit beta native sidecar annotation from namespace - #15734

Open
spicysharkco wants to merge 1 commit into
linkerd:mainfrom
spicysharkco:fix/ns-beta-native-sidecar
Open

spicysharkco wants to merge 1 commit into
linkerd:mainfrom
spicysharkco:fix/ns-beta-native-sidecar

Conversation

@spicysharkco

Copy link
Copy Markdown

Problem

A namespace annotated with config.beta.linkerd.io/proxy-enable-native-sidecar: "false" no longer turns native sidecars off: new pods in it get one anyway, because native sidecars are now the default. The same annotation on the pod works. The annotation is deprecated, not removed (doc, override code), and the deprecated alpha key is still inherited.

#15267 replaced the beta key in ProxyAnnotations with the GA key, so the beta key is in neither list that AppendNamespaceAnnotations copies.

Solution

Add the beta key to ProxyAlphaConfigAnnotations, next to the alpha key. It cannot go in ProxyAnnotations: the proxy injector builds metric labels from that list, the beta and GA keys give the same label, and the duplicate panics the injector at start-up.

Validation

go test -count=3 -run TestGetOverriddenValues ./pkg/inject/: the new beta row fails without the change (Proxy.NativeSidecar: true != false) and passes with it; the new alpha row passes both ways. The pkg/inject and controller/proxy-injector packages pass.

Fixes #15733

Problem

A namespace annotated with `config.beta.linkerd.io/proxy-enable-native-sidecar: "false"` no longer turns native sidecars off: new pods in it get one anyway, because native sidecars are now the default. The same annotation on the pod works. The annotation is deprecated, not removed ([doc](https://github.com/linkerd/linkerd2/blob/b60b8e74786e5c6d47d211375d223446f9ae1857/cli/cmd/doc.go#L287-L290), [override code](https://github.com/linkerd/linkerd2/blob/b60b8e74786e5c6d47d211375d223446f9ae1857/pkg/inject/inject.go#L429-L445)), and the deprecated alpha key is still inherited.

linkerd#15267 replaced the beta key in `ProxyAnnotations` with the GA key, so [the beta key is in neither list](https://github.com/linkerd/linkerd2/blob/b60b8e74786e5c6d47d211375d223446f9ae1857/pkg/inject/inject.go#L85-L90) that [`AppendNamespaceAnnotations`](https://github.com/linkerd/linkerd2/blob/b60b8e74786e5c6d47d211375d223446f9ae1857/pkg/inject/inject.go#L177-L189) copies.

Solution

Add the beta key to `ProxyAlphaConfigAnnotations`, next to the alpha key. It cannot go in `ProxyAnnotations`: the proxy injector builds metric labels from that list, the beta and GA keys give the same label, and the duplicate panics the injector at start-up.

Validation

`go test -count=3 -run TestGetOverriddenValues ./pkg/inject/`: the new beta row fails without the change (`Proxy.NativeSidecar: true != false`) and passes with it; the new alpha row passes both ways. The `pkg/inject` and `controller/proxy-injector` packages pass.

Signed-off-by: Leo King <321699413+spicysharkco@users.noreply.github.com>
@spicysharkco
spicysharkco requested a review from a team as a code owner October 20, 2026 02:36
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.

Proxy injector ignores the beta native sidecar annotation on a namespace

1 participant