A destination rule is a key Service Mesh (ASM) resource for traffic routing. A destination rule defines policies that apply to traffic for a service after routing has occurred. It specifies settings such as load balancing, sidecar connection pool size, and outlier detection. These settings help detect and remove unhealthy hosts from the load balancing pool. This topic provides configuration examples and field descriptions for destination rules.
Configuration examples
Example 1: Simple load balancing policy
The following destination rule uses the least request (LEAST_REQUEST) load balancing algorithm. This algorithm prioritizes endpoints with the fewest outstanding requests when it distributes the load.
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: bookinfo-ratings
spec:
host: ratings.prod.svc.cluster.local
trafficPolicy:
loadBalancer:
simple: LEAST_REQUESTExample 2: Custom configuration for a port
You can customize traffic policies for specific ports. The following destination rule applies the least request (LEAST_REQUEST) load balancing policy to traffic on port 80 and the round robin (ROUND_ROBIN) load balancing policy to traffic on port 9080.
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: bookinfo-ratings-port
spec:
host: ratings.prod.svc.cluster.local
trafficPolicy: # Apply to all ports.
portLevelSettings:
- port:
number: 80
loadBalancer:
simple: LEAST_REQUEST
- port:
number: 9080
loadBalancer:
simple: ROUND_ROBINExample 3: Custom configuration for a specific workload
The following example uses the workloadSelector configuration to apply the destination rule to a specific workload.
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: configure-client-mtls-dr-with-workloadselector
spec:
host: example.com
workloadSelector:
matchLabels:
app: ratings
trafficPolicy:
loadBalancer:
simple: ROUND_ROBIN
portLevelSettings:
- port:
number: 31443
tls:
credentialName: client-credential
mode: MUTUALField reference
DestinationRule
A destination rule defines policies that apply to traffic for a destination service after routing has occurred.
Field | Type | Required | Description |
host | String | Yes | The name of a service in the service registry. The service name is looked up in the platform's service registry, such as Kubernetes services or Consul services, and in the hosts declared by ServiceEntry resources. Rules for services that are not defined in the service registry are ignored. This field applies to HTTP and TCP services. Notes for Kubernetes:
|
trafficPolicy | No | The traffic policy to apply, such as load balancing policy, connection pool size, and outlier detection. | |
subsets | No | One or more subsets that represent different versions of a service. The base traffic policy for the service can be overridden at the subset level. | |
exportTo | String[] | No | A list of namespaces to which the destination rule is exported. A destination rule is resolved in the context of a namespace. Exporting a destination rule allows it to be included in the resolution hierarchy for services in other namespaces. This feature provides a mechanism for service owners and mesh administrators to control the visibility of destination rules across namespace boundaries.
|
workloadSelector | No | Criteria used to select the pods to which this destination rule applies.
|
TrafficPolicy
A traffic policy that applies to traffic for a specific destination. This policy applies to all ports of the destination.
Field | Type | Required | Description |
loadBalancer | No | Settings for the load balancing algorithm. | |
connectionPool | No | Settings for the connection pool for an upstream service. | |
outlierDetection | No | Settings for how to remove unhealthy hosts from the load balancing pool. | |
tls | No | TLS-related settings for connections to an upstream service. | |
portLevelSettings | No | Traffic policies for specific ports. Port-level settings override destination-level settings. When a port-level traffic policy overrides a destination-level setting, other fields at the destination level are not inherited. Fields that are omitted in the port-level traffic policy use their default values. | |
tunnel | No | Tunnels TCP traffic through other transport-layer or application-layer protocols for the host specified in the destination rule. TunnelSettings can be applied to TCP or TLS routes, but not to HTTP routes. |
Subset
A subset is a collection of endpoints for a service. You can use subsets for scenarios such as A/B testing or routing to a specific version of a service. Traffic policies defined at the service level can be overridden at the subset level. For more information, see Virtual Service CRD reference.
Destination rules can specify named service subsets, such as grouping all instances of a given service by version. These service subsets are used in the routing rules of a virtual service to control traffic to different instances of a service. You can specify policies for a specific version in a subset to override the settings at the service level. The following destination rule uses the round robin (ROUND_ROBIN) load balancing policy to send all traffic to a subset named testversion. This subset consists of endpoints with the label version: v3.
The load balancing policy specified for a subset takes effect only when the destination rule sends traffic to that subset.
Typically, one or more labels are required to specify the targets included in a subset. A subset without labels can be ambiguous when the hostname represented by the destination rule supports multiple SNI hostnames, such as an egress gateway. In this case, you can use a traffic policy that includes ClientTLSSettings to identify the specific SNI host that corresponds to the named subset.
Field | Type | Required | Description |
name | String | Yes | The name of the subset. The service name and subset name can be used for traffic splitting in a routing rule. |
labels | Map<String, String> | No | Labels used to create a filter that selects endpoints of the service in the service registry. |
trafficPolicy | No | The traffic policy to apply to this subset. A subset inherits the traffic policy specified at the DestinationRule level. Settings specified at the subset level override the corresponding settings at the DestinationRule level. |
LoadBalancerSettings
Load balancing policies for a specific destination. For more information, see Load Balancing.
The following destination rule uses the round robin load balancing policy for all traffic sent to the ratings service.
The following destination rule configures session persistence for the ratings service. It uses a hash-based load balancer and sets the
httpCookiefield to use theusercookie as the hash key.
In the following table, oneof in the Type column indicates that you can set only one of the available fields.
Field | Type | Required | Description |
simple | No | Specifies a simple load balancing algorithm. | |
consistentHash | No | Specifies a consistent hashing load balancing algorithm. | |
localityLbSetting | No | Locality load balancer settings. This configuration completely overrides the mesh-wide settings. This object and the object in MeshConfig are not merged. | |
warmupDurationSecs | No | This parameter is deprecated in ASM instances 1.24 and later. Use The warmup duration for the service. If this field is set, new endpoints of the service enter a warmup mode for the specified duration, starting from their creation time. During this period, Istio gradually increases the traffic to the endpoint instead of sending a proportional amount of traffic.
| |
warmup | No | The warmup duration for the service. If this field is set, new endpoints of the service enter a warmup mode for the specified duration, starting from their creation time. During this period, Istio gradually increases the traffic to the endpoint instead of sending a proportional amount of traffic.
|
WarmupConfiguration
Field | Type | Required | Description |
duration | Duration | Yes | The warmup duration. |
minimumPercent | DoubleValue | No | Configures the minimum percentage of traffic relative to normal traffic. Default value: 10. |
aggression | DoubleValue | No | This parameter controls how quickly traffic increases during the warmup period. The default value is 1.0, which causes the node to increase traffic linearly. If you increase this parameter, the traffic increases non-linearly. |
ConnectionPoolSettings
Connection pool settings for connections to an upstream host. These settings apply to each host in the upstream service. For more information, see Envoy's circuit breaker. You can apply connection pool settings at the TCP and HTTP levels.
For example, the following rule sets a limit of 100 connections and a connection timeout of 30 ms for a Redis service named myredissrv.
Field | Type | Required | Description |
tcp | No | Common settings for HTTP and TCP upstream connections. | |
http | No | HTTP connection pool settings. |
OutlierDetection
A circuit breaker that tracks the status of hosts in an upstream service. It applies to HTTP and TCP services.
For HTTP services, a host that continuously returns 5xx errors for API calls is removed from the pool of available hosts for a specified period.
For TCP services, connection timeouts or connection failures for a given host are considered errors when calculating the consecutive error metric. For more information, see Envoy's outlier detection.
The following destination rule sets the connection pool size to 100 HTTP/1 connections and allows no more than 10 requests or connections to the reviews service. It sets a limit of 1,000 concurrent requests for HTTP/2 and configures upstream hosts to be scanned every 5 minutes. Any host that returns a 502, 503, or 504 error code for 7 consecutive times is ejected for 15 minutes.
Field | Type | Required | Description |
splitExternalLocalOriginErrors | Bool | No | Specifies whether to distinguish between local origin failures and external errors. The default value is false. If set to true, consecutiveLocalOriginFailures is used in the outlier detection calculation. Use this feature in the following scenarios.
|
consecutiveLocalOriginFailures | No | The number of consecutive local origin failures required to trigger an ejection. The default value is 5. This field takes effect only when splitExternalLocalOriginErrors is set to true. | |
consecutiveGatewayErrors | No | The number of gateway errors required to eject a host from the connection pool. When an upstream host is accessed over HTTP, 502, 503, or 504 return codes are considered gateway errors. When an upstream host is accessed over an opaque TCP connection, connection timeout and connection error/failure events are considered gateway errors. This feature is disabled by default or when the value is set to 0. Note
| |
consecutive5xxErrors | No | The number of 5xx errors required to eject a host from the connection pool. When an upstream host is accessed over an opaque TCP connection, connection timeouts, connection errors or failures, and request failure events are all considered 5xx errors. The default value is 5. You can disable this feature by setting the value to 0. | |
interval | No | The time interval for ejection scanning. The format is | |
baseEjectionTime | No | The minimum ejection duration. The time a host is ejected from the connection pool is the product of the minimum ejection duration and the number of times the host has been ejected. This field allows the system to automatically increase the ejection time for unhealthy upstream servers. The format is | |
maxEjectionPercent | Int32 | No | The maximum percentage of upstream service hosts in the load balancing pool that can be ejected. The default value is 10%. |
minHealthPercent | Int32 | No | Enables outlier detection when at least |
ClientTLSSettings
SSL/TLS settings for upstream connections. This configuration applies to HTTP and TCP upstreams. For more information, see Envoy's TLS context.
The following destination rule configures the client to use a mutual TLS connection to an upstream database cluster.
The following destination rule configures the client to use TLS when communicating with external services that match the domain name
*.foo.com.The following destination rule configures the client to use Istio mutual TLS when communicating with the ratings service.
Field | Type | Required | Description |
mode | Yes | Specifies whether to secure connections to this port with TLS. The value of this field determines how TLS is applied. | |
clientCertificate | String | No | The file path of the client-side TLS certificate.
|
privateKey | String | No | The file path of the client private key.
|
caCertificates | String | No | The file path of the CA certificate used to verify the certificate.
|
credentialName | String | No | The name of the secret that stores the client TLS certificate, including the CA certificate. The secret must exist in the same namespace as the proxy that uses the certificate. Both
Note This field takes effect for a sidecar only when a workload selector (workloadSelector) is specified in the |
subjectAltNames | String[] | No | A list of subject alternative names used to verify the identity of the subject in the certificate.
|
sni | String | No | The SNI string presented to the server during the TLS handshake. If not specified, when the |
insecureSkipVerify | No | This field specifies whether the proxy skips verifying the CA signature and SAN of the server certificate corresponding to the host. The default value is false. Set this flag only when global CA signature verification is enabled, the |
LocalityLoadBalancerSetting
Provides locality-weighted load balancing, which allows administrators to control the proportion of traffic distributed to endpoints based on the traffic's source and destination locations. You can specify locality information using labels. These labels specify the hierarchy of a locality in the format {region}/{zone}/{sub-zone}. For more information, see Locality Weight.
The following example shows how to set locality weighting across the entire mesh. Assume a mesh with workloads and services is deployed to the localities
hangzhou/zone1/andhangzhou/zone2/. This example specifies that when traffic to a service originates from a workload inhangzhou/zone1/, 80% of the traffic is sent to endpoints inhangzhou/zone1/(the same locality), and the remaining 20% is sent to endpoints inhangzhou/zone2/. This setting prioritizes routing traffic to endpoints in the same locality. A similar setting is specified for traffic originating fromhangzhou/zone2/.If your goal is to limit failover locality rather than distribute the load across regions or zones, you can set a
failoverpolicy instead of adistributepolicy.The following example sets a locality failover policy. Assume the service resides in the Hangzhou, Beijing, and Shanghai regions. This policy specifies that when endpoints in Hangzhou become unhealthy, traffic is transferred to endpoints in the Beijing region or sub-region. Similarly, when endpoints in Beijing become unhealthy, traffic is transferred to endpoints in Shanghai.
Field | Type | Required | Description |
distribute | No | Explicitly specifies load balancing weights across different regions and geographical locations. If empty, locality weights are set based on the number of endpoints in them. For more information, see Locality weighted load balancing. Note You can set only one of the | |
failover | Failover[] | No | Explicitly specifies which locality traffic will be transferred to when endpoints in the local locality become unhealthy. This field needs to be used with |
failoverPriority | String[] | No | An ordered list of labels used to sort endpoints for priority-based load balancing. This field is used to support traffic failover across different endpoint groups. This field needs to be used with Assume a total of N labels are specified:
This field can be any label specified on the client and server workloads and supports the following labels with special semantics:
The priorities for the following topology configuration are described as follows:
|
enabled | No | Enables locality load balancing. This configuration is at the DestinationRule level and will completely override the mesh-level settings. For example, if this field is configured as true, locality load balancing is enabled for this DestinationRule regardless of the mesh-level settings. |
TrafficPolicy.PortTrafficPolicy
A traffic policy for a specific port of a service.
Field | Type | Required | Description |
port | No | Specifies the port number on the destination service to which this policy applies. | |
loadBalancer | No | Controls the load balancer algorithm. | |
connectionPool | No | Controls the number of connections to the upstream service. | |
outlierDetection | No | Controls the ejection of unhealthy hosts from the load balancing pool. | |
tls | No | TLS-related settings for connections to an upstream service. |
LoadBalancerSettings.ConsistentHashLB
You can use consistent hash-based load balancing to provide soft session persistence based on HTTP headers, cookies, or other properties. Consistent hashing is weaker than traditional hostname-based session persistence. When one or more hosts are added or removed, load balancing using a consistent hashing algorithm causes a small fraction of requests to lose session persistence. Hostname-based session persistence typically encodes a specific destination in a cookie, ensuring that the association is maintained as long as the backend remains unchanged.
The advantage of consistent hashing is that it can achieve better load balancing and is more suitable for cloud-based systems.
Consistent hashing depends on each proxy having a consistent view of the endpoints. When locality load balancing is enabled, it is not guaranteed that each proxy has a consistent view of the endpoints. Locality load balancing and consistent hashing can only work together when all proxies are in the same locality, or when a higher-level load balancer is used to handle locality affinity.
Field | Type | Required | Description |
httpHeaderName | String | No | Hash based on a specific HTTP header.
You can configure only one of |
httpCookie | No | Hash based on an HTTP cookie. | |
useSourceIp | Bool | No | Hash based on the source IP address. This applies to TCP and HTTP connections. |
httpQueryParameterName | String | No | Hash based on a specified HTTP query parameter. |
ringHash | No | The Ring or Modulo load balancer implements consistent hashing for backend hosts. You can configure only one of the | |
maglev | No | The Maglev load balancer implements consistent hashing for backend hosts. ASM supports the | |
minimumRingSize | Uint64 | No | Deprecated. Use |
LoadBalancerSettings.ConsistentHashLB.RingHash
Field | Type | Required | Description |
minimumRingSize | Uint64 | No | The minimum number of virtual nodes for the Ring algorithm. The default value is 1024. A larger ring results in more fine-grained load distribution. If the number of hosts in the load balancing pool is greater than the ring size, each host will be assigned one virtual node. |
LoadBalancerSettings.ConsistentHashLB.MagLev
Field | Type | Required | Description |
tableSize | Uint64 | No | The size of the hash table in the Maglev algorithm, which helps control disruption when backend hosts change. Increasing the table size can reduce the degree of disruption. |
LoadBalancerSettings.ConsistentHashLB.HTTPCookie
Specifies the cookie that will be used as the hash key for the consistent hash load balancer. If the cookie does not exist, it will be generated.
Field | Type | Required | Description |
name | String | Yes | The content of this cookie will be used as the hash key. If this cookie does not exist and the ttl below is not set, no hash will be generated. |
path | String | No | If specified, a cookie with a TTL will be generated when this cookie does not exist. If the TTL exists and is equal to zero, the generated cookie will be a session cookie. |
ttl | Yes | The lifecycle of the cookie. |
ConnectionPoolSettings.TCPSettings
Common settings for HTTP and TCP upstream connections.
Field | Type | Required | Description |
maxConnections | Int32 | No | The maximum number of HTTP/1 or TCP connections to a destination host. The default value is 4294967295. |
connectTimeout | No | The TCP connection timeout duration. The format is | |
tcpKeepalive | No | If set, SO_KEEPALIVE needs to be set on the socket to enable TCP keepalive. | |
maxConnectionDuration | No | The maximum duration of a connection. The duration is defined as the interval since the connection was established. If not set, there is no maximum duration. When |
ConnectionPoolSettings.HTTPSettings
Settings applicable to HTTP/1.1, HTTP/2, and gRPC connections.
Field | Type | Required | Description |
http1MaxPendingRequests | Int32 | No | The maximum number of requests that can be queued waiting for a connection to be ready. The default value is 1024. This configuration applies to HTTP/1.1 and HTTP/2. For information about when a new connection is created for HTTP/2, see circuit_breaking. |
http2MaxRequests | Int32 | No | The maximum number of active requests to a destination. The default value is 1024. This configuration applies to HTTP/1.1 and HTTP/2. |
maxRequestsPerConnection | Int32 | No | The maximum number of requests per connection. Setting this parameter to 1 disables HTTP keepalive. The default value is 0, which means no limit. The maximum value is 2^29. |
maxRetries | Int32 | No | The maximum number of retries that can be made to all hosts in a cluster at a given time. The default value is 4294967295. |
idleTimeout | No | The idle timeout for connections in the upstream connection pool. The idle timeout is the period during which there are no active requests. If not set, the default is 1 hour. When the idle timeout is reached, the connection is closed. If the connection is an HTTP/2 connection, a Drain Sequence is sent before the connection is closed. A request-based timeout indicates that an HTTP/2 PING will not keep the connection alive. This configuration applies to HTTP/1.1 and HTTP/2 connections. | |
h2UpgradePolicy | No | Specifies whether to upgrade HTTP/1.1 connections to the corresponding destination to HTTP/2 connections. | |
useClientProtocol | Bool | No | If set to |
ConnectionPoolSettings.TCPSettings.TcpKeepalive
Settings related to TCP keepalive.
Field | Type | Required | Description |
probes | Uint32 | No | The maximum number of keepalive probes to send without a response before determining the connection is dead. The default uses the operating system-level configuration unless overridden. The default for Linux is |
time | No | The duration a connection needs to be idle before keepalive probes start being sent. The default uses the operating system-level configuration unless overridden. The default for Linux is | |
interval | No | The interval between keepalive probes. The default uses the operating system-level configuration unless overridden. The default for Linux is |
google.protobuf.UInt32Value
Wrapper message for Uint32.
Field | Type | Required | Description |
value | Uint32 | No | The Uint32 value. In JSON, |
LoadBalancerSettings.SimpleLB
Standard load balancing algorithms.
Field | Description |
UNSPECIFIED | Does not specify a load balancing algorithm. Istio will choose a suitable default. |
RANDOM | The random load balancing algorithm randomly selects a healthy host. If no health check policy is configured, the random load balancer generally performs better than round robin. |
PASSTHROUGH | This option forwards the connection to the original IP address requested by the caller without any form of load balancing. This is an advanced use case. Use with caution. For more information, see Original destination. |
ROUND_ROBIN | The basic round robin load balancing policy. It is less safe in many scenarios, such as when using endpoint weighting, because it can overload endpoints. In general, it is better to use |
LEAST_REQUEST | The least request load balancer prioritizes endpoints with the fewest outstanding requests when distributing the load. It is generally safer and superior to |
LEAST_CONN | Deprecated. Use |
ConnectionPoolSettings.HTTPSettings.H2UpgradePolicy
Policy for upgrading HTTP/1.1 connections to HTTP/2.
Field | Description |
DEFAULT | Use the global default value. |
DO_NOT_UPGRADE | Do not upgrade the connection to HTTP/2. |
UPGRADE | Upgrade the connection to HTTP/2. |
ClientTLSSettings.TLSmode
TLS connection mode.
Field | Description |
DISABLE | Do not establish a TLS connection to the upstream endpoint. |
SIMPLE | Establish a TLS connection to the upstream endpoint. |
MUTUAL | Secure the connection to the upstream with mutual TLS by providing a client certificate for authentication. |
ISTIO_MUTUAL | Secure the connection to the upstream with mutual TLS by providing a client certificate for authentication. Compared to the |