Alibaba Cloud Service Mesh (ASM) allows you to add a Container Service for Kubernetes (ACK) cluster to an ASM instance. To make full use of ASM, you must inject a sidecar proxy into the pod of an application that is deployed in the ACK cluster. ASM supports both manual and automatic sidecar injection. We recommend that you enable automatic sidecar injection because it requires simpler operations than manual sidecar injection. This topic describes the methods that can be used to enable automatic sidecar injection.
Background information
Enable automatic sidecar injection
Other settings of automatic sidecar injection
- Set the
alwaysInjectSelector
parameter to inject sidecar proxies into the pods that are matched by label. This setting takes priority over global settings.{ "alwaysInjectSelector": [ { "matchExpressions": [ { "key": "key1", "operator": "Exists" } ] }, { "matchExpressions": [ { "key": "key2", "operator": "Exists" } ] } ] }
- Set the
neverInjectSelector
parameter to prevent sidecar proxies from being injected into the pods that are matched by label. This setting takes priority over global settings.{ "neverInjectSelector": [ { "matchExpressions": [ { "key": "key3", "operator": "Exists" } ] }, { "matchExpressions": [ { "key": "key4", "operator": "Exists" } ] } ] }
- Set other parameters.
{ "replicaCount": 2, "injectedAnnotations": { "test/istio-init": "runtime/default", "test/istio-proxy": "runtime/default" }, "nodeSelector": { "beta.kubernetes.io/os": "linux" } }
- replicaCount: the number of replicas that are deployed for a sidecar injector.
- injectedAnnotations: other injected annotations.
- nodeSelector: the nodes on which sidecar injectors run. In this example, the beta.kubernetes.io/os
parameter is set to
linux
, which indicates that sidecar injectors run on the nodes with thelinux
label.
Scenario 1: Disable automatic sidecar injection for specific pods in a namespace for which automatic sidecar injection is enabled
To disable automatic sidecar injection for specific pods in a namespace for which automatic sidecar injection is enabled, perform the following operations:
Use other automatic sidecar injection configurations to disable automatic sidecar injection for specific pods in a namespace for which automatic sidecar injection is enabled
Use annotations to disable automatic sidecar injection for specific pods in a namespace for which automatic sidecar injection is enabled
Scenario 2: Configure automatic sidecar injection for a pod
If you do not want to configure automatic sidecar injection by namespace, you can configure automatic sidecar injection by pod.