Skip to content

Istio Sidecar Injection Methods

Istio enables Service mesh capabilities by deploying an Envoy proxy alongside application workloads. This process, known as sidecar injection, can be performed automatically by the cluster or manually by the user.^[400-devops__07-Monitoring-and-Observability__k8s-istio__samples__custom-bootstrap__README.md]

Automatic sidecar injection

When Automatic sidecar injection is configured in the cluster (typically enabled on specific namespaces via the istio-injection=enabled label), the sidecar is automatically injected into pods upon creation.^[400-devops__07-Monitoring-and-Observability__k8s-istio__samples__custom-bootstrap__README.md]

In this mode, standard Kubernetes commands deploy the application with the proxy:

bash [kubectl](<./kubectl.md>) apply -f example-app.yaml^[400-devops__07-Monitoring-and-Observability__k8s-istio__samples__websockets__README.md]

Manual Sidecar Injection

If automatic injection is not set up, or if a specific deployment requires explicit control, the sidecar must be manually injected before deployment.^[400-devops__07-Monitoring-and-Observability__k8s-istio__samples__custom-bootstrap__README.md] This involves using the istioctl command line tool to modify the resource definitions locally.

The manual injection process generally follows these steps: 1. Use istioctl kube-inject to process the resource file and output a modified version containing the sidecar specification. 2. Apply the modified file to the cluster.^[400-devops__07-Monitoring-and-Observability__k8s-istio__samples__custom-bootstrap__README.md]

Example command: bash [istioctl](<./istioctl.md>) kube-inject -f example-app.yaml -o example-app-istio.yaml [kubectl](<./kubectl.md>) apply -f example-app-istio.yaml^[400-devops__07-Monitoring-and-Observability__k8s-istio__samples__custom-bootstrap__README.md]

Alternatively, the injection and application can be combined into a single pipeline operation:

bash [kubectl](<./kubectl.md>) create -f <([istioctl](<./istioctl.md>) kube-inject -f samples/websockets/app.yaml)^[400-devops__07-Monitoring-and-Observability__k8s-istio__samples__websockets__README.md]

Sources

  • 400-devops__07-Monitoring-and-Observability__k8s-istio__samples__custom-bootstrap__README.md
  • 400-devops__07-Monitoring-and-Observability__k8s-istio__samples__websockets__README.md