Getting traces out of forty services usually stalls on the same thing: forty teams, forty build pipelines, and forty different opinions about when to add an SDK. OpenTelemetry Operator auto-instrumentation moves that decision from the application repo to the cluster. The Operator watches pods as they are created and, when a pod carries the right annotation, injects the language agent for Java, Node.js, Python or .NET (and, with extra privileges, Go) before the application starts. Nobody rebuilds an image.
Our Kubernetes monitoring with OpenTelemetry guide covers the Collector side of a cluster and gives the Operator one section. This post is the long version: installing it properly, what every field in the Instrumentation resource does, how the annotations resolve, and the specific reasons a pod comes up without an agent when you expected one.
How injection works
The Operator registers a mutating admission webhook. When the API server receives a pod creation request, it sends the pod spec to the webhook, which checks for an instrumentation.opentelemetry.io/inject-<language> annotation. If it finds one, it looks up the matching Instrumentation resource and rewrites the pod before it is scheduled:
- An init container (named
opentelemetry-auto-instrumentation-<language>) copies the agent files from an auto-instrumentation image into a sharedemptyDirvolume. - The application container gets that volume mounted, plus the environment variables that load the agent:
JAVA_TOOL_OPTIONSfor Java,NODE_OPTIONSfor Node.js,PYTHONPATHfor Python, and the CLR profiler variables for .NET. - Standard SDK variables are added too:
OTEL_SERVICE_NAME,OTEL_EXPORTER_OTLP_ENDPOINT,OTEL_PROPAGATORS,OTEL_TRACES_SAMPLERandOTEL_RESOURCE_ATTRIBUTESwith the pod, namespace, node and owning workload names.
Two consequences follow from this design and explain most support questions. First, injection only happens at pod creation; nothing touches a running pod. Second, the image itself is never modified, so removing the annotation and restarting is a complete rollback.
Installing the Operator
The webhook needs a TLS certificate the API server trusts. The chart defaults to asking cert-manager for one, so install cert-manager first if the cluster does not already run it:
helm install cert-manager oci://quay.io/jetstack/charts/cert-manager \ --namespace cert-manager \ --create-namespace \ --set crds.enabled=true
Then add the OpenTelemetry chart repository and install the Operator. Pin --version for both charts in anything you intend to keep:
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts helm repo update helm install opentelemetry-operator open-telemetry/opentelemetry-operator \ --namespace opentelemetry-operator-system \ --create-namespace
If you cannot run cert-manager, the Operator chart can generate a self-signed certificate instead with --set admissionWebhooks.certManager.enabled=false and --set admissionWebhooks.autoGenerateCert.enabled=true. Either way, wait for the opentelemetry-operator Deployment to be ready before creating any resources, because the webhook also validates them.
A Collector for the agents to send to
Agents can export straight to a backend, but pointing them at a Collector inside the cluster keeps credentials out of application namespaces, absorbs retries when the backend is slow, and lets the k8sattributes processor enrich data. The Operator manages Collectors through a second CRD, OpenTelemetryCollector. Store the license key in a Secret first:
kubectl create secret generic aiaxoniq \ --namespace observability \ --from-literal=license-key=YOUR_LICENSE_KEY
apiVersion: opentelemetry.io/v1beta1
kind: OpenTelemetryCollector
metadata:
name: otel
namespace: observability
spec:
mode: daemonset
env:
- name: AIAXONIQ_LICENSE_KEY
valueFrom:
secretKeyRef:
name: aiaxoniq
key: license-key
config:
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
processors:
memory_limiter:
check_interval: 1s
limit_percentage: 75
spike_limit_percentage: 15
batch: {}
exporters:
otlphttp:
endpoint: https://app.aiaxoniq.com/otlp
headers:
x-license-key: ${env:AIAXONIQ_LICENSE_KEY}
service:
pipelines:
traces:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [otlphttp]
metrics:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [otlphttp]
logs:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [otlphttp]The Operator creates a Service named after the resource with -collector appended, so this one is reachable at otel-collector.observability.svc.cluster.local. Other modes are deployment (the default), statefulset and sidecar. A DaemonSet is a good fit for agent traffic because every pod has a Collector on its own node.
The Instrumentation resource, field by field
An Instrumentation resource describes how injected agents behave. Create it in each application namespace, or once in a shared namespace and reference it by name:
apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata:
name: default
namespace: shop
spec:
exporter:
endpoint: http://otel-collector.observability.svc.cluster.local:4318
propagators:
- tracecontext
- baggage
sampler:
type: parentbased_traceidratio
argument: "0.25"
env:
- name: OTEL_EXPORTER_OTLP_PROTOCOL
value: http/protobuf
resource:
addK8sUIDAttributes: true
java:
env:
- name: OTEL_INSTRUMENTATION_KAFKA_ENABLED
value: "false"
resources:
limits:
cpu: 500m
memory: 64Mi
nodejs:
env:
- name: OTEL_NODE_DISABLED_INSTRUMENTATIONS
value: fs
python:
env:
- name: OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED
value: "true"- `exporter.endpoint` becomes
OTEL_EXPORTER_OTLP_ENDPOINT. If you leave it out, agents default tohttp://localhost:4317and your data goes nowhere. For anhttps://endpoint,exporter.tlstakes a CA file or a Secret reference. - `propagators` sets
OTEL_PROPAGATORS. Keeptracecontextandbaggageunless something in the call path still speaksb3orjaeger, in which case list those too so context survives the hop. - `sampler` sets
OTEL_TRACES_SAMPLERand its argument. Valid types includealways_on,traceidratio,parentbased_always_onandparentbased_traceidratio. Use a parent-based sampler so a downstream service honours the decision made at the edge rather than sampling each hop independently. - `env` applies to every language. Pinning
OTEL_EXPORTER_OTLP_PROTOCOLhere matters because defaults differ: the Node.js agent injected by the Operator defaults to gRPC on 4317, while Java, Python, .NET and Go default tohttp/protobufon 4318. Python cannot use gRPC at all. One protocol and one port for everyone removes a class of silent failures. - `resource` controls resource attributes.
addK8sUIDAttributesadds UIDs alongside names;resourceAttributesadds static key-value pairs. - Per-language blocks (
java,nodejs,python,dotnet,go, plusapacheHttpdandnginx) take their ownenv, animageoverride and resource limits for the init container. Note the field name differs: Java usesresources, the others useresourceRequirements.
The image field deserves a decision. By default the Operator uses the upstream autoinstrumentation-<language> images that ship with its release, and upgrading the Operator moves the default agent version. Teams that want agent upgrades to be a separate, reviewed change set image explicitly and mirror it to an internal registry, which also removes a runtime dependency on ghcr.io.
Annotating workloads
Auto-instrumentation is opt-in. Add the annotation to the pod template, spec.template.metadata.annotations, not the Deployment's own metadata. Annotations on the Deployment object are never seen by the webhook, and this is the single most common reason nothing happens:
apiVersion: apps/v1
kind: Deployment
metadata:
name: checkout
namespace: shop
spec:
template:
metadata:
annotations:
instrumentation.opentelemetry.io/inject-java: "true"
instrumentation.opentelemetry.io/container-names: "checkout"
resource.opentelemetry.io/service.version: "4.2.0"The language annotations are inject-java, inject-nodejs, inject-python, inject-dotnet and inject-go. There is also inject-sdk, which injects only the environment variables for applications that already embed an SDK but should take endpoint and sampling from the cluster. The value controls which Instrumentation is used:
"true"uses the resource in the pod's own namespace."my-instrumentation"uses a named resource in the same namespace."observability/my-instrumentation"uses a resource in another namespace."false"opts the pod out, which is useful when the annotation is set on the namespace.
Setting the annotation on a namespace opts in every pod created there. That is convenient for a dedicated application namespace and dangerous for a shared one, since it also catches sidecars, batch jobs and anything else that starts in it.
By default only the first container in the pod is instrumented. If a service mesh or log shipper sidecar is listed first, the agent lands in the wrong container; container-names fixes that. Pods that mix languages need the enable-multi-instrumentation feature flag and the per-language variants such as java-container-names and python-container-names.
For service.name, the Operator uses the resource.opentelemetry.io/service.name annotation if present, otherwise the owning Deployment, StatefulSet, DaemonSet, Job or pod name. The resource.opentelemetry.io/ prefix works for any resource attribute, as with service.version above.
Go is different
Go compiles to a static binary with no runtime hook to load an agent into, so the Operator instruments it with the OpenTelemetry Go auto-instrumentation project, which uses eBPF uprobes from a sidecar instead. That brings three requirements the other languages do not have:
- Go support is off by default. Enable it on the Operator with
--set manager.autoInstrumentation.go.enabled=true. - The pod must say which binary to attach to, through the
instrumentation.opentelemetry.io/otel-go-auto-target-exeannotation (for example/app/server). Without it, injection is abandoned and the pod starts unchanged. - The injected sidecar runs with
privileged: trueandrunAsUser: 0. Many clusters forbid that through Pod Security Admission or a policy engine, so check with whoever owns those rules before promising Go coverage.
Go injection also does not support multi-container pods. If privileged sidecars per Go pod are not acceptable, a node-level eBPF agent or compiling the Go SDK in are the alternatives; our Go monitoring guide covers the SDK route.
Troubleshooting injection
Work through these in order. Each one rules out a layer.
Was the pod created after the Instrumentation?
The webhook only acts at admission. Pods that existed before you created the Instrumentation or added the annotation stay uninstrumented until they are recreated. Restart the workload and check again:
kubectl rollout restart deployment/checkout -n shop
kubectl get pod -n shop -l app=checkout \
-o jsonpath='{.items[0].spec.initContainers[*].name}'An instrumented Java pod lists opentelemetry-auto-instrumentation-java. No init container means the webhook did not mutate the pod. Confirm the resource exists where the annotation expects it with kubectl get otelinst -n shop, check the annotation is on the pod template, and read the Operator logs:
kubectl logs -n opentelemetry-operator-system \ -l app.kubernetes.io/name=opentelemetry-operator -c manager
The init container ran, but no data arrives
Now the problem is the export path. Run kubectl describe pod and read the injected OTEL_EXPORTER_OTLP_ENDPOINT. The usual faults are a protocol and port mismatch (gRPC sent to 4318, or HTTP to 4317), a short Service name that only resolves inside the Collector's namespace, or a NetworkPolicy blocking the application namespace from the Collector. The Collector's own logs show whether it is receiving anything at all.
The application behaves differently after injection
The Operator sets JAVA_TOOL_OPTIONS, NODE_OPTIONS and PYTHONPATH. If your image or a ConfigMap already sets one of them, the injected value can override yours; this is a known upstream issue. Move those settings to command-line flags or merge them explicitly. Python images built on musl (Alpine) need instrumentation.opentelemetry.io/otel-python-platform: "musl", and .NET on musl needs instrumentation.opentelemetry.io/otel-dotnet-auto-runtime: "linux-musl-x64".
Where auto-instrumentation stops
The Operator gives you what the language agents give you: spans for supported HTTP frameworks, clients, database drivers and messaging libraries, runtime metrics, and context propagation between them. It cannot add the attributes that make a trace useful during an incident, such as the tenant, the plan or the cart size. It adds startup time and memory, most noticeably for the Java agent, so revisit requests and readiness probes when you switch it on. And it only covers languages with an agent; a Rust service or a third-party binary gets nothing.
The practical pattern is layered: the Operator for broad coverage of supported runtimes, a few hand-written spans on the paths where revenue depends on the answer, and kernel-level telemetry for whatever neither reaches.
Auto-instrumentation and aiAxonIQ
Everything above exports standard OTLP, so the Collector shown here sends to aiAxonIQ without vendor agents. aiAxonIQ's Kubernetes monitoring adds the layer the Operator cannot: axonIQzerocode runs as one DaemonSet installed with Helm, reconstructs HTTP, gRPC, PostgreSQL, MySQL and Redis calls from socket traffic with eBPF, and labels them with pod, namespace, container and node. Services the Operator instruments get full traces; the rest still report rate, errors and latency, and both land in the same store.