From c2953d395e159dc32e342ccd93a20f86860b561c Mon Sep 17 00:00:00 2001 From: slayerjain Date: Tue, 1 Dec 2026 03:20:39 +0530 Subject: [PATCH 1/2] docs(k8s-proxy): add Java TLS capture setup and verification guide Signed-off-by: slayerjain --- .../running-keploy/java-tls-capture.md | 162 ++++++++++++++++++ .../version-4.0.0-sidebars.json | 3 +- 2 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 versioned_docs/version-4.0.0/running-keploy/java-tls-capture.md diff --git a/versioned_docs/version-4.0.0/running-keploy/java-tls-capture.md b/versioned_docs/version-4.0.0/running-keploy/java-tls-capture.md new file mode 100644 index 000000000..bd7ca9deb --- /dev/null +++ b/versioned_docs/version-4.0.0/running-keploy/java-tls-capture.md @@ -0,0 +1,162 @@ +--- +id: java-tls-capture +title: Enable Java TLS Capture in Kubernetes +sidebar_label: Java TLS Capture +description: Why Java HTTPS calls need Keploy's in-JVM JSSE agent in Kubernetes, how to enable it in the k8s-proxy Helm chart, how to re-record in the dashboard, and how to verify capture. +tags: + - kubernetes + - k8s proxy + - java + - tls + - recording + - troubleshooting +keywords: + - keploy java tls capture + - java_tls_not_captured + - keploy jsse javaagent + - k8s-proxy jvmAgent + - java https recording kubernetes + - sunjsse tls capture +--- + +import ProductTier from '@site/src/components/ProductTier'; + + + +When Keploy records traffic in Kubernetes with eBPF, native TLS libraries +(OpenSSL, BoringSSL, Go `crypto/tls`) are captured directly at the library +boundary. Java's built-in TLS stack (SunJSSE / `javax.net.ssl`) encrypts +payloads inside the JVM before bytes reach the kernel socket, so native eBPF +uprobes cannot read plaintext Java HTTPS calls. + +To capture HTTPS traffic from Java workloads, Keploy attaches a lightweight +in-JVM agent (`keploy-jsse-agent.jar`) via `-javaagent` when recorded pods +start. If a recorded Java pod makes outbound HTTPS calls without that agent +active (or unable to reach the Keploy capture listener), Keploy reports a +`java_tls_not_captured` capture warning and pauses auto-replay for the affected +test sets so incomplete mocks do not cause false failures. + +--- + +## Enable Java TLS capture in the Helm chart + +### DaemonSet mode (`daemonset.enabled=true`) + +Java TLS capture is **enabled by default** in the `k8s-proxy` chart +(`daemonset.jvmAgent.enabled: true`): + +- **At pod admission (recommended):** the `k8s-proxy` mutating webhook mounts a + read-only ConfigMap volume at `/keploy-jsse` containing + `keploy-jsse-agent.jar` and sets `-javaagent` in `_JAVA_OPTIONS` on recorded + containers (leaving your image's `JAVA_TOOL_OPTIONS` untouched). Non-JVM + processes ignore `_JAVA_OPTIONS`. +- **At container startup (fallback):** the DaemonSet node agent also injects + the jar and preload constructor into matched JVM containers when the cgroup is + created. + +If a Java workload is reporting `java_tls_not_captured`, make sure Java TLS +capture and admission preload are enabled in your Helm release: + +```bash +helm upgrade keploy/k8s-proxy -n \ + --reuse-values \ + --set daemonset.jvmAgent.enabled=true \ + --set daemonset.scheduling.webhook.install=true +``` + +Check the following cluster settings that can prevent injection or delivery: + +1. **Admission preload disabled:** admission injection stays off when + `daemonset.namespaced=true`, `rbac.create=false`, `recording.readOnly=true`, + `daemonset.scheduling.webhook.install=false`, or + `daemonset.jvmAgent.enabled=false`, or if `KEPLOY_DS_JVM_PRELOAD=false` is + set on the `k8s-proxy` control-plane Deployment. +2. **Per-pod opt-out annotation:** remove `keploy.io/jsse-inject: "false"` from + any pod template whose Java HTTPS traffic you want recorded. +3. **Loopback port conflict:** by default (`daemonset.jvmAgent.podListener.enabled: true`), + each recorded JVM sends captured plaintext over a per-pod transport + (`127.0.0.1:16790` loopback, or a Unix socket in the pod's `/dev/shm` when + the DaemonSet runs without `CAP_SYS_ADMIN`). Because traffic stays local to + the pod, cluster NetworkPolicies do not block it. Port `16790` is reserved on + `127.0.0.1` inside recorded JVM pods; if your application binds `16790`, + override it with `--set daemonset.jvmAgent.podListener.port=`. +4. **Node-listener fallback and NetworkPolicies:** sandboxed runtimes (such as + Kata or gVisor) or clusters that set + `daemonset.jvmAgent.podListener.enabled=false` fall back to sending captured + TLS plaintext to the node's DaemonSet listener. In that setup, ensure your + NetworkPolicy or host firewall allows pod-to-own-node egress to the + DaemonSet JSSE listener port. + +### Sidecar mode (`daemonset.enabled=false`) + +In Sidecar mode with low-latency recording enabled, the `k8s-proxy` admission +webhook automatically stages `keploy-jsse-agent.jar` into a shared `emptyDir` +volume and injects `-javaagent` into the application container when recording +starts. Ensure the pod is not opted out with `keploy.io/jsse-inject: "false"` +and that the deployment rolls onto the mutated pod when you start recording. + +--- + +## Re-record from the Keploy Dashboard + +Java TLS capture is configured on the cluster rather than as a per-run UI +toggle. Because a JVM only loads `-javaagent` at process startup, pods that were +already running before Java TLS capture was enabled must be re-recorded: + +1. Open the **Recordings** page in the Keploy Dashboard and stop the affected + recording if it is still running. +2. Start a new recording for the Java deployment. Keploy restarts the targeted + pods under capture so each JVM starts with `keploy-jsse-agent.jar` attached. +3. If you intentionally want to replay an older paused recording without its + missing Java HTTPS mocks, open the **Auto-replay paused** notice in the + dashboard and select **Replay anyway**. + +--- + +## Verify Java TLS capture is active + +### 1. Check the recorded Java pod + +Inspect a pod running under an active recording: + +```bash +kubectl exec -n -- sh -c ' + env | grep -E "JAVA_TOOL_OPTIONS|_JAVA_OPTIONS" + ls -l /keploy-jsse/ /keploy/ 2>/dev/null +' +``` + +You should see `-javaagent:...keploy-jsse-agent.jar` in `_JAVA_OPTIONS` +(admission injection) or `JAVA_TOOL_OPTIONS` (node preload), with +`keploy-jsse-agent.jar` present in `/keploy-jsse/` or `/keploy/`. + +### 2. Check the DaemonSet agent logs + +In DaemonSet mode, inspect the data-plane agent logs on the pod's node: + +```bash +kubectl logs -n -l app.kubernetes.io/component=data-plane --tail=100 \ + | grep -iE "JSSE|JVM PRELOAD" +``` + +At startup, the agent logs `JSSE: per-pod capture transports` confirming that +`podLoopback` or `podUnixSocket` is ready. If the preload could not attach +`-javaagent`, the log reports `JVM PRELOAD DECLINED` or +`JVM PRELOAD BAIL OBSERVED` along with the reason (for example, JVM option +limits or missing permissions). + +### 3. Confirm clean capture in the dashboard + +Send HTTPS requests through the recorded Java service and verify that: + +- Outbound HTTPS dependencies appear as mocks in the newly recorded test set. +- No `java_tls_not_captured` warning or **Auto-replay paused** banner appears + for the new recording. + +--- + +## Related + +- [Kubernetes Live Record & Replay using Keploy Proxy](/docs/quickstart/k8s-proxy/) +- [K8s Proxy DaemonSet Architecture & Auto-Replay Environments](/docs/running-keploy/k8s-proxy-daemonset-architecture/) +- [Fix "could not record an app's bytes" warnings](/docs/running-keploy/capture-loss/) diff --git a/versioned_sidebars/version-4.0.0-sidebars.json b/versioned_sidebars/version-4.0.0-sidebars.json index 8233df557..1bd3b18a6 100644 --- a/versioned_sidebars/version-4.0.0-sidebars.json +++ b/versioned_sidebars/version-4.0.0-sidebars.json @@ -172,7 +172,8 @@ "quickstart/k8s-proxy-developer-workflow", "quickstart/k8s-proxy-llm-workflow", "keploy-cloud/smart-set-agent", - "running-keploy/k8s-proxy-daemonset-architecture" + "running-keploy/k8s-proxy-daemonset-architecture", + "running-keploy/java-tls-capture" ] }, { From 69299ec3e100348db3c9b2986363ba79ded0085d Mon Sep 17 00:00:00 2001 From: slayerjain Date: Tue, 1 Dec 2026 03:42:30 +0530 Subject: [PATCH 2/2] docs(k8s-proxy): clarify port 16790 lifecycle and sidecar jsse-inject opt-in Signed-off-by: slayerjain --- .../running-keploy/java-tls-capture.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/versioned_docs/version-4.0.0/running-keploy/java-tls-capture.md b/versioned_docs/version-4.0.0/running-keploy/java-tls-capture.md index bd7ca9deb..541d753b2 100644 --- a/versioned_docs/version-4.0.0/running-keploy/java-tls-capture.md +++ b/versioned_docs/version-4.0.0/running-keploy/java-tls-capture.md @@ -77,9 +77,11 @@ Check the following cluster settings that can prevent injection or delivery: each recorded JVM sends captured plaintext over a per-pod transport (`127.0.0.1:16790` loopback, or a Unix socket in the pod's `/dev/shm` when the DaemonSet runs without `CAP_SYS_ADMIN`). Because traffic stays local to - the pod, cluster NetworkPolicies do not block it. Port `16790` is reserved on - `127.0.0.1` inside recorded JVM pods; if your application binds `16790`, - override it with `--set daemonset.jvmAgent.podListener.port=`. + the pod, cluster NetworkPolicies do not block it. Keploy opens the loopback + listener on `127.0.0.1:16790` **before your application starts** (and keeps + it bound for the life of the pod's network namespace, so a container restart + does not release it); if your application needs port `16790`, set + `--set daemonset.jvmAgent.podListener.port=`. 4. **Node-listener fallback and NetworkPolicies:** sandboxed runtimes (such as Kata or gVisor) or clusters that set `daemonset.jvmAgent.podListener.enabled=false` fall back to sending captured @@ -91,8 +93,10 @@ Check the following cluster settings that can prevent injection or delivery: In Sidecar mode with low-latency recording enabled, the `k8s-proxy` admission webhook automatically stages `keploy-jsse-agent.jar` into a shared `emptyDir` -volume and injects `-javaagent` into the application container when recording -starts. Ensure the pod is not opted out with `keploy.io/jsse-inject: "false"` +volume and injects `-javaagent` into the application container when it detects a +JVM workload and recording starts. If your JVM isn't detected (for example, +behind a custom entrypoint), set `keploy.io/jsse-inject: "true"` on the pod +template. Ensure the pod is not opted out with `keploy.io/jsse-inject: "false"` and that the deployment rolls onto the mutated pod when you start recording. ---