Kubernetes
Add the LogDrop Java agent to your pods with the LogDrop Helm chart and one pod annotation.
The LogDrop Helm chart installs a small admission webhook, the trace injector. When a pod whose template carries the annotation logdrop.io/trace: java is created, the injector adds an init container that copies the LogDrop Java agent into the pod and sets JAVA_TOOL_OPTIONS and the LOGDROP_* settings on your container. Your images and code stay unchanged.
You need a traces ingest key and the other items in Before you start, and the Java requirements.
1. Store the ingest key in each namespace you trace
The traces ingest key is the credential the agent sends traces to LogDrop with. On Kubernetes it lives in a Secret named logdrop-trace-ingest-key in each traced namespace. Create the Secret with:
printf 'Traces key (paste it once, then press Enter): ' && read -rs LOGDROP_TRACE_KEY && echo
if [[ $LOGDROP_TRACE_KEY == ldtk_* && ${#LOGDROP_TRACE_KEY} -eq 71 ]]; then
kubectl -n <namespace> create secret generic logdrop-trace-ingest-key \
--from-literal=trace-ingest-key="$LOGDROP_TRACE_KEY"
else
echo 'That is not one traces key (it starts with ldtk_ and has 71 characters). Paste it once.'
fi
unset LOGDROP_TRACE_KEYread -rs keeps the key out of your shell history and off the screen, so nothing appears while you paste: paste once. The check refuses a key pasted twice or cut short; LogDrop answers such a key with 401. The commands work in bash and zsh. The Secret must exist in every traced namespace; the chart never creates it. A pod in a namespace without the Secret still starts, but sends nothing (its log says LogDrop ingest key file is missing or invalid).
The key never appears in pod specs or logs: the injector mounts the Secret as a read-only file and the agent reads it from there. With a GitOps tool, keep the Secret in your usual secret workflow (for example Sealed Secrets, External Secrets or SOPS), never as plain text in Git.
2. Install the LogDrop chart with tracing on
The LogDrop Helm chart installs the trace injector in your cluster. The values below turn tracing on and set where traces go, which namespaces are traced and the environment shown in APM.
enabled: true
clusterName: <a name for this cluster, for example shop-prod>
cluster:
uid: <kube-system namespace UID> # optional; adds the cluster identity to every trace
tracing:
enabled: true
endpoint: https://otel.logdrop.io
namespaces: [<namespace>] # every namespace whose pods you want to trace
environment: production
requirePodLabel: true # only labelled pods ever reach the injector
networkPolicy:
apiServerCIDRs: [<API server address>/32]Find the API server addresses and the cluster UID with:
kubectl get endpointslices -n default -l kubernetes.io/service-name=kubernetes \
-o jsonpath='{.items[*].endpoints[*].addresses[*]}' # API server addresses
kubectl get namespace kube-system -o jsonpath='{.metadata.uid}' # cluster UIDManaged control planes that call webhooks through an in-cluster proxy also need that proxy as a source. On DigitalOcean Kubernetes, for example, the calls come from the konnectivity agents:
tracing:
injector:
sourcePeers:
- namespaceSelector: {matchLabels: {kubernetes.io/metadata.name: kube-system}}
podSelector: {matchLabels: {k8s-app: konnectivity-agent}}Install the chart:
helm upgrade --install logdrop oci://registry.logdrop.io/charts/logdrop-infrastructure --version 0.1.1-alpha15 \
--namespace logdrop-system --create-namespace -f logdrop-values.yamlThe chart pulls the agent image (registry.logdrop.io/logdrop-javaagent) and the injector's runtime from registry.logdrop.io by digest; see Verify what you install. With these values it installs one small webhook pod, the trace injector, and nothing else. The same chart also installs the infrastructure metrics agent, which links each trace to its cluster and pod: add its values to this release (Infrastructure Monitoring).
On DigitalOcean Kubernetes with Helm 4, a later helm upgrade can stop with a conflict on the injector webhook's objectSelector, because the platform adds its own rule there. Run the upgrade again with --server-side=true --force-conflicts.
| Value | Default | Meaning |
|---|---|---|
tracing.endpoint | none | The traces endpoint, https://otel.logdrop.io: an HTTPS base URL without path, query or credentials |
tracing.namespaces | none | Namespaces whose annotated pods are instrumented. Pods in other namespaces are never sent to the webhook |
tracing.environment | production | Environment shown in APM |
tracing.serviceNamespace | empty | Default service group in APM. The pod annotation logdrop.io/service-namespace overrides it |
tracing.requirePodLabel | false | Also require the pod label logdrop.io/trace: java (or nodejs, python, dotnet, go, php, rust), so other pods in a traced namespace never reach the webhook. Recommended |
tracing.ingestKeySecret.name / .key | logdrop-trace-ingest-key / trace-ingest-key | The key Secret in each traced namespace |
tracing.caSecret / tracing.caSecretKey | empty / ca.crt | A Secret with a private CA. Only needed for an on-premises LogDrop installation with its own CA |
tracing.java.image | LogDrop's published agent, by digest | Set your own repository and digest (or tag) when you mirror images |
tracing.java.imagePullSecrets | empty | Pull Secrets for the agent image. They must exist in every traced namespace |
tracing.java.resources | requests 10m / 16Mi, limits 100m / 64Mi | The init container that copies the agent. Your container keeps its own resources |
tracing.injector.timeoutSeconds | 5 | How long the API server waits for the injector. After that the pod is created without tracing |
tracing.injector.sourceCIDRs / sourcePeers | empty | Extra webhook callers besides networkPolicy.apiServerCIDRs |
tracing.injector.tls.existingSecret / caBundle | empty | Your own webhook certificate (for example from cert-manager) and the CA that signed it. Empty: the chart generates one, reuses it on upgrades and renews it 60 days before it expires |
networkPolicy.apiServerCIDRs | none | The API server addresses allowed to call the injector. Required while networkPolicy.enabled is true, the default |
clusterName, cluster.uid | empty | The cluster name and UID added to every trace |
With Argo CD or helm template (no cluster access while rendering), the generated webhook certificate changes on every render. Give the chart a certificate with tracing.injector.tls.existingSecret and the CA that signed it in tracing.injector.tls.caBundle.
3. Opt a workload in
A pod annotation is a key and value in a pod's metadata. The injector adds the agent only to pods whose template carries the annotation logdrop.io/trace: java, so you choose which workloads are traced.
Add the label and the annotations to the pod template and roll the workload:
spec:
template:
metadata:
labels:
logdrop.io/trace: java # needed with requirePodLabel: true
annotations:
logdrop.io/trace: java
logdrop.io/service: orders # optional
logdrop.io/release: "1.4.2" # optional| Annotation | Meaning |
|---|---|
logdrop.io/trace: java | Opts the pod in. java, nodejs, python, dotnet, go, php and rust are supported; any other value is skipped with a status |
logdrop.io/service | Service name. Default: the label app.kubernetes.io/name, then the owning Deployment, StatefulSet, DaemonSet or Job, then the container name |
logdrop.io/service-namespace | Service group in APM. Default: tracing.serviceNamespace |
logdrop.io/release | Release shown in APM. Default: the label app.kubernetes.io/version |
logdrop.io/container | The container to trace. Default: the first container |
logdrop.io/trace-status | Written by the injector: injected or skipped: <reason> |
Annotation values are at most 128 characters, without control characters. Pods that already run are not changed: the agent is added when a pod is created.
4. Check it
Check that the injector added the agent to the new pods. It records the result in the pod annotation logdrop.io/trace-status:
kubectl -n <namespace> get pod <pod> -o jsonpath='{.metadata.annotations.logdrop\.io/trace-status}'injected means the agent is in. The container log then shows one line from the agent:
[logdrop-agent] INFO LogDrop Java agent 0.1.0-alpha5 is tracing service "orders" (environment "production") to otel.logdrop.io.Send a request to the service. The trace appears in Trace Explorer within about a minute; the service, its endpoints and dependencies appear in Services and the Dependency map within about two minutes. See Tracing & APM.
trace-status | Meaning |
|---|---|
injected | The agent was added |
skipped: unsupported language | The annotation value is not java, nodejs, python, dotnet, go, php or rust |
skipped: container not found | logdrop.io/container names no container of the pod |
skipped: no containers, skipped: invalid container name | The pod spec cannot be instrumented |
skipped: invalid logdrop.io/service (or service-namespace, release) | The annotation value is empty, longer than 128 characters or has control characters |
skipped: JAVA_TOOL_OPTIONS uses valueFrom | The container takes JAVA_TOOL_OPTIONS from a ConfigMap or Secret, which the injector never rewrites. Set it as a literal value |
skipped: volume name conflict, skipped: mount path conflict | The pod already uses the injector's volume names, or the paths /logdrop-agent or /var/run/secrets/logdrop.io/trace |
| missing | The webhook did not see the pod: its namespace is not in tracing.namespaces, the pod label is missing with requirePodLabel: true, the pod was created before the chart was installed, or the injector was unavailable |
Network and disk
This section lists the network access the injector and the traced pods need, and the storage tracing uses in each pod. Check it when your cluster restricts network traffic, or when pods get no trace-status annotation.
The injector runs in the pod network. The chart gives it a NetworkPolicy that admits only the API server addresses in networkPolicy.apiServerCIDRs, plus tracing.injector.sourceCIDRs and sourcePeers, on the webhook port, and allows it no egress. It has no access to the Kubernetes API. If pods are created without a logdrop.io/trace-status annotation after you install the chart, the control plane probably reaches the webhook from an address you have not listed.
Traced pods send to the traces endpoint on port 443 and need DNS. In namespaces with a default-deny egress policy, allow it:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: {name: allow-logdrop-trace-export, namespace: <namespace>}
spec:
podSelector:
matchLabels: {logdrop.io/trace: java} # without the pod label: podSelector: {}
policyTypes: [Egress]
egress:
- to: [{ipBlock: {cidr: <traces endpoint address>/32}}]
ports: [{protocol: TCP, port: 443}]A NetworkPolicy matches IP addresses, not host names. Allow the addresses that otel.logdrop.io resolves to, and check them again if the agent starts to log LogDrop is not reachable.
Disk. Tracing uses no node directories and no persistent volumes. The agent keeps the spans waiting to be sent in memory (at most 2,048 by default) and drops new spans when that queue is full. Each traced pod gets an emptyDir volume, limited to 64 MiB, that holds the agent jar of about 25 MB.
When the injector is unavailable
The webhook never blocks a deploy. When the injector is down, slow or unreachable, pods are created without tracing and without a trace-status annotation; restart them once the injector is back. The injector never refuses a pod: a pod it cannot instrument is created unchanged except for trace-status: skipped: <reason>.
Things to know
These points describe how the injected agent fits into your pods. Check them before you opt production workloads in.
JAVA_TOOL_OPTIONSset in the image (ENVin a Dockerfile) is replaced by the pod-level value the injector adds. Move such options into the pod spec, where the injector appends-javaagentto them. A value fromenvFromis overridden the same way.- Size the container for about 100 MiB more memory and about one second more startup time with the agent.
LOGDROP_*variables that the container already sets win over the injected ones.- Containers added by webhooks that run after the injector are not instrumented.
- The webhook receives the full spec of every pod created in the traced namespaces (with
requirePodLabel: true, only of labelled pods). Its logs carry only the pod name, the namespace and the result, never environment values.
Upgrade, roll back, remove
helm upgrade keeps the webhook certificate and restarts the injector when its configuration changes. Running pods keep the agent they started with until they are restarted, so roll your workloads to pick up a new agent version. helm rollback restores the previous webhook, configuration and certificate together.
helm uninstall removes the injector; instrumented pods keep their copy of the agent until they restart. To stop tracing one workload, remove the annotation and roll it out.
.png)