Skip to content

Inject Beacon with DataKit Operator

DataKit Operator can inject Beacon into Java, Node.js, and Python applications when Pods are created. The release includes a default rule for Java.

Before You Start

Install DataKit Operator, enable the DataKit OpenTelemetry input, and check that application Pods can reach the DataKit Service.

Choose an injection mode

Set the selectors in admission_inject_v2.beacons in the Operator YAML. namespace_selectors matches the namespace and label_selectors matches existing Pod labels. Configure at least one list. The Pod must match an entry in each configured list. See selector syntax.

Scenario Operator rule Application workload
Centrally managed injection Use check_annotation: false (the field default) and set the version in image. Leave the workload YAML unchanged. The rule’s image is used even if the Pod has a version annotation.
Opt in per workload Keep the selectors and set check_annotation: true on the same rule. Add or retain the language-specific version annotation under spec.template.metadata.annotations on the target Deployment. Pods outside the selector scope cannot match this rule even with the annotation.

Enable Beacon with a version annotation

The default Java rule sets namespace_selectors: ["^default$"] and check_annotation: true and has no label selector. To enable Beacon for a Java Deployment in default, update its Pod template as shown and recreate its Pods.

spec:
  template:
    metadata:
      annotations:
        admission.datakit/beacon-java-lib.version: "1.3.4"

Custom rules use the same language-specific keys. A nonempty version replaces the tag in image and removes its digest. Use check_annotation: false to retain a pinned digest.

Language Version annotation
Java admission.datakit/beacon-java-lib.version
Node.js admission.datakit/beacon-nodejs-lib.version
Python admission.datakit/beacon-python-lib.version

To disable Beacon for one workload, set admission.datakit/beacon.enabled: "false" on its Pod template. With "true", the Pod must still meet the rule’s selector and version annotation requirements. To disable all tracing probes, set admission.datakit/tracing.enabled: "false".

Supported Runtimes and Images

These examples use the injection images below. Other versions are listed on GHCR. Java · Node.js · Python

Language Application runtime Injection image
Java JDK 8, 11, 17, 21, 25, 26 · Linux amd64/arm64 ghcr.io/beacon-observability/beacon-java:1.3.4
Node.js Node.js 24 · Debian Bookworm (glibc) · Linux amd64/arm64 ghcr.io/beacon-observability/beacon-nodejs:2.0.2
Python Standard GIL build of CPython 3.13 · Debian Bookworm (glibc) · Linux amd64/arm64 ghcr.io/beacon-observability/beacon-python:1.2.4

For the tested JDK versions and image architectures, see the Beacon Java 1.3.4 release notes.

The release pins the Java image by digest and uses IfNotPresent. If nodes cannot reach ghcr.io, preload the image or mirror it to a reachable registry and update image in the rule.

Inject automatically using existing labels

Add a rule per language to admission_inject_v2.beacons in the Operator, keeping existing rules in order. The example selects Pods by the default namespace and their existing app label. Substitute the selectors for your workloads. After editing the ConfigMap directly, restart the Operator and recreate the target Pods.

{
    "admission_inject_v2": {
        "beacons": [
            {
                "name": "beacon-java",
                "language": "java",
                "namespace_selectors": ["^default$"],
                "label_selectors": ["app=beacon-java-demo"],
                "check_annotation": false,
                "image": "ghcr.io/beacon-observability/beacon-java:1.3.4",
                "image_pull_policy": "IfNotPresent",
                "envs": {
                    "POD_NAME": "{fieldRef:metadata.name}",
                    "POD_NAMESPACE": "{fieldRef:metadata.namespace}",
                    "OTEL_SERVICE_NAME": "{fieldRef:metadata.labels['app']}",
                    "OTEL_RESOURCE_ATTRIBUTES": "k8s.pod.name=$(POD_NAME),k8s.namespace.name=$(POD_NAMESPACE)",
                    "OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
                    "OTEL_EXPORTER_OTLP_ENDPOINT": "http://datakit-service.datakit.svc.cluster.local:9529/otel",
                    "OTEL_TRACES_EXPORTER": "otlp",
                    "OTEL_METRICS_EXPORTER": "none",
                    "OTEL_LOGS_EXPORTER": "none",
                    "OTEL_PROFILING_ENABLED": "false",
                    "BEACON_SECURITY_ENABLED": "false"
                }
            },
            {
                "name": "beacon-nodejs",
                "language": "nodejs",
                "namespace_selectors": ["^default$"],
                "label_selectors": ["app=beacon-nodejs-demo"],
                "image": "ghcr.io/beacon-observability/beacon-nodejs:2.0.2",
                "image_pull_policy": "IfNotPresent",
                "envs": {
                    "OTEL_SERVICE_NAME": "{fieldRef:metadata.labels['app']}",
                    "OTEL_EXPORTER_OTLP_ENDPOINT": "http://datakit-service.datakit.svc.cluster.local:9529/otel",
                    "OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf"
                }
            },
            {
                "name": "beacon-python",
                "language": "python",
                "namespace_selectors": ["^default$"],
                "label_selectors": ["app=beacon-python-demo"],
                "image": "ghcr.io/beacon-observability/beacon-python:1.2.4",
                "image_pull_policy": "IfNotPresent",
                "envs": {
                    "OTEL_SERVICE_NAME": "{fieldRef:metadata.labels['app']}",
                    "OTEL_EXPORTER_OTLP_ENDPOINT": "http://datakit-service.datakit.svc.cluster.local:9529/otel",
                    "OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf"
                }
            }
        ]
    }
}

The HTTP/Protobuf base endpoint must retain /otel. Signal-specific variables such as OTEL_EXPORTER_OTLP_TRACES_ENDPOINT require a complete path, for example http://datakit-service.datakit.svc.cluster.local:9529/otel/v1/traces. Signal-specific variables take precedence over the base endpoint.

Rule Fields

Field Description
name Rule name, recommended for locating relevant logs
language Required; one of java, python, or nodejs
namespace_selectors Array of Namespace regular expressions
label_selectors Array of Pod Label Selectors
check_annotation Whether the Pod must provide a version Annotation for the corresponding language; defaults to false
image Required. Use a Beacon injection image compatible with the application runtime.
image_pull_policy Optional; Always, IfNotPresent, or Never. Missing or invalid values use Always. See Image Pull Policy
envs Environment variables injected into all regular application containers
resources Resource configuration for the init Container; defaults are used when missing or invalid

How Beacon interacts with OTel and DDTrace

Each Pod receives at most one tracing probe. The Operator checks Beacon → OTel → DDTrace, moving to the next probe only if the current one has no eligible rule. If some applications should use OTel or DDTrace, narrow the Beacon selectors or disable Beacon on those applications’ Pod templates.

For each probe, the Operator uses the first rule in configuration order whose selectors and annotation requirements the Pod meets.

Optional Java Features

By default, only traces are exported. To enable metrics, logs, profiling, or security, see the Beacon Java guide. To send profiles to DataKit, enable the DataKit Profile input and set OTEL_PROFILING_EXPORTER=datakit and OTEL_PROFILING_ENDPOINT.

Deployment Example

This Deployment already matches the Java rule through app=beacon-java-demo. Replace the example image with your Java application image.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: beacon-java-demo
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: beacon-java-demo
  template:
    metadata:
      labels:
        app: beacon-java-demo
    spec:
      containers:
        - name: app
          image: registry.example.com/apps/java-demo:1.0.0

Verify Injection and Traces

Once the example Deployment is ready, inspect the init container exit code and JVM options. Expect exit code 0 and a single -javaagent:/beacon-auto-instrumentation-java/javaagent.jar alongside the original JVM options.

kubectl -n default rollout status deployment/beacon-java-demo
pod=$(kubectl -n default get pods -l app=beacon-java-demo -o jsonpath='{.items[0].metadata.name}')
kubectl -n default get pod "$pod" -o jsonpath='{.status.initContainerStatuses[?(@.name=="datakit-beacon-lib-init")].state.terminated.exitCode}{"\n"}'
kubectl -n default get pod "$pod" -o jsonpath='{.spec.containers[?(@.name=="app")].env[?(@.name=="JAVA_TOOL_OPTIONS")].value}{"\n"}'
kubectl -n default logs "$pod" -c app

For Node.js, look for the register.mjs preload in the application container’s NODE_OPTIONS. For Python, check the agent directories in PYTHONPATH and verify OTEL_PYTHON_DISTRO=beacon. Send a request that the agent instruments, then find its trace using the service name from the app label. The Java example uses beacon-java-demo.

For missing injection or init container failures, see General troubleshooting. If injection succeeds but traces are missing, check the DataKit input, OTLP endpoint, and existing OTEL_* or JVM -D options. To roll back, disable the Beacon rule or set admission.datakit/beacon.enabled: "false", then recreate the Pods.

Init Container Permissions

The Beacon init container runs as a non-root user (UID/GID 65532 by default). If you use a custom image, make the probe files readable by the init container’s user.

Read-only Root Filesystem

If Beacon Java 1.3.4 reports Failed to open embedded extensions on a read-only root filesystem, give the Java container a writable temporary directory, for example by mounting an emptyDir at /tmp.

FAQ

How does injection work?

The Operator adds a datakit-beacon-lib-init init container to copy the selected agent into the datakit-beacon-auto-instrument EmptyDir. Application containers mount the volume read-only and load the agent when their processes start.

The rule’s language and envs apply to all regular application containers in the Pod. Explicit environment variables in the application container take precedence. If an existing probe or a startup option prevents injection, check the Operator log for the reason.

What changes in a Java container?

Java containers mount the volume at /beacon-auto-instrumentation-java. The Operator copies /javaagent.jar from the image into the volume and appends -javaagent:/beacon-auto-instrumentation-java/javaagent.jar to JAVA_TOOL_OPTIONS.

If the application already loads an APM agent manually, set admission.datakit/tracing.enabled: "false" on its Pod template to disable automatic tracing injection.

What changes in a Node.js container?

Node.js containers mount the shared volume at /beacon-auto-instrumentation-nodejs. The Operator appends the following preload option to NODE_OPTIONS.

--import=/beacon-auto-instrumentation-nodejs/node_modules/@beacon-observability/nodejs/register.mjs

Beacon Node.js guide

What changes in a Python container?

The Operator loads sitecustomize.py through PYTHONPATH and sets OTEL_PYTHON_DISTRO and OTEL_PYTHON_CONFIGURATOR to beacon. Make sure Python can load the site module and read environment variables at startup.

Beacon Python guide

DDTrace is a tracing project initiated and open-sourced by Datadog. Copyright belongs to Datadog and other contributors. TrueWatch supports DDTrace data ingestion. Use of DDTrace is subject to the applicable project's open-source license.