Multi-container Pods
When working with multi-container pods, you need to configure auto-instrumentation to handle multiple containers appropriately. The Operator provides flexible options for controlling which containers receive instrumentation and how multiple instrumentations interact.
TOC
Default BehaviorSpecifying Target ContainersMultiple Instrumentations in One PodContainer Name Annotation FormatEnvironment Variable IsolationExample: Multi-language ApplicationImportant NotesDefault Behavior
By default, when you annotate a pod for auto-instrumentation, the Operator injects instrumentation into the first container in the pod specification. This works well for single-container pods but may not be suitable for multi-container scenarios.
Specifying Target Containers
To control which containers receive instrumentation, use the container-names annotation:
In this example, only the app and worker containers receive Java instrumentation, while the sidecar container remains uninstrumented.
Multiple Instrumentations in One Pod
You can apply different instrumentation types to different containers within the same pod:
This configuration applies:
- Java instrumentation to the
java-appcontainer - Python instrumentation to the
python-workercontainer - No instrumentation to the
nginxcontainer
Container Name Annotation Format
The container name annotation follows this pattern:
Where <language> can be:
javapythonnodejsdotnetgoapache-httpdsdk
Environment Variable Isolation
Each instrumented container receives its own set of instrumentation environment variables. You can configure container-specific settings using the Instrumentation CR:
Example: Multi-language Application
In the following example, myapp and myapp2 containers will be instrumented using Java and myapp3 using Python instrumentation:
Important Notes
- Go auto-instrumentation does not support multicontainer pods. When injecting Go auto-instrumentation the first container should be the only you want to instrument.
- This type of instrumentation does not allow to instrument a container with multiple language instrumentations.
instrumentation.opentelemetry.io/container-namesannotation is not used for this feature.