All Products
Search
Document Center

Alibaba Cloud Service Mesh:Configure a sidecar proxy with annotations

Last Updated:Mar 11, 2026

When mesh-wide sidecar proxy defaults do not fit every workload, you can override CPU, memory, startup behavior, traffic interception, and proxy lifecycle settings for individual pods through Kubernetes annotations -- without changing the global mesh configuration.

Two annotation categories are available:

  • Resource annotations -- Control CPU, memory, and other container-level resource requests and limits for the sidecar proxy (for example, sidecar.istio.io/proxyMemory).

  • ProxyConfig annotations -- Override proxy runtime behavior such as termination drain duration, concurrency, and startup ordering through the proxy.istio.io/config annotation.

Prerequisites

Before you begin, make sure that you have:

Add resource annotations

Resource annotations control CPU, memory, and other container-level settings for the sidecar proxy. Add these annotations under spec.template.metadata.annotations in the deployment YAML.

Apply annotations through the ACK console

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, click the name of the cluster that you want to manage and choose Workloads > Deployments in the left-side navigation pane.

  3. On the Deployments page, find the target application and choose More > View in YAML in the Actions column.

  4. In the Edit YAML dialog box, add annotations under the template parameter, then click Update. The following example sets the minimum memory of the sidecar proxy to 14 MiB:

    annotations:
      sidecar.istio.io/proxyMemory: 14Mi

    Memory annotation in YAML

Verify the annotation

  1. In the left-side navigation pane of the cluster details page, choose Workloads > Pods.

  2. On the Pods page, find the pod and click View Details in the Actions column.

  3. On the Container tab, click istio-proxy. The required memory for the istio-proxy container shows 14 MiB.

    Required resources showing 14 MiB

Set ProxyConfig fields

ProxyConfig fields control proxy runtime behavior -- termination handling, concurrency, and startup ordering. Set these fields through the proxy.istio.io/config annotation in YAML or JSON format.

The procedure for applying ProxyConfig annotations is the same as for resource annotations. See the steps in Add resource annotations.

Example 1: Set the termination drain duration

The terminationDrainDuration field controls how long the istio-proxy container waits before shutting down after the application container terminates. During this period, the proxy drains active connections -- preventing new connections while allowing existing ones to complete.

Add the following annotation to set a 3-second drain duration:

annotations:
  proxy.istio.io/config: |
    terminationDrainDuration: 3s
Termination drain duration annotation

To verify, navigate to the pod details page: Workloads > Pods > View Details > Container tab > istio-proxy. The termination drain duration shows 3 seconds.

Proxy config showing 3 seconds

Example 2: Control the sidecar startup sequence

By default, ASM sets holdApplicationUntilProxyStarts to true globally. This prevents the application container from starting until the istio-proxy container is ready to receive traffic. The Istio Container Network Interface (CNI) plug-in or the sidecar injector modifies the pod spec to enforce this ordering.

Keep this set to true for most workloads -- it makes sure that traffic management, monitoring, and security policies take effect as soon as the pod starts receiving traffic. Set it to false only when the application does not depend on the proxy being ready at startup, for example, batch jobs that do not receive inbound traffic.

To verify the startup sequence, navigate to the pod details page: Workloads > Pods > View Details > Events tab. The events show that the istio-proxy container starts before the application container.

Pod events showing istio-proxy start sequence

Istio resource annotations reference

The following table lists supported Istio resource annotations for sidecar proxy configuration.

AnnotationDescription
proxy.istio.io/configOverrides the proxy configuration for this specific pod. Accepts YAML or JSON values.
readiness.status.sidecar.istio.io/applicationPortsComma-separated list of ports exposed by the application container. Used by the sidecar proxy readiness probe to determine whether the proxy is configured and ready to receive traffic.
readiness.status.sidecar.istio.io/failureThresholdFailure threshold for the sidecar proxy readiness probe.
readiness.status.sidecar.istio.io/initialDelaySecondsInitial delay for the sidecar proxy readiness probe, in seconds.
readiness.status.sidecar.istio.io/periodSecondsPeriod for the sidecar proxy readiness probe, in seconds.
sidecar.istio.io/componentLogLevelComponent log level for the sidecar proxy.
sidecar.istio.io/enableCoreDumpWhether to enable core dump for the sidecar proxy.
sidecar.istio.io/extraStatTagsComma-separated list of additional tags extracted from in-proxy Istio telemetry.
sidecar.istio.io/injectWhether to enable automatic sidecar proxy injection for this pod.
sidecar.istio.io/interceptionModeTraffic interception mode: REDIRECT or TPROXY.
sidecar.istio.io/logLevelLog level for the sidecar proxy.
sidecar.istio.io/proxyCPURequested CPU for the sidecar proxy. Format: Kubernetes resource quantity (for example, 100m).
sidecar.istio.io/proxyCPULimitCPU limit for the sidecar proxy. Format: Kubernetes resource quantity (for example, 2000m).
sidecar.istio.io/proxyMemoryRequested memory for the sidecar proxy. Format: Kubernetes resource quantity (for example, 128Mi).
sidecar.istio.io/proxyMemoryLimitMemory limit for the sidecar proxy. Format: Kubernetes resource quantity (for example, 1024Mi).
sidecar.istio.io/rewriteAppHTTPProbersWhether to rewrite HTTP readiness and liveness probes to redirect through the sidecar proxy.
status.sidecar.istio.io/portHTTP status port of the sidecar proxy. Set to 0 to disable the status endpoint. Default: 15020.
traffic.sidecar.istio.io/excludeInboundPortsComma-separated list of inbound ports to exclude from traffic redirection. The wildcard * matches all ports.
traffic.sidecar.istio.io/excludeOutboundIPRangesComma-separated list of CIDR blocks to exclude from outbound traffic redirection. The wildcard * matches all CIDR blocks.
traffic.sidecar.istio.io/excludeOutboundPortsComma-separated list of outbound ports to exclude from traffic redirection.
traffic.sidecar.istio.io/includeInboundPortsComma-separated list of inbound ports to redirect to the sidecar proxy. The wildcard * matches all ports. An empty value disables all inbound redirection.
traffic.sidecar.istio.io/includeOutboundIPRangesComma-separated list of CIDR blocks to redirect for outbound traffic. The wildcard * matches all CIDR blocks. An empty value disables all outbound redirection.
traffic.sidecar.istio.io/includeOutboundPortsComma-separated list of outbound ports to redirect to the sidecar proxy.
traffic.sidecar.istio.io/kubevirtInterfacesComma-separated list of virtual interfaces whose inbound traffic is treated as outbound traffic.

ProxyConfig fields reference

Set the following fields through the proxy.istio.io/config annotation to override proxy runtime behavior for individual pods.

FieldTypeDefaultDescription
configPathString--Path to the proxy configuration file directory. The proxy agent generates and stores configuration in this directory.
statsdUdpAddressString--IP address and port of a StatsD UDP listener (for example, 127.0.0.1:9125).
proxyAdminPortInt3215000Port on which Envoy listens for administrative commands.
controlPlaneAuthPolicyAuthenticationPolicyMUTUAL_TLSAuthentication policy for proxy-to-control-plane connections.
concurrencyInt32Value2Number of worker threads. Set to 0 to use all available cores. If unset, auto-determined based on CPU requests and limits.
interceptionModeInboundInterceptionMode--Mode for redirecting inbound traffic to the sidecar proxy.
tracingTracing--Distributed tracing configuration.
sdsSDS--Secret Discovery Service (SDS) configuration.
proxyMetadataMap<string, string>--Additional environment variables for the proxy. Variables with names starting with ISTIO_META_ are included in the bootstrap configuration and sent to the XDS server.
statusPortInt3215020Port for administrative commands such as readiness probes.
terminationDrainDurationDuration5sTime allowed for active connections to complete before the proxy is killed. After receiving SIGTERM or SIGINT, istio-agent starts draining connections, then sleeps for this duration before terminating remaining processes.
holdApplicationUntilProxyStartsBoolValuetrue (ASM default)Delays application container startup until the sidecar proxy is ready to accept traffic, preventing startup race conditions.