Configure sidecar proxies

Updated at:

Injecting sidecar proxies into application containers in a cluster enhances the network security, reliability, and observability of service invocations. You can flexibly configure sidecar proxy parameters such as resources, lifecycles, traffic interception policies, and observability capabilities based on your business requirements. This topic describes how to configure sidecar proxies and provides descriptions of the related parameters.

Prerequisites

Sidecar proxy configuration levels

Different sidecar proxy configuration levels represent different effective scopes and priorities. In ascending order of priority, the sidecar proxy configuration levels are global, namespace, workload, and Pod scope.

You can configure the same sidecar proxy at different levels based on your business requirements. ASM determines the parameters that ultimately take effect when a sidecar proxy is injected based on the priority of each sidecar configuration level. For example, you configure the same sidecar proxy at both the namespace level and the global level, and the namespace-level configuration applies to the default namespace. When you deploy a new workload in the default namespace, the injected sidecar proxy uses the namespace-level parameters because the namespace level has a higher priority than the global level.

Sidecar proxy configuration level

Description

Global

The sidecar proxy configuration takes effect globally. The configuration is applied to all Pods when sidecar proxies are injected.

Namespace

The sidecar proxy configuration takes effect in a specified namespace. The configuration is applied only to the Pods in that namespace when sidecar proxies are injected. To configure a sidecar proxy at this level, you must select a namespace.

Workload

The sidecar proxy configuration takes effect on specified workloads. The configuration is applied only to the workloads selected by the specified label selector when sidecar proxies are injected. To configure a sidecar proxy at this level, you must specify a workload label selector to determine which workloads the configuration applies to.

Pod scope

Sidecar proxy configurations at this level cannot be configured in the ASM console. You can configure them by adding annotations to Pods. For more information, see Configure Sidecar Proxy using annotations.

Procedure

The following sections describe how to configure sidecar proxies at different levels. To make a new sidecar proxy configuration take effect on a workload, you must redeploy the Pods. For more information, see Redeploy the workload.

Global level

  1. Log on to the ASM console. In the left-side navigation pane, choose Service Mesh > Mesh Management.

  2. On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose Data Plane Component Management > Configure the agent parameters of the injected Sidecar.

  3. On the Configure the agent parameters of the injected Sidecar page, click the global tab, configure the sidecar parameters as needed, and then click Update Settings.

    For more information about sidecar proxy parameters, see Sidecar proxy parameters.

  4. Check whether the sidecar proxy configuration takes effect.

    1. In the left-side navigation pane, choose Instance Information > Basic Information.

    2. In the Basic Information section, check the Status of the mesh.

      If the Status is Running, the global-level sidecar proxy configuration has taken effect.

Namespace level

  1. Log on to the ASM console. In the left-side navigation pane, choose Service Mesh > Mesh Management.

  2. On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose Data Plane Component Management > Configure the agent parameters of the injected Sidecar.

  3. On the Configure the agent parameters of the injected Sidecar page, click the Namespace tab, select the Namespace in which the configuration takes effect, click the target sidecar configuration, select and configure the required parameters, and then click Update Settings.

    Because the namespace level is not the lowest sidecar proxy configuration level, none of the sidecar proxy parameters has a default value. By default, the parameters use the global-level configuration. After you click Update Settings, the namespace-level sidecar proxy configuration takes effect immediately. For more information about sidecar proxy parameters, see Sidecar proxy parameters.

Workload level

In the same namespace, you can create multiple workload-level sidecar proxy configurations that apply to different workloads.

  1. Log on to the ASM console. In the left-side navigation pane, choose Service Mesh > Mesh Management.

  2. On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose Data Plane Component Management > Configure the agent parameters of the injected Sidecar.

  3. On the Configure the agent parameters of the injected Sidecar page, click the workload tab, and then click Create.

  4. On the workload tab, select the Namespace in which the configuration takes effect, specify the Name of the workload-level sidecar proxy configuration, create a label selector that matches the workload labels in Match Label, click the target sidecar configuration, select and configure the required parameters, and then click Create.

    Because the workload level is not the lowest sidecar proxy configuration level, none of the sidecar proxy parameters has a default value. By default, the parameters use the global-level configuration. After you click Create, the workload-level sidecar proxy configuration is created immediately. For more information about sidecar proxy parameters, see Sidecar proxy parameters.

After the configuration is created, you can also update or delete it.

  • Update a workload-level sidecar proxy configuration: On the workload tab, find the target sidecar proxy configuration and click Update in the Actions column. Modify the Match Label setting and the sidecar proxy configuration as needed, and then click Update.

  • Delete a workload-level sidecar proxy configuration: On the workload tab, find the target sidecar proxy configuration and click Delete in the Actions column. Then, in the Confirm dialog box, click OK.

Pod scope level

To apply a sidecar proxy configuration at the Pod scope level, you must configure specific annotations for the Pod. For more information, see Configure Sidecar Proxy using annotations.

(Optional) Redeploy the workload

The configuration of a Pod that is already deployed cannot be changed, so your sidecar proxy configuration does not take effect immediately. Therefore, after you configure a sidecar proxy, you must redeploy the Pods. After the redeployment, the sidecar proxies injected into the Pods use the new configuration.

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

  2. On the Clusters page, click the name of your cluster. In the left navigation pane, click Workloads > Deployments.

  3. On the Deployments page, perform one of the following operations to redeploy workloads.

    Scenario

    Action

    A single workload

    In the Actions column, choose More > Redeploy for the target workload. Then, in the Redeploy dialog box, click OK.

    Multiple workloads

    In the Name column, select multiple target workloads and click Batch Redeploy at the bottom of the page. Then, in the Confirm dialog box, click OK.

Minimum required versions for sidecar proxy parameters

The features supported by different ASM versions may vary. In most cases, sidecar proxies of later ASM versions provide more features and parameters than earlier versions. If you cannot find a sidecar proxy parameter, refer to the following table to check whether you need to upgrade the ASM version. For more information about how to upgrade the ASM version, see Upgrade an ASM instance.

In the Parameter column of the following table, you can click a link to view the description and configuration example of the parameter.

Important

If your ASM instance runs version 1.22 or later and your data plane cluster runs version 1.30 or later, the sidecar proxy is deployed as a native sidecar container. In this case, the Kubernetes cluster directly manages the lifecycle of the sidecar proxy container and overrides all sidecar proxy parameters of the lifecycle management type.

Type

Parameter

Global level

Namespace level

Workload level

Resource settings

Resource settings for injected Istio proxies

All versions

1.10.5.34

1.13.4.20

Configure sidecar resources by percentage

1.24.6.83

Resource settings for the istio-init init container

1.9.7.93

1.10.5.34

1.13.4.20

ACK dynamic oversold resources for sidecars

1.16.3.47

1.16.3.47

1.16.3.47

Istio-Proxy concurrency

1.15.3.104

1.12.4.19

1.13.4.20

Enable or disable the sidecar proxy by port or address

Address ranges for intercepting outbound traffic

All versions

1.10.5.34

1.13.4.20

Address ranges excluded from outbound traffic interception

All versions

1.10.5.34

1.13.4.20

Ports that route inbound traffic through the sidecar proxy

1.15.3.104

1.10.5.34

1.13.4.20

Ports that route outbound traffic through the sidecar proxy

1.15.3.104

1.10.5.34

1.13.4.20

Ports that bypass the sidecar proxy for inbound traffic

All versions

1.10.5.34

1.13.4.20

Ports that bypass the sidecar proxy for outbound traffic

All versions

1.10.5.34

1.13.4.20

DNS proxy feature

Enable the DNS proxy feature

1.8.3.17

1.10.5.34

1.13.4.20

Sidecar proxy environment variable management

Graceful termination of sidecar proxies (EXIT_ON_ZERO_ACTIVE_CONNECTIONS)

1.15.3.104

1.15.3.104

1.15.3.104

Lifecycle management

Graceful startup of sidecar proxies (HoldApplicationUntilProxyStarts)

1.15.3.104

1.12.4.58

1.13.4.20

Sidecar proxy termination drain duration

1.9.7.93

1.10.5.34

1.13.4.20

Sidecar proxy lifecycle

1.9.7.93

1.10.5.34

1.13.4.20

Access policy for external services

Access policy for external services: OutboundTrafficPolicy

All versions

1.10.5.34

1.13.4.20

Sidecar inbound traffic interception policy

Sidecar inbound traffic interception policy

1.15.3.25

1.15.3.25

1.15.3.25

Monitoring and statistics

Log level

1.15.3.104

1.12.4.58

1.13.4.20

proxyStatsMatcher

1.15.3.104

1.12.4.58

1.13.4.20

Envoy runtime parameters

Downstream connection limit

1.21.6.95

1.21.6.95

1.21.6.95

Sidecar proxy parameters

You can configure the resource usage, traffic interception policies, DNS proxy, and lifecycle of sidecar proxies. The following sections describe the sidecar proxy parameters and provide configuration examples.

Resource settings for injected Istio proxies

Expand to view the description and configuration example of resource settings for injected Istio proxies

Parameter description

This parameter specifies the minimum CPU and memory resources that the sidecar proxy container requires at runtime and the maximum CPU and memory resources that the container can request.

Parameter

Description

Limits on Resources

The maximum CPU and memory resources that the sidecar proxy container can request. CPU resources are measured in cores, and memory resources are measured in MiB.

Required Resources

The minimum CPU and memory resources that the sidecar proxy container requires at runtime. CPU resources are measured in cores, and memory resources are measured in MiB.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click Resource Settings.

  2. (Optional) In the Resource Settings section, select Configure Resources for Injected Sidecar Proxy.

    This step is required on the Namespace and workload tabs. You can skip this step on the global tab.

  3. For Limits on Resources, set CPU to 2 cores and Memory to 1025 MiB. For Required Resources, set CPU to 0.1 cores and Memory to 128 MiB. Then, click Update Settings at the bottom of the page.

  4. Redeploy the workload to make the sidecar proxy configuration take effect.

  5. View the Istio proxy resources that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    ...
    spec:
      containers:
        - args:
            - proxy
    ...
          name: istio-proxy
    ...
          resources:
            limits:
              cpu: '2'
              memory: 1025Mi
            requests:
              cpu: 100m
              memory: 128Mi
    ...

    The istio-proxy container is the sidecar proxy container. If the resources field of the container named istio-proxy in the Pod is set to the target resource values, the Configure Resources for Injected Sidecar Proxy configuration has taken effect.

Configure sidecar resources by percentage

Expand to view the description and configuration example of configuring sidecar resources by percentage

Parameter description

This parameter automatically calculates sidecar resources based on application containers. Enabling this parameter overrides the Resource settings for injected Istio proxies. This feature allocates resources to sidecars based on the maximum resource configuration of application containers, which allows sidecar resources to be dynamically adjusted for different Pods. The following calculation strategies are supported:

  • Maximum container resources: The system goes through all containers in the Pod and uses the largest resource value as the calculation baseline.

  • Specified container name: The system uses the resources of the container with the specified name in the Pod as the calculation baseline. To use this strategy, you must specify a container as the calculation baseline. If the specified container is not found in the Pod, the sidecar resources configured in the Resource settings for injected Istio proxies are used. In addition, if the Pod contains the scaled-resource.inject.istio.alibabacloud.com/container-ref annotation, the container defined in the annotation takes precedence as the calculation baseline.

Important

Regardless of the strategy that you select:

  • If the container used as the calculation baseline does not have limits configured, the system considers the sidecar resources unlimited and does not configure limits for the sidecar.

  • If the container used as the calculation baseline does not have requests configured, the system allocates the minimum viable resources to the sidecar to ensure its normal operation. In this case, the CPU resource in requests is no less than 100m, and the memory resource is no less than 128Mi.

  • Minimum resources required by a sidecar: The CPU resource in requests and limits cannot be lower than 100m, and the memory resource cannot be lower than 128Mi. If the calculated resources are lower than the minimum resources required by the sidecar, the sidecar resources are set to the minimum values.

Configuration example

The following examples show the actual effects of different resource percentages in different scenarios. The sample container configuration is as follows:

Normal application configuration

resources:
  requests:
    cpu: 300m
    memory: 512Mi
  limits:
    cpu: 500m
    memory: 1Gi

No requests configured

resources:
  limits:
    cpu: 500m
    memory: 1Gi

No limits configured

resources:
  requests:
    cpu: 300m
    memory: 512Mi
  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click Resource Settings.

  2. In the Resource Settings section, select Configure sidecar resources by ratio.

  3. Configure Proportion of Resources, select the Computing Policy (optional), and then click Update Settings.

    Select the calculation strategy of Maximum Resource Capacity or Specify a container name. based on your requirements.

  4. Redeploy the workload to make the sidecar proxy configuration take effect.

  5. View the Istio proxy resources that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    Normal application configuration

    Normal configuration

    If the resource percentage is set to 50, which means the sidecar obtains 50% of the resources configured for the application container, the final sidecar resource allocation is as follows:

    ...
    resources:
      requests:
        cpu: 150m
        memory: 256Mi
      limits:
        cpu: 250m
        memory: 512Mi

    Minimum configuration

    If the resource percentage is set to 20, which means the sidecar obtains 20% of the resources configured for the application container, the final sidecar resource allocation is as follows:

    ...
    resources:
      requests:
        cpu: 100m
        memory: 128Mi
      limits:
        cpu: 100m
        memory: 204Mi

    No requests configured

    If the resource percentage is set to 50, which means the sidecar obtains 50% of the resources configured for the application container, the final sidecar resource allocation is as follows:

    ...
    resources:
      requests:
        cpu: 100m
        memory: 128Mi
      limits:
        cpu: 250m
        memory: 512Mi

    No limits configured

    If the resource percentage is set to 50, which means the sidecar obtains 50% of the resources configured for the application container, the final sidecar resource allocation is as follows:

    ...
    resources:
      requests:
        cpu: 150m
        memory: 256Mi

Resource settings for the istio-init init container

Expand to view the description and configuration example of resource settings for the istio-init init container

Parameter description

This parameter specifies the minimum CPU and memory resources that the istio-init container requires at runtime and the maximum CPU and memory resources that the container can request in Pods into which sidecar proxies are injected. The istio-init container is an init container that runs when a Pod with an injected sidecar proxy starts. It configures traffic interception routing rules for the sidecar proxy container.

Parameter

Description

Limits on Resources

The maximum CPU and memory resources that the istio-init container can request. CPU resources are measured in cores, and memory resources are measured in MiB.

Required Resources

The minimum CPU and memory resources that the istio-init container requires at runtime. CPU resources are measured in cores, and memory resources are measured in MiB.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click Resource Settings.

  2. (Optional) In the Resource Settings section, select Configure Resources for istio-init Container.

    This step is required on the Namespace and workload tabs. You can skip this step on the global tab.

  3. For Limits on Resources, set CPU to 1 core and Memory to 512 MiB. For Required Resources, set CPU to 0.1 cores and Memory to 128 MiB. Then, click Update Settings at the bottom of the page.

  4. Redeploy the workload to make the sidecar proxy configuration take effect.

  5. View the istio-init init container resources that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    ...
    spec:
    ...
      initContainers:
        - args:
    ...
          name: istio-init
          resources:
            limits:
              cpu: '1'
              memory: 512Mi
            requests:
              cpu: 100m
              memory: 128Mi
    ...

    If the resources field of the init container named istio-init in the Pod is set to the target resource values, the Configure Resources for istio-init Container configuration has taken effect.

ACK dynamic oversold resources for sidecars

Expand to view the description and configuration example of ACK dynamic oversold resources for sidecars

Parameter description

This parameter specifies the ACK dynamic oversold resources allocated to the injected Istio proxy and the istio-init init container. For more information about dynamic oversold resources, see Enable dynamic resource overcommitment.

This parameter is configured in the same way as the Resource settings for injected Istio proxies and the Resource settings for the istio-init init container. After the configuration, if a Pod has the ACK dynamic resource overselling label koordinator.sh/qosClass, ACK dynamic oversold resources are allocated to the Istio proxy and the istio-init init container in the Pod, instead of regular Kubernetes CPU and memory resources.

Note

When you configure ACK dynamic oversold resources for sidecars, CPU resources are measured in millicores.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, click Resource Settings, select Set ACK Resources That Can Be Dynamically Overcommitted for Sidecar Proxy, configure the related parameters, and then click Update Settings at the bottom of the page.

    Parameter

    Sub-parameter

    Description

    Configure Resources for Injected Sidecar Proxy (ACK Dynamically Overcommitted Resources)

    Limits on Resources

    Set CPU to 2000 millicores and Memory to 2048 MiB.

    Required Resources

    Set CPU to 200 millicores and Memory to 256 MiB.

    istio-init container resource (ACK dynamic oversold resource)

    Limits on Resources

    Set CPU to 1000 millicores and Memory to 1024 MiB.

    Required Resources

    Set CPU to 100 millicores and Memory to 128 MiB.

  2. Redeploy the workload to make the sidecar proxy configuration take effect.

  3. Run the following command to view the istio-init init container resources that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    metadata:
    ...
      labels:
        koordinator.sh/qosClass: BE
    spec:
      containers:
        - args:
    ...
          name: istio-proxy
    ...
          resources:
            limits:
              kubernetes.io/batch-cpu: 2k
              kubernetes.io/batch-memory: 2Gi
            requests:
              kubernetes.io/batch-cpu: '200'
              kubernetes.io/batch-memory: 256Mi
    ...
      initContainers:
        - args:
    ...
          name: istio-init
          resources:
            limits:
              kubernetes.io/batch-cpu: 1k
              kubernetes.io/batch-memory: 1Gi
            requests:
              kubernetes.io/batch-cpu: '100'
              kubernetes.io/batch-memory: 128Mi
    ...

    The istio-proxy container (Istio proxy container) and the istio-init init container in the Pod both contain the resources field set to the target resource values. This indicates that the Set ACK Resources That Can Be Dynamically Overcommitted for Sidecar Proxy configuration has taken effect.

Istio-Proxy concurrency

Expand to view the description and configuration example of Istio-Proxy concurrency

Parameter description

This parameter specifies the number of worker threads of the sidecar proxy container. You must specify a non-negative integer as the number of worker threads. If you set this parameter to 0, the number of worker threads is automatically determined based on the requested CPU resources or the CPU resource limit configured for the sidecar proxy. The resource limit takes precedence over the requested resources.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click Resource Settings.

  2. (Optional) In the Resource Settings section, select Number of Sidecar Proxy Threads.

    This step is required on the Namespace and workload tabs. You can skip this step on the global tab.

  3. Set Number of Sidecar Proxy Threads to 3, and then click Update Settings at the bottom of the page.

    This configuration indicates that the sidecar proxy container runs three worker threads at runtime.

  4. Redeploy the workload to make the sidecar proxy configuration take effect.

  5. Run the following command to view the Istio-Proxy concurrency that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    ...
    spec:
    ...
        - args:
            - proxy
            - sidecar
            - '--domain'
            - $(POD_NAMESPACE).svc.cluster.local
            - '--proxyLogLevel=warning'
            - '--proxyComponentLogLevel=misc:error'
            - '--log_output_level=default:info'
            - '--concurrency'
            - '3'
    ...
          name: istio-proxy
    ...

    The concurrency parameter of the istio-proxy container is set to 3. This indicates that the Number of Sidecar Proxy Threads configuration has taken effect.

Address ranges for intercepting outbound traffic

Expand to view the description and configuration example of address ranges for intercepting outbound traffic

Parameter description

You must specify a list of IP address ranges separated by commas (,). Each IP address range is in CIDR notation. When a workload with an injected sidecar proxy accesses other services, only the requests whose destination IP addresses fall within the configured address ranges are intercepted by the sidecar proxy container. Other requests are sent directly to the destinations without going through the sidecar proxy. By default, this parameter is set to *, which indicates that the sidecar proxy container intercepts all outbound traffic of the workload.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click Enable/Disable Sidecar Proxy by Ports or IP Addresses.

  2. (Optional) In the Enable/Disable Sidecar Proxy by Ports or IP Addresses section, select Addresses to Which External Access Is Redirected to Sidecar Proxy.

    This step is required on the Namespace and workload tabs. You can skip this step on the global tab.

  3. Set Addresses to Which External Access Is Redirected to Sidecar Proxy to 192.168.0.0/16,10.1.0.0/24, and then click Update Settings at the bottom of the page.

    This configuration indicates that the sidecar proxy container intercepts requests whose destination IP addresses fall within the two CIDR blocks 192.168.0.0/16 and 10.1.0.0/24.

  4. Redeploy the workload to make the sidecar proxy configuration take effect.

  5. Run the following command to view the address ranges for intercepting outbound traffic that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    ...
    spec:
    ...
      initContainers:
        - args:
            - istio-iptables
            - '-p'
            - '15001'
            - '-z'
            - '15006'
            - '-u'
            - '1337'
            - '-m'
            - REDIRECT
            - '-i'
            - '192.168.0.0/16,10.1.0.0/24'
            - '-x'
            - 192.168.0.1/32
            - '-b'
            - '*'
            - '-d'
            - '15090,15021,15081,9191,15020'
            - '--log_output_level=default:info'
    ...
          name: istio-init
    ...

    The runtime parameters of the istio-init container include -i 192.168.0.0/16,10.1.0.0/24. This indicates that the Addresses to Which External Access Is Redirected to Sidecar Proxy configuration has taken effect.

Address ranges excluded from outbound traffic interception

Expand to view the description and configuration example of address ranges excluded from outbound traffic interception

Parameter description

You must specify a list of IP address ranges separated by commas (,). Each IP address range is in CIDR notation. When a workload with an injected sidecar proxy accesses other services, the sidecar proxy container intercepts the outbound traffic. If the destination IP address of a request falls within a CIDR block configured for this parameter, the request is not intercepted by the sidecar proxy container.

Important

If the address ranges excluded from outbound traffic interception contain the address specified by Addresses to Which External Access Is Redirected to Sidecar Proxy, requests to this address are not intercepted by the sidecar proxy. For more information, see Address ranges for intercepting outbound traffic.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click Enable/Disable Sidecar Proxy by Ports or IP Addresses.

  2. (Optional) In the Enable/Disable Sidecar Proxy by Ports or IP Addresses section, select Addresses to Which External Access Is Not Redirected to Sidecar Proxy.

    This step is required on the Namespace and workload tabs. You can skip this step on the global tab.

  3. Set Addresses to Which External Access Is Not Redirected to Sidecar Proxy to 10.1.0.0/24, and then click Update Settings at the bottom of the page.

    This configuration indicates that the sidecar proxy container does not intercept requests whose destination IP addresses fall within the CIDR block 10.1.0.0/24.

  4. Redeploy the workload to make the sidecar proxy configuration take effect.

  5. Run the following command to view the address ranges excluded from outbound traffic interception that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    ...
    spec:
    ...
      initContainers:
        - args:
            - istio-iptables
            - '-p'
            - '15001'
            - '-z'
            - '15006'
            - '-u'
            - '1337'
            - '-m'
            - REDIRECT
            - '-i'
            - '*'
            - '-x'
            - '192.168.0.1/32,10.1.0.0/24'
            - '-b'
            - '*'
            - '-d'
            - '15090,15021,15081,9191,15020'
            - '--log_output_level=default:info'
    ...
          name: istio-init
    ...

    The runtime parameters of the istio-init container include -x 192.168.0.1/32,10.1.0.0/24. 192.168.0.1/32 is the default host address CIDR block. 10.1.0.0/24 matches the IP address range configured for the sidecar proxy. This indicates that the Addresses to Which External Access Is Not Redirected to Sidecar Proxy configuration has taken effect.

Ports that route inbound traffic through the sidecar proxy

Expand to view the description and configuration example of ports that route inbound traffic through the sidecar proxy

Parameter description

You must specify a list of ports separated by commas (,). Traffic destined for the ports in the list is intercepted by the sidecar proxy container. By default, this parameter is set to *, which indicates that the sidecar proxy container intercepts all inbound traffic of the workload.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click Enable/Disable Sidecar Proxy by Ports or IP Addresses.

  2. (Optional) In the Enable/Disable Sidecar Proxy by Ports or IP Addresses section, select Ports on Which Inbound Traffic Redirected to Sidecar Proxy.

    This step is required on the Namespace and workload tabs. You can skip this step on the global tab.

  3. Set Ports on Which Inbound Traffic Redirected to Sidecar Proxy to 80,443, and then click Update Settings.

    This configuration indicates that the sidecar proxy container intercepts only the requests sent to port 80 and port 443 of the workload.

  4. Redeploy the workload to make the sidecar proxy configuration take effect.

  5. Run the following command to view the inbound traffic interception ports that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    ...
    spec:
    ...
      initContainers:
        - args:
            - istio-iptables
            - '-p'
            - '15001'
            - '-z'
            - '15006'
            - '-u'
            - '1337'
            - '-m'
            - REDIRECT
            - '-i'
            - '*'
            - '-x'
            - 192.168.0.1/32
            - '-b'
            - '80,443'
            - '-d'
            - '15090,15021,15081,9191,15020'
            - '--log_output_level=default:info'
    ...
          name: istio-init
    ...
                                

    The runtime parameters of the istio-init container include -b 80,443, which matches the inbound ports configured for the sidecar proxy. This indicates that the Ports on Which Inbound Traffic Redirected to Sidecar Proxy configuration has taken effect.

Ports that route outbound traffic through the sidecar proxy

Expand to view the description and configuration example of ports that route outbound traffic through the sidecar proxy

Parameter description

You must specify a list of ports separated by commas (,), which represents the destination service ports of all outbound traffic. Requests whose destination service ports are in the list are intercepted by the sidecar proxy container.

Important

If this parameter is configured together with Addresses to Which External Access Is Not Redirected to Sidecar Proxy or Ports on Which Outbound Traffic Not Redirected to Sidecar Proxy, and the destination IP address of a request falls within a non-intercepted CIDR block or the destination service port of the request is in the non-intercepted port list, the request is not intercepted by the sidecar proxy even if the destination port is in the list of this parameter. For more information, see Address ranges excluded from outbound traffic interception and Ports that bypass the sidecar proxy for outbound traffic.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click Enable/Disable Sidecar Proxy by Ports or IP Addresses.

  2. (Optional) In the Enable/Disable Sidecar Proxy by Ports or IP Addresses section, select Ports on Which Outbound Traffic Redirected to Sidecar Proxy.

    This step is required on the Namespace and workload tabs. You can skip this step on the global tab.

  3. Set Ports on Which Outbound Traffic Redirected to Sidecar Proxy to 80,443, and then click Update Settings at the bottom of the page.

    This configuration indicates that the sidecar proxy container intercepts requests sent to services on port 80 and port 443.

  4. Redeploy the workload to make the sidecar proxy configuration take effect.

  5. Run the following command to view the outbound traffic interception ports that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    ...
    spec:
    ...
      initContainers:
        - args:
            - istio-iptables
            - '-p'
            - '15001'
            - '-z'
            - '15006'
            - '-u'
            - '1337'
            - '-m'
            - REDIRECT
            - '-i'
            - '*'
            - '-x'
            - 192.168.0.1/32
            - '-b'
            - '*'
            - '-d'
            - '15090,15021,15081,9191,15020'
            - '--log_output_level=default:info'
            - '-q'
            - '80,443'
            - '--log_output_level=default:info'
    ...
          name: istio-init
    ...
                                

    The runtime parameters of the istio-init container include -q 80,443, which matches the outbound ports configured for the sidecar proxy. This indicates that the Ports on Which Outbound Traffic Redirected to Sidecar Proxy configuration has taken effect.

Ports that bypass the sidecar proxy for inbound traffic

Expand to view the description and configuration example of ports that bypass the sidecar proxy for inbound traffic

Parameter description

You must specify a list of ports separated by commas (,). Traffic destined for the ports in the list is not intercepted by the sidecar proxy container.

Important

This parameter takes effect only when Ports on Which Inbound Traffic Redirected to Sidecar Proxy is set to *, which means the sidecar proxy container intercepts all inbound traffic by default.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click Enable/Disable Sidecar Proxy by Ports or IP Addresses.

  2. (Optional) In the Enable/Disable Sidecar Proxy by Ports or IP Addresses section, select Ports on Which Inbound Traffic Not Redirected to Sidecar Proxy.

    This step is required on the Namespace and workload tabs. You can skip this step on the global tab.

  3. Set Ports on Which Inbound Traffic Not Redirected to Sidecar Proxy to 8000, and then click Update Settings at the bottom of the page.

    This configuration indicates that the sidecar proxy container no longer intercepts requests sent to port 8000 of the workload.

  4. Redeploy the workload to make the sidecar proxy configuration take effect.

  5. Run the following command to view the inbound traffic bypass ports that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    ...
    spec:
    ...
      initContainers:
        - args:
            - istio-iptables
            - '-p'
            - '15001'
            - '-z'
            - '15006'
            - '-u'
            - '1337'
            - '-m'
            - REDIRECT
            - '-i'
            - '*'
            - '-x'
            - 192.168.0.1/32
            - '-b'
            - '*'
            - '-d'
            - '15090,15021,15081,9191,15020,8000'
            - '--log_output_level=default:info'
    ...
          name: istio-init
    ...
                                

    The runtime parameters of the istio-init container include -d 15090,15021,15081,9191,8000. The ports 15090,15021,15081,9191 are the application ports of the sidecar proxy and are excluded from interception by default. The port 8000 matches the inbound ports configured for the sidecar proxy. This indicates that the Ports on Which Inbound Traffic Not Redirected to Sidecar Proxy configuration has taken effect.

Ports that bypass the sidecar proxy for outbound traffic

Expand to view the description and configuration example of ports that bypass the sidecar proxy for outbound traffic

Parameter description

You must specify a list of ports separated by commas (,), which represents the destination service ports of all outbound traffic. Requests whose destination service ports are in the list are not intercepted by the sidecar proxy container, regardless of whether the destination IP address falls within the intercepted outbound address ranges or whether the destination port is in the intercepted outbound port list.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click Enable/Disable Sidecar Proxy by Ports or IP Addresses.

  2. (Optional) In the Enable/Disable Sidecar Proxy by Ports or IP Addresses section, select Ports on Which Outbound Traffic Not Redirected to Sidecar Proxy.

    This step is required on the Namespace and workload tabs. You can skip this step on the global tab.

  3. Set Ports on Which Outbound Traffic Not Redirected to Sidecar Proxy to 8000, and then click Update Configurations at the bottom of the page.

    This configuration indicates that the sidecar proxy container no longer intercepts requests sent to services on port 8000.

  4. Redeploy the workload to make the sidecar proxy configuration take effect.

  5. Run the following command to view the outbound traffic bypass ports that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    ...
    spec:
    ...
      initContainers:
        - args:
            - istio-iptables
            - '-p'
            - '15001'
            - '-z'
            - '15006'
            - '-u'
            - '1337'
            - '-m'
            - REDIRECT
            - '-i'
            - '*'
            - '-x'
            - 192.168.0.1/32
            - '-b'
            - '*'
            - '-d'
            - '15090,15021,15081,9191,15020'
            - '--log_output_level=default:info'
            - '-o'
            - '8000'
    ...
          name: istio-init
    ...
                                

    The runtime parameters of the istio-init container include -o 8000, which matches the outbound ports configured for the sidecar proxy. This indicates that the Ports on Which Outbound Traffic Not Redirected to Sidecar Proxy configuration has taken effect.

Enable the DNS proxy feature

Expand to view the description and configuration example of the DNS proxy feature

Parameter description

You can enable or disable the DNS proxy feature for sidecar proxy containers. After the DNS proxy feature is enabled, sidecar proxy containers intercept the DNS requests of workloads to improve the performance and availability of Service Mesh. All requests from workloads are redirected to the sidecar proxy container. Because sidecar proxy containers store the mappings between IP addresses and local domain names locally, they can directly return DNS responses to workloads without sending requests to remote DNS services. If a DNS request cannot be handled by the sidecar proxy container, the sidecar directly forwards the DNS request. For more information, see Use DNS proxy in ASM.

Important

Due to network permission issues, the DNS proxy feature cannot be enabled for sidecar proxy containers in ACK clusters with ACK Serverless cluster or ECI Pods.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click DNS Proxy.

  2. (Optional) In the DNS Proxy section, select Enable DNS Proxy, turn on the switch on the right, and then click Update Settings.

    This step is required on the Namespace and workload tabs. You can skip this step on the global tab. Turning on the switch enables the DNS proxy feature for the sidecar proxy.

  3. Redeploy the workload to make the sidecar proxy configuration take effect.

  4. Run the following command to view the DNS proxy feature that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    spec:
      containers:
        - args:
            - proxy
            - sidecar
            - '--domain'
            - $(POD_NAMESPACE).svc.cluster.local
            - '--proxyLogLevel=warning'
            - '--proxyComponentLogLevel=misc:error'
            - '--log_output_level=default:info'
            - '--concurrency'
            - '3'
          env:
    ...
            - name: ISTIO_META_DNS_AUTO_ALLOCATE
              value: 'true'
            - name: ISTIO_META_DNS_CAPTURE
              value: 'true'
    ...
          name: istio-proxy
                                

    The ISTIO_META_DNS_AUTO_ALLOCATE and ISTIO_META_DNS_CAPTURE environment variables of the istio-proxy container are set to true. This indicates that the DNS Proxy configuration has taken effect.

Sidecar proxy environment variable management

Expand to view the description and configuration example of sidecar proxy environment variable management

Parameter description

This parameter specifies additional environment variables added to sidecar proxy containers. You can configure the following two types of sidecar proxy environment variables.

Parameter

Description

Sidecar Graceful Shutdown (EXIT_ON_ZERO_ACTIVE_CONNECTIONS)

After this parameter is enabled, the environment variable EXIT_ON_ZERO_ACTIVE_CONNECTIONS: "true" is added to the sidecar proxy container. The environment variable works as follows:

By default, when a sidecar proxy container stops, the pilot-agent process in the container stops the Envoy proxy from listening to inbound traffic, waits for a period of time determined by the sidecar proxy termination drain duration parameter, and then stops the Envoy proxy process.

After EXIT_ON_ZERO_ACTIVE_CONNECTIONS is set, when the sidecar proxy container stops, the pilot-agent process in the container first stops the Envoy proxy from listening to inbound traffic and waits for 5 seconds by default. After the wait, the process polls the number of active connections of the Envoy proxy and stops the Envoy proxy process only after the number of active connections becomes 0. Setting EXIT_ON_ZERO_ACTIVE_CONNECTIONS improves the termination lifecycle of sidecar proxy containers in common cases by reducing both the termination time and the number of requests dropped during termination.

Important

After this parameter is configured, Sidecar Proxy Drain Duration at Pod Termination no longer takes effect. For more information, see Sidecar proxy termination drain duration.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click Manage Environment Variables for Sidecar Proxy.

  2. (Optional) In the Manage Environment Variables for Sidecar Proxy section, select Sidecar Graceful Shutdown (EXIT_ON_ZERO_ACTIVE_CONNECTIONS).

    This step is required on the Namespace and workload tabs. You can skip this step on the global tab.

  3. Turn on the switch on the right of Sidecar Graceful Shutdown (EXIT_ON_ZERO_ACTIVE_CONNECTIONS), and then click Update Configurations.

  4. Redeploy the workload to make the sidecar proxy configuration take effect.

  5. Run the following command to view the environment variables of the sidecar proxy that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    ...
    spec:
      containers:
        - args:
    ...
          env:
            - name: EXIT_ON_ZERO_ACTIVE_CONNECTIONS
              value: 'true'
          name: istio-proxy
    ...

    The EXIT_ON_ZERO_ACTIVE_CONNECTIONS environment variable is added to the sidecar environment variables of the istio-proxy container in the Pod. This indicates that the Manage Environment Variables for Sidecar Proxy configuration has taken effect.

Graceful startup of sidecar proxies (HoldApplicationUntilProxyStarts)

Expand to view the description and configuration example of HoldApplicationUntilProxyStarts

Parameter description

HoldApplicationUntilProxyStarts is a lifecycle management parameter for sidecar proxies. HoldApplicationUntilProxyStarts is enabled by default, which means that for a Pod with an injected sidecar proxy, the sidecar proxy container must start successfully before the application containers in the Pod start. This ensures that traffic sent to the application containers is not lost because the sidecar proxy has not finished starting.

If this parameter is disabled, the sidecar proxy container and the application containers in the Pod start at the same time. When a large number of Pods are deployed in a cluster, sidecar proxy containers may start slowly due to heavy load on the APIServer. You can disable HoldApplicationUntilProxyStarts to speed up the deployment.

Configuration example

The following example shows how to disable HoldApplicationUntilProxyStarts on the global tab.

  1. On the Configure the agent parameters of the injected Sidecar page, click the global tab, and then click Lifecycle Management.

  2. Turn off the switch on the right of Sidecar Graceful Startup (HoldApplicationUntilProxyStarts), and then click Update Settings.

    This configuration indicates that the HoldApplicationUntilProxyStarts capability is disabled.

  3. Redeploy the workload to make the sidecar proxy configuration take effect.

  4. Run the following command to view the HoldApplicationUntilProxyStarts setting.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    ...
    spec:
      containers:
        - command:
    ...
          name: sleep
    ...
          env:
            - name: PROXY_CONFIG
              value: >-
                {..."holdApplicationUntilProxyStarts":false,...}
    ...
          name: istio-proxy
    ...

    After the holdApplicationUntilProxyStarts capability is disabled, the istio-proxy container is no longer forcibly declared before the application containers, and the default lifecycle field is no longer declared. In this case, Service Mesh no longer ensures that the sidecar proxy container starts successfully before the application containers start.

Sidecar proxy termination drain duration

Expand to view the description and configuration example of the sidecar proxy termination drain duration

Parameter description

The sidecar proxy termination drain duration is a lifecycle management parameter for sidecar proxies. After a sidecar proxy is injected into a Pod, the traffic of the application Pod is intercepted by the sidecar proxy container.

When a Pod starts to stop, the corresponding Service no longer forwards traffic to the Pod. After the sidecar proxy container receives the exit signal, it waits for a period of time. During this period, the container stops accepting new inbound traffic but continues to process existing inbound traffic. Outbound traffic is not affected and can still be sent normally. This period is called the sidecar proxy termination drain duration. The default termination drain duration of sidecar proxy containers is 5s. You can configure a duration in s, such as 10s.

If the interface calls provided by the stopped service take a long time and exceed the termination drain duration of the sidecar proxy container, existing inbound and outbound connections are terminated even if they have not been fully processed, which may cause some requests to be lost. In this case, you can use this parameter to extend the sidecar proxy termination drain duration so that inbound and outbound traffic can be fully processed.

The sidecar proxy termination drain duration must be specified in seconds with the unit s, such as 10s.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click Lifecycle Management.

  2. (Optional) In the Lifecycle Management section, select Sidecar Proxy Drain Duration at Pod Termination.

    This step is required on the Namespace and workload tabs. You can skip this step on the global tab.

  3. Set Sidecar Proxy Drain Duration at Pod Termination to 10s, and then click Update Settings.

    This configuration indicates that the sidecar proxy waits 10 seconds to process existing connections during termination.

  4. Redeploy the workload to make the sidecar proxy configuration take effect.

  5. Run the following command to view the sidecar proxy termination drain duration that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    ...
    spec:
      containers:
        - args:
    ...
          env:
            - name: TERMINATION_DRAIN_DURATION_SECONDS
              value: '10'
    ...
            - name: PROXY_CONFIG
              value: >-
                {..."terminationDrainDuration":"10s"}
    ...
          name: istio-proxy
    ...

    The istio-proxy container in the Pod is configured with the TERMINATION_DRAIN_DURATION_SECONDS environment variable set to 10, and the PROXY_CONFIG environment variable records terminationDrainDuration as 10s. This indicates that the Sidecar Proxy Drain Duration at Pod Termination configuration has taken effect.

Sidecar proxy lifecycle

Expand to view the description and configuration example of the sidecar proxy lifecycle

Parameter description

The sidecar proxy lifecycle parameter allows you to fully customize the container lifecycle hooks of sidecar proxy containers. For this parameter, you must enter a container lifecycle hook field (lifecycle) declared in JSON format. This field replaces the default container lifecycle hook field of the sidecar proxy container. For more information, see Container lifecycle hooks.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click Lifecycle Management.

  2. (Optional) In the Lifecycle Management section, select Lifecycle of Sidecar Proxy.

    This step is required on the Namespace and workload tabs. You can skip this step on the global tab.

  3. Under Lifecycle of Sidecar Proxy, enter the following YAML content, and then click Update Settings.

    This YAML content configures the postStart and preStop hook parameters.

    • postStart: waits for pilot-agent to start after the sidecar container starts.

    • preStop: sleeps for 13 seconds before the sidecar container stops.

    {
      "postStart": {
        "exec": {
          "command": [
            "pilot-agent",
            "wait"
          ]
        }
      },
      "preStop": {
        "exec": {
          "command": [
            "/bin/sh",
            "-c",
            "sleep 13"
          ]
        }
      }
    }
  4. Redeploy the workload to make the sidecar proxy configuration take effect.

  5. Run the following command to view the sidecar proxy lifecycle that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    ...
    spec:
      containers:
        - args:
    ...
    ...
            lifecycle:
            postStart:
              exec:
                command:
                - pilot-agent
                - wait
            preStop:
              exec:
                command:
                - /bin/sh
                - -c
                - sleep 13
          name: istio-proxy
    ...

    The container lifecycle hook field (lifecycle) of the istio-proxy container in the Pod is changed to the target configuration. This indicates that the Lifecycle of Sidecar Proxy configuration has taken effect.

Access policy for external services

Expand to view the description and configuration example of the access policy for external services

Parameter description

This parameter specifies the access policy of sidecar proxy containers for external services. External services are services outside the mesh that are not registered with Service Mesh. By default, all services in the Kubernetes clusters managed by Service Mesh are registered services. You can manually register services with Service Mesh by declaring ServiceEntry resources. Services that are not registered are considered external services.

This parameter supports the following two policies:

  • ALLOW_ANY: the default access policy for external services. The sidecar proxy allows access to external services and forwards requests to external services as is.

  • REGISTRY_ONLY: The sidecar proxy denies access to external services, and workloads cannot establish connections to external services.

Note

This parameter is a global configuration and can only be set at the global level. To set the access policy for external services at the namespace or workload level, log on to the ASM console and configure it on the Traffic Management Center > Sidecar Traffic Configuration page.

Configuration example

  1. On the global tab of the Configure the agent parameters of the injected Sidecar page, click Outbound Traffic Policy, select REGISTRY_ONLY on the right of Outbound Traffic Policy, and then click Update Settings.

    This configuration restricts services in the mesh from accessing external services.

  2. Redeploy the workload to make the sidecar proxy configuration take effect.

  3. Create sleep.yaml with the following content.

    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: sleep
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: sleep
      labels:
        app: sleep
        service: sleep
    spec:
      ports:
      - port: 80
        name: http
      selector:
        app: sleep
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: sleep
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: sleep
      template:
        metadata:
          labels:
            app: sleep
        spec:
          terminationGracePeriodSeconds: 0
          serviceAccountName: sleep
          containers:
          - name: sleep
            image: curlimages/curl
            command: ["/bin/sleep", "3650d"]
            imagePullPolicy: IfNotPresent
            volumeMounts:
            - mountPath: /etc/sleep/tls
              name: secret-volume
          volumes:
          - name: secret-volume
            secret:
              secretName: sleep-secret
              optional: true
    ---
  4. Run the following command to deploy the sleep application.

    kubectl apply -f sleep.yaml -n default
  5. Run the following command to use the sleep application to access an external service.

    kubectl exec -it {sleep-pod-name} -c sleep -- curl www.aliyun.com -v

    Expected output:

    *   Trying *********...
    * Connected to www.aliyun.com (********) port 80 (#0)
    > GET / HTTP/1.1
    > Host: www.aliyun.com
    > User-Agent: curl/7.87.0-DEV
    > Accept: */*
    >
    * Mark bundle as not supporting multiuse
    < HTTP/1.1 502 Bad Gateway
    < date: Mon,********* 03:25:00 GMT
    < server: envoy
    < content-length: 0
    <
    * Connection #0 to host www.aliyun.com left intact

    The 502 response indicates that the sleep application with an injected sidecar proxy cannot access the external service www.aliyun.com. This indicates that the Outbound Traffic Policy configuration has taken effect.

Sidecar inbound traffic interception policy

Expand to view the description and configuration example of the sidecar inbound traffic interception policy

Parameter description

This parameter specifies the interception policy of sidecar proxies for inbound traffic. By default, sidecar proxy containers use the iptables REDIRECT policy to intercept inbound traffic sent to application workloads. After inbound traffic is intercepted by redirection, the application can only see the IP address of the sidecar proxy container as the source IP address of requests and cannot see the original IP address of the client.

If you change the inbound traffic interception policy to the transparent proxy (TPROXY) policy, Service Mesh allows sidecar proxy containers to intercept inbound traffic in the iptables transparent proxy mode. After this parameter is configured, the application can see the original IP address of the client. For more information, see Obtain client source IP in Service Mesh.

Important

The transparent proxy policy does not support nodes that run CentOS. If the nodes where your Pods run use CentOS, use the REDIRECT policy.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click Sidecar Traffic Interception Mode.

  2. (Optional) In the Sidecar Traffic Interception Mode section, select Sidecar Traffic Interception Mode.

    This step is required on the Namespace and workload tabs. You can skip this step on the global tab.

  3. On the right of Sidecar Traffic Interception Mode, select TPROXY, and then click Update Settings.

  4. Redeploy the workload to make the sidecar proxy configuration take effect.

  5. Run the following command to view the sidecar inbound traffic interception policy that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    ...
    spec:
      containers:
        - args:
    ...
            - name: PROXY_CONFIG
              value: >-
                {..."interceptionMode":"TPROXY",...}
            - name: ISTIO_META_POD_PORTS
              value: |-
                [
                ]
    ...
          name: istio-proxy
    ...
      initContainers:
        - args:
            - istio-iptables
            - '-p'
            - '15001'
            - '-z'
            - '15006'
            - '-u'
            - '1337'
            - '-m'
            - TPROXY
    ...
          name: istio-init
    ...

    The sidecar environment variables of the istio-proxy container in the Pod record "interceptionMode":"TPROXY", and the istio-init container also runs the initialization command with the TPROXY parameter. This indicates that the Sidecar Traffic Interception Mode configuration has taken effect.

Log level

Expand to view the description and configuration example of the log level

Parameter description

This parameter specifies the log level of sidecar proxy containers. By default, sidecar proxies use the info log level. You can change the log level of sidecar proxies to any of the seven levels info, debug, trace, warning, error, critical, and off to obtain more or less log information from sidecar proxies.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click Monitoring Statistics.

  2. (Optional) In the Monitoring Statistics section, select Log Level.

    This step is required on the Namespace and workload tabs. You can skip this step on the global tab.

  3. On the right of Log Level, select error, and then click Update Settings.

    This configuration indicates that the sidecar proxy outputs logs at the error level, and only logs at the error level or higher are output.

  4. Redeploy the workload to make the sidecar proxy configuration take effect.

  5. Run the following command to view the sidecar proxy log level that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    ...
    spec:
      containers:
        - args:
            - proxy
            - sidecar
            - '--domain'
            - $(POD_NAMESPACE).svc.cluster.local
            - '--proxyLogLevel=error'
    ...
          name: istio-proxy
    ...

    The runtime parameters of the istio-proxy container are set to --proxyLogLevel=error. This indicates that the Log Level configuration has taken effect.

proxyStatsMatcher

Expand to view the description and configuration example of proxyStatsMatcher

Parameter description

This parameter defines the custom Envoy statistics reported by sidecar proxies. Envoy is the technical implementation of sidecar proxies and can collect and report a series of metrics. However, Service Mesh enables the collection and exposure of only some metrics by default to reduce the performance overhead on sidecar proxies. You can use this parameter to specify additional metrics that sidecar proxies need to collect and report by prefix matching, suffix matching, or regular expression matching.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click Monitoring Statistics.

  2. In the Monitoring Statistics section, select proxyStatsMatcher, select Regular Expression Match, and then set it to .*outlier_detection.*.

    This configuration adds the collection of circuit breaking metrics for the sidecar proxy.

  3. Redeploy the workload to make the sidecar proxy configuration take effect.

  4. Run the following command to view the custom statistics of the sidecar proxy that you configured.

    kubectl get pod -n <namespace> <pod-name> -o yaml

    Expected output:

    apiVersion: v1
    kind: Pod
    ...
    spec:
      containers:
        - args:
     ...
            - name: PROXY_CONFIG
              value: >-
                {..."proxyStatsMatcher":{"inclusionRegexps":[".*outlier_detection.*"]},...}
    ...

    The custom statistics in the sidecar environment variables of the istio-proxy container in the Pod have been updated. This indicates that the proxyStatsMatcher configuration has taken effect.

Envoy runtime parameters

Expand to view the description and configuration example of Envoy runtime parameters

Parameter description

This parameter specifies the runtime parameters of the Envoy process in sidecar proxy containers. You can configure the following runtime parameter.

Parameter

Description

Downstream connection limit

By default, sidecar proxies have no limit on the number of downstream connections, which may be exploited by malicious activities. For more information, see security bulletin 2020-007. You can configure the maximum number of downstream connections that a sidecar proxy can accept based on your business requirements.

Configuration example

  1. On the Configure the agent parameters of the injected Sidecar page, click the tab for the target sidecar proxy configuration level, and then click Manage Environment Variables for Sidecar Proxy.

  2. (Optional) In the Envoy Runtime Parameters section, enter 5000 in the input field on the right of Limits on Downstream Connections, and then click Update Configurations.

  3. Redeploy the workload to make the sidecar proxy configuration take effect.

  4. Run the following command to view the environment variables of the sidecar proxy that you configured.

kubectl get pod -n <namespace> <pod-name> -o yaml

Expected output:

apiVersion: v1
kind: Pod
...
spec:
  containers:
    - args:
...
      env:
        - name: PROXY_CONFIG
          value: >-
            {"concurrency":2,"configPath":"/etc/istio/proxy","discoveryAddress":"istiod-1-22-6.istio-system.svc:15012","holdApplicationUntilProxyStarts":true,"interceptionMode":"REDIRECT","proxyMetadata":{"BOOTSTRAP_XDS_AGENT":"false","DNS_AGENT":"","EXIT_ON_ZERO_ACTIVE_CONNECTIONS":"true"},"runtimeValues":{"overload.global_downstream_max_connections":"5000"},"terminationDrainDuration":"5s","tracing":{"zipkin":{"address":"zipkin.istio-system:9411"}}}
      name: istio-proxy
...

The "runtimeValues":{"overload.global_downstream_max_connections":"5000"} field is added to the PROXY_CONFIG environment variable in the sidecar configuration of the istio-proxy container in the Pod. This indicates that the Envoy runtime parameters configuration has taken effect.