Skip to content

Commit 009a25f

Browse files
authored
feat: promote native sidecars to GA and enable by default (#15267)
Advances [native sidecars](https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/) support from beta to GA, and makes them the default injection mode for the proxy. This requires Kubernetes v1.29 or later, which is below our current minimum supported version (v1.31). The cluster must also have the `SidecarContainers` feature gate enabled, which is the default in all recent Kubernetes versions. You can verify the feature gate is enabled with: ``` $ kubectl get --raw /metrics | grep feature.*SidecarContainers kubernetes_feature_enabled{name="SidecarContainers",stage=""} 1 ``` Changes: - `proxy.nativeSidecar` now defaults to `true` - The `config.beta.linkerd.io/proxy-enable-native-sidecar` annotation is deprecated in favor of `config.linkerd.io/proxy-enable-native-sidecar`
1 parent 52016cb commit 009a25f

67 files changed

Lines changed: 7590 additions & 7522 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

charts/linkerd-control-plane/values.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ proxy:
228228
# Kubernetes but no longer than the pod's `terminationGracePeriodSeconds`.
229229
# See [Lifecycle
230230
# hooks](https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks)
231-
# for more info on container lifecycle hooks.
231+
# for more info on container lifecycle hooks. Ignored when nativeSidecar=true.
232232
waitBeforeExitSeconds: 0
233233
# -- If set, the application container will not start until the proxy is
234234
# ready
@@ -251,10 +251,8 @@ proxy:
251251
defaultInboundPolicy: "all-unauthenticated"
252252
# -- Configures the outbound transport mode. Valid values are "transport-header" and "transparent"
253253
outboundTransportMode: transport-header
254-
# -- Enable KEP-753 native sidecars
255-
# This is a beta feature. It requires Kubernetes >= 1.29.
256-
# If enabled, .proxy.waitBeforeExitSeconds should not be used.
257-
nativeSidecar: false
254+
# -- Enable [native sidecars](https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/)
255+
nativeSidecar: true
258256
# -- Native sidecar proxy startup probe parameters.
259257
# -- LivenessProbe timeout and delay configuration
260258
livenessProbe:

charts/partials/templates/_proxy.tpl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{{ define "partials.proxy" -}}
2-
{{ if and .Values.proxy.nativeSidecar .Values.proxy.waitBeforeExitSeconds }}
3-
{{ fail "proxy.nativeSidecar and waitBeforeExitSeconds cannot be used simultaneously" }}
4-
{{- end }}
52
{{- if not (has .Values.proxy.logHTTPHeaders (list "insecure" "off" "")) }}
63
{{- fail "logHTTPHeaders must be one of: insecure | off" }}
74
{{- end }}

cli/cmd/doc.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,15 @@ func generateAnnotationsDocs() []annotationDoc {
282282
},
283283
{
284284
Name: k8s.ProxyEnableNativeSidecarAnnotationAlpha,
285-
Description: "Enable KEP-753 native sidecars. This is a beta feature. It requires Kubernetes >= 1.29. If enabled, .proxy.waitBeforeExitSeconds should not be used. Deprecated in favor of " + k8s.ProxyEnableNativeSidecarAnnotationBeta,
285+
Description: "Enable KEP-753 native sidecars. Deprecated in favor of " + k8s.ProxyEnableNativeSidecarAnnotation,
286286
},
287287
{
288288
Name: k8s.ProxyEnableNativeSidecarAnnotationBeta,
289-
Description: "Enable KEP-753 native sidecars. This is a beta feature. It requires Kubernetes >= 1.29. If enabled, .proxy.waitBeforeExitSeconds should not be used.",
289+
Description: "Enable KEP-753 native sidecars. Deprecated in favor of " + k8s.ProxyEnableNativeSidecarAnnotation,
290+
},
291+
{
292+
Name: k8s.ProxyEnableNativeSidecarAnnotation,
293+
Description: "Enable KEP-753 native sidecars",
290294
},
291295
{
292296
Name: k8s.ProxyAdditionalEnvAnnotation,

cli/cmd/inject.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ func getOverrideAnnotations(values *linkerd2.Values, base *linkerd2.Values) map[
498498
}
499499

500500
if proxy.NativeSidecar != baseProxy.NativeSidecar {
501-
overrideAnnotations[k8s.ProxyEnableNativeSidecarAnnotationBeta] = strconv.FormatBool(proxy.NativeSidecar)
501+
overrideAnnotations[k8s.ProxyEnableNativeSidecarAnnotation] = strconv.FormatBool(proxy.NativeSidecar)
502502
}
503503

504504
return overrideAnnotations

cli/cmd/inject_test.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,6 @@ func TestProxyConfigurationAnnotations(t *testing.T) {
725725
values.Proxy.Await = false
726726
values.Proxy.AccessLog = "apache"
727727
values.Proxy.ShutdownGracePeriod = "60s"
728-
values.Proxy.NativeSidecar = true
729728

730729
expectedOverrides := map[string]string{
731730
k8s.ProxyIgnoreInboundPortsAnnotation: "8500-8505",
@@ -739,16 +738,15 @@ func TestProxyConfigurationAnnotations(t *testing.T) {
739738
k8s.ProxyLogLevelAnnotation: "debug",
740739
k8s.ProxyLogFormatAnnotation: "cool",
741740

742-
k8s.ProxyEnableExternalProfilesAnnotation: "true",
743-
k8s.ProxyCPURequestAnnotation: "10m",
744-
k8s.ProxyCPULimitAnnotation: "100m",
745-
k8s.ProxyMemoryRequestAnnotation: "10Mi",
746-
k8s.ProxyMemoryLimitAnnotation: "50Mi",
747-
k8s.ProxyWaitBeforeExitSecondsAnnotation: "10",
748-
k8s.ProxyAwait: "disabled",
749-
k8s.ProxyAccessLogAnnotation: "apache",
750-
k8s.ProxyShutdownGracePeriodAnnotation: "60s",
751-
k8s.ProxyEnableNativeSidecarAnnotationBeta: "true",
741+
k8s.ProxyEnableExternalProfilesAnnotation: "true",
742+
k8s.ProxyCPURequestAnnotation: "10m",
743+
k8s.ProxyCPULimitAnnotation: "100m",
744+
k8s.ProxyMemoryRequestAnnotation: "10Mi",
745+
k8s.ProxyMemoryLimitAnnotation: "50Mi",
746+
k8s.ProxyWaitBeforeExitSecondsAnnotation: "10",
747+
k8s.ProxyAwait: "disabled",
748+
k8s.ProxyAccessLogAnnotation: "apache",
749+
k8s.ProxyShutdownGracePeriodAnnotation: "60s",
752750
}
753751

754752
overrides := getOverrideAnnotations(values, baseValues)
@@ -853,6 +851,7 @@ func TestOverwriteRegistry(t *testing.T) {
853851
}
854852

855853
func diffOverrides(t *testing.T, expectedOverrides map[string]string, actualOverrides map[string]string) {
854+
t.Helper()
856855
if len(expectedOverrides) != len(actualOverrides) {
857856
t.Fatalf("expected annotations:\n%s\nbut received:\n%s", expectedOverrides, actualOverrides)
858857
}

cli/cmd/testdata/inject-filepath/expected/injected_nginx.yaml

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,50 @@ spec:
1919
linkerd.io/workload-ns: ""
2020
spec:
2121
containers:
22+
- image: nginx
23+
name: nginx
24+
ports:
25+
- containerPort: 80
26+
name: http
27+
initContainers:
28+
- args:
29+
- --firewall-bin-path
30+
- iptables-nft
31+
- --firewall-save-bin-path
32+
- iptables-nft-save
33+
- --ipv6=false
34+
- --incoming-proxy-port
35+
- "4143"
36+
- --outgoing-proxy-port
37+
- "4140"
38+
- --proxy-uid
39+
- "2102"
40+
- --inbound-ports-to-ignore
41+
- 4190,4191,4567,4568
42+
- --outbound-ports-to-ignore
43+
- 4567,4568
44+
command:
45+
- /usr/lib/linkerd/linkerd2-proxy-init
46+
image: cr.l5d.io/linkerd/proxy:install-proxy-version
47+
imagePullPolicy: IfNotPresent
48+
name: linkerd-init
49+
securityContext:
50+
allowPrivilegeEscalation: false
51+
capabilities:
52+
add:
53+
- NET_ADMIN
54+
- NET_RAW
55+
privileged: false
56+
readOnlyRootFilesystem: true
57+
runAsGroup: 65534
58+
runAsNonRoot: true
59+
runAsUser: 65534
60+
seccompProfile:
61+
type: RuntimeDefault
62+
terminationMessagePolicy: FallbackToLogsOnError
63+
volumeMounts:
64+
- mountPath: /run
65+
name: linkerd-proxy-init-xtables-lock
2266
- env:
2367
- name: _pod_name
2468
valueFrom:
@@ -158,13 +202,6 @@ spec:
158202
value: linkerd-destination.linkerd.serviceaccount.identity.linkerd.cluster.local
159203
image: cr.l5d.io/linkerd/proxy:install-proxy-version
160204
imagePullPolicy: IfNotPresent
161-
lifecycle:
162-
postStart:
163-
exec:
164-
command:
165-
- /usr/lib/linkerd/linkerd-await
166-
- --timeout=2m
167-
- --port=4191
168205
livenessProbe:
169206
httpGet:
170207
path: /live
@@ -183,63 +220,26 @@ spec:
183220
port: 4191
184221
initialDelaySeconds: 2
185222
timeoutSeconds: 1
223+
restartPolicy: Always
186224
securityContext:
187225
allowPrivilegeEscalation: false
188226
readOnlyRootFilesystem: true
189227
runAsNonRoot: true
190228
runAsUser: 2102
191229
seccompProfile:
192230
type: RuntimeDefault
231+
startupProbe:
232+
failureThreshold: 120
233+
httpGet:
234+
path: /ready
235+
port: 4191
236+
periodSeconds: 1
193237
terminationMessagePolicy: FallbackToLogsOnError
194238
volumeMounts:
195239
- mountPath: /var/run/linkerd/identity/end-entity
196240
name: linkerd-identity-end-entity
197241
- mountPath: /var/run/secrets/tokens
198242
name: linkerd-identity-token
199-
- image: nginx
200-
name: nginx
201-
ports:
202-
- containerPort: 80
203-
name: http
204-
initContainers:
205-
- args:
206-
- --firewall-bin-path
207-
- iptables-nft
208-
- --firewall-save-bin-path
209-
- iptables-nft-save
210-
- --ipv6=false
211-
- --incoming-proxy-port
212-
- "4143"
213-
- --outgoing-proxy-port
214-
- "4140"
215-
- --proxy-uid
216-
- "2102"
217-
- --inbound-ports-to-ignore
218-
- 4190,4191,4567,4568
219-
- --outbound-ports-to-ignore
220-
- 4567,4568
221-
command:
222-
- /usr/lib/linkerd/linkerd2-proxy-init
223-
image: cr.l5d.io/linkerd/proxy:install-proxy-version
224-
imagePullPolicy: IfNotPresent
225-
name: linkerd-init
226-
securityContext:
227-
allowPrivilegeEscalation: false
228-
capabilities:
229-
add:
230-
- NET_ADMIN
231-
- NET_RAW
232-
privileged: false
233-
readOnlyRootFilesystem: true
234-
runAsGroup: 65534
235-
runAsNonRoot: true
236-
runAsUser: 65534
237-
seccompProfile:
238-
type: RuntimeDefault
239-
terminationMessagePolicy: FallbackToLogsOnError
240-
volumeMounts:
241-
- mountPath: /run
242-
name: linkerd-proxy-init-xtables-lock
243243
volumes:
244244
- emptyDir: {}
245245
name: linkerd-proxy-init-xtables-lock

0 commit comments

Comments
 (0)