Docs/Deployment/Kubernetes

Kubernetes

Configure the NxtOne SDK in your Kubernetes workloads.

There is no NxtOne Helm chart, DaemonSet, sidecar, or operator to install. The SDK is a dependency of your application, so it ships inside your own image (see Docker) and runs in your service's process. On Kubernetes, the work happens in your own manifests: a Secret for the API key, a few environment variables on each Deployment, and pod settings that let the SDK flush its last events on shutdown.

1. What runs where

PieceWhere it runsWhat it does
NxtOne SDKInside your application container, in your own imageInstruments your code in-process and batches events in memory.
NxtOne platformHosted by NxtOneReceives events from the SDK over HTTPS. Nothing NxtOne-specific runs in your cluster.

Because nothing runs at the node or cluster level, there is no ServiceAccount, RBAC, or CRD to create, and no cluster-scoped permissions are needed. Only workloads that run your own code need the SDK — databases, caches, and ingress controllers stay as they are.

2. Prerequisites

  • An application image with the SDK installed — see Docker.
  • kubectl access to the namespaces your services run in.
  • An API key from the dashboard — see Authentication.
  • Outbound HTTPS (443) from your pods to the NxtOne API and Amazon S3 — see section 9.

3. Store the API key in a Secret

bash
# Create it in every namespace that runs an instrumented service kubectl create secret generic nxtone-credentials \ --namespace payments \ --from-literal=api-key="$NXTONE_API_KEY"

Secrets are namespaced: a pod can only reference a Secret in its own namespace. If your services span several namespaces, create the Secret in each, or manage it with the secret-sync tooling you already use.

Keep the key out of manifests and images. Never paste it as a literal value: in a Deployment committed to Git, and never bake it into the image. Environment variables from a Secret are read when the container starts, so after rotating the key run kubectl rollout restart on the Deployments that use it.

4. Configuring your Deployment

Each instrumented Deployment gets the API key from the Secret and its own NXTONE_PROJECT_ID. If you template manifests with your own Helm chart or Kustomize, these are ordinary env entries:

yaml
apiVersion: apps/v1 kind: Deployment metadata: name: payment-service namespace: payments spec: replicas: 3 selector: matchLabels: app: payment-service template: metadata: labels: app: payment-service spec: containers: - name: payment-service image: registry.example.com/payment-service:1.4.0 env: - name: NXTONE_API_KEY valueFrom: secretKeyRef: name: nxtone-credentials key: api-key # One project per service — this is what lets NxtOne stitch a # request into a cross-service execution flow. - name: NXTONE_PROJECT_ID value: payment-service

Java on JDK 21 or later: add -XX:+EnableDynamicAgentLoading to the JVM options (for example through JAVA_TOOL_OPTIONS), since the SDK attaches itself at startup.

5. Environment variables

VariableRequiredDescription
NXTONE_API_KEYYesAuthenticates the SDK with the platform. Without it the SDK does nothing and your service runs unobserved — it never fails your app.
NXTONE_PROJECT_IDRecommendedGroups execution flows in the UI. Set it explicitly per Deployment — the fallback is not service-specific, so a cluster's services can collapse into a single project.
NXTONE_EXCLUDENoPackages or paths to leave uninstrumented. See Filtering.

See Environment Variables and Filtering for the full reference.

6. Read-only root filesystems

This only matters if your pods set readOnlyRootFilesystem: true. The Node.js SDK writes nothing to disk. The Java SDK copies its JAR into the JVM's temp directory (/tmp by default) at startup — if it can't, it logs nxtone: agent attach failed and the service runs uninstrumented. The Python SDK creates a nxtone/ directory under the system temp directory at startup, and writes batches there only when its in-memory queue is full or a send fails. For Java and Python services, mount an emptyDir at /tmp:

yaml
spec: containers: - name: payment-service securityContext: readOnlyRootFilesystem: true volumeMounts: - name: tmp mountPath: /tmp volumes: - name: tmp emptyDir: {}

An emptyDir is disk-backed by default. medium: Memory makes it a tmpfs, but anything written there then counts against the container's memory limit.

7. Graceful shutdown

When Kubernetes stops a pod it sends SIGTERM to each container's main process, waits terminationGracePeriodSeconds (30 by default), then sends SIGKILL. The SDK batches events in memory and flushes them when your process exits, so a pod killed before that flush loses its last events — on every rollout, scale-down, and node drain:

  • Use the exec form of CMD/ENTRYPOINT in your Dockerfile so your app is PID 1 and receives SIGTERM directly. If you override command in the pod spec, list the binary and its arguments directly rather than wrapping them in sh -c — a shell as PID 1 may not pass the signal on.
  • On Node.js, start your app with node rather than npx nxtone run — the launcher does not forward SIGTERM to your app.
  • On Python, the SDK installs no SIGTERM handler; it flushes when the interpreter exits normally or on ASGI lifespan shutdown — uvicorn, for example, handles SIGTERM that way. A plain worker script needs its own handler that exits cleanly, because Python's default reaction to SIGTERM skips exit handlers.
  • Keep the grace period longer than the SDK's flush. Java and Node.js flush for up to 5 seconds, well within the 30-second default. The Python SDK can wait up to 60 seconds (NXTONE_SHUTDOWN_TIMEOUT) — raise the grace period to match, or lower the timeout.
yaml
spec: template: spec: # Python services: longer than the SDK's 60 s flush, plus your own # shutdown work and any preStop hook. terminationGracePeriodSeconds: 90
A preStop hook runs inside the same grace period, so a sleep there to let load balancers drain leaves less time for the flush. If a service-mesh proxy carries your pod's outbound traffic, make sure it outlives your app's shutdown too — otherwise the final flush has no route out.

8. Resource requests and limits

The SDK runs inside your container, so there is no separate pod to size: its memory for the event queue and CPU for serialization count against your container's own requests and limits. Limits sized tightly against an uninstrumented service are the usual cause of OOMKilled pods after rollout.

There is no universal number. Overhead depends on request volume, payload size, and how aggressively you exclude code paths. Roll out to one Deployment first, watch kubectl top pod under representative load, and size from what you observe. Trimming noisy packages with exclusions is usually more effective than raising limits.

9. Network egress

The SDK only makes outbound connections — it opens no ports, so there is no Service, container port, or ingress rule to add for NxtOne. It needs HTTPS (443) to the NxtOne API (api.nxtone.ai and www.api.nxtone.ai) and to Amazon S3, which it uses for large payloads.

Pods can reach the internet by default. If your namespace applies a default-deny egress policy, allow DNS and outbound 443 from instrumented pods:

yaml
apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: payment-service-nxtone-egress namespace: payments spec: podSelector: matchLabels: app: payment-service policyTypes: - Egress egress: # DNS - to: - namespaceSelector: matchLabels: kubernetes.io/metadata.name: kube-system podSelector: matchLabels: k8s-app: kube-dns ports: - protocol: UDP port: 53 - protocol: TCP port: 53 # NxtOne API and Amazon S3 - ports: - protocol: TCP port: 443

Standard NetworkPolicy matches IPs and ports, not hostnames, so this rule allows 443 to any destination. To restrict egress to specific hosts, use your CNI's DNS-aware policies (for example Cilium's toFQDNs) or an egress firewall. NetworkPolicy is only enforced if your CNI plugin supports it.

10. Verifying the rollout

The SDK logs to stderr, so its startup lines appear in your pod logs:

bash
kubectl rollout status deployment/payment-service -n payments # SDK startup lines from one of the Deployment's pods kubectl logs -n payments deployment/payment-service | grep -i nxtone # Confirm the container received the variables (the key's value is not shown) kubectl describe pod -n payments -l app=payment-service | grep NXTONE_
RuntimeWhat to look for
Javanxtone: agent attached, then nxtone: application ready
Node.jsNXTONE_SESSION_ID=…
AnyA hint that the API key is missing means the SDK is running as a no-op — check the environment the container actually received.
SymptomLikely causeFix
CreateContainerConfigErrorThe Secret, or the key named in secretKeyRef, does not exist in the pod's namespace.Create nxtone-credentials in that namespace and check the key name matches.
Missing-API-key hint in the logsThe variable is set on a different container, or the pod started before you added it.Check kubectl describe pod, then kubectl rollout restart the Deployment.
No Java SDK lines with a read-only root filesystem/tmp is not writable.Mount an emptyDir at /tmp (section 6).
SDK lines present, no data in the dashboardEgress to the NxtOne API or Amazon S3 is blocked.Check NetworkPolicies, egress firewalls, and proxies (section 9).
Last events missing after rolloutsThe pod is killed before the SDK flushes.Use an exec-form command and a longer grace period (section 7).
OOMKilledMemory limits sized for the uninstrumented service.Exclude noisy packages or raise the limit (section 8).

Anything not covered here — see Troubleshooting.

Running on Amazon EKS? The setup is the same — see AWS EKS for sourcing the key from Secrets Manager, Fargate, and VPC egress. No IAM role is needed.