Skip to content

feat(kubernetes): pod and container attribution for connections#299

Merged
domcyrus merged 1 commit into
mainfrom
feat/kubernetes-attribution
Jul 6, 2026
Merged

feat(kubernetes): pod and container attribution for connections#299
domcyrus merged 1 commit into
mainfrom
feat/kubernetes-attribution

Conversation

@domcyrus

Copy link
Copy Markdown
Owner

Add an optional kubernetes feature (off by default, no extra dependencies) that attributes connections to their owning pod and container on a node:

  • cgroup parser maps a PID to pod UID + container ID via /proc//cgroup
  • cross-namespace socket-table walker reads per-PID /proc//net/{tcp,udp}, which is netns-aware, so pod-owned sockets are attributed under hostNetwork
  • pod/container names resolved from the kubelet log directories (/var/log/containers, /var/log/pods): runtime-agnostic, no CRI socket and no kubelet auth
  • surfaced in the TUI details pane, JSONL and PCAP exports, and the pod:, ns:, container: filter keywords

The container image enables the feature by default via the CARGO_FEATURES build-arg; native installs stay default-off.

@domcyrus
domcyrus force-pushed the feat/kubernetes-attribution branch 3 times, most recently from 209a1f9 to 8bed755 Compare May 21, 2026 19:53
@domcyrus
domcyrus force-pushed the feat/kubernetes-attribution branch from 8bed755 to 8287159 Compare July 3, 2026 08:46
Add an optional `kubernetes` feature (off by default, no extra dependencies)
that attributes connections to their owning pod and container on a node:

- cgroup parser maps a PID to pod UID + container ID via /proc/<pid>/cgroup
- cross-namespace socket-table walker reads per-PID /proc/<pid>/net/{tcp,udp},
  which is netns-aware, so pod-owned sockets are attributed under hostNetwork
- pod/container names resolved from the kubelet log directories
  (/var/log/containers, /var/log/pods): runtime-agnostic, no CRI socket and no
  kubelet auth
- surfaced in the TUI details pane, JSONL and PCAP exports, and the pod:, ns:,
  container: filter keywords
- `--kubernetes <auto|on|off>` controls it at runtime; `auto` (the default)
  enables only when running inside a pod, detected via KUBERNETES_SERVICE_HOST
- Landlock read access extended to the kubelet log dirs when enabled, so name
  resolution keeps working under the sandbox

The container image is built with the feature enabled (CARGO_FEATURES build-arg);
native installs (cargo/brew/deb/rpm) leave it off and stay lean.
@domcyrus
domcyrus force-pushed the feat/kubernetes-attribution branch from 8287159 to 4bacb3d Compare July 3, 2026 08:49
@domcyrus
domcyrus merged commit 531a5ad into main Jul 6, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant