liveBook · Manning

Automatic sidecar injection

As explained in Google Anthos in Action

Automatic sidecar injection is the admission-time addition of a proxy sidecar to newly created pods based on cluster configuration.

Automatic sidecar injection adds a proxy container beside each newly created workload Pod through Kubernetes admission, enabling transparent participation in Anthos Service Mesh. section 4.5.1

Configure injection at the namespace and workload lifecycle levels:

  • Enable injection by labeling the application namespace with the appropriate Anthos Service Mesh revision, such as istio.io/rev=asm-managed. section 4.5.1 section 4.7.1
  • Let the mutating admission webhook apply the injection configuration; the istio-sidecar-injector configuration map controls the injected proxy. section 4.5.1
  • Restart existing Pods after labeling because injection occurs only when Pods are created. section 4.5.1
  • Verify successful injection by checking that each workload reports two ready containers: the application and its proxy. section 4.5.1

Enable injection for an Online Boutique namespace

Create the demo namespace, inspect istiod labels to identify the control-plane revision, label the namespace with that revision, and deploy the application. The resulting workload Pods report 2/2 READY, confirming proxy injection. section 4.7.1

kubectl label namespace NAMESPACE istio.io/rev=asm-managed --overwrite

Use the supplied kubectl command to label a namespace for the asm-managed injection revision, then restart deployments and inspect Pod readiness. section 4.5.1

How Google Anthos in Action covers it

How deep it goes
Explains namespace labeling, admission-webhook behavior, Pod restarts, and readiness checks, but defers detailed installation options.
Examples
Demonstrates namespace labels, deployment restarts, Pod inspection, and an Online Boutique deployment with 2/2 readiness.
What it assumes
Assumes a deployed Anthos Service Mesh and Kubernetes cluster, while demonstrating namespace labeling and workload recreation.
What you can do after
Operate/configure namespace injection with kubectl and verify that newly recreated workloads contain proxy sidecars.
How it connects
Connects Kubernetes namespaces, Pods, admission webhooks, Istio, Anthos Service Mesh, and sidecar proxies.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Google Anthos in Action. The section links point to the parts of the book it draws on.