Skip to content

Add PxL UDFs to look up the host IP of a pod - #2414

Open
NopeCharon wants to merge 1 commit into
pixie-io:mainfrom
NopeCharon:add-pod-host-ip-udfs
Open

NopeCharon wants to merge 1 commit into
pixie-io:mainfrom
NopeCharon:add-pod-host-ip-udfs

Conversation

@NopeCharon

Copy link
Copy Markdown
Contributor

Summary: Add PxL UDFs to look up the host IP of a pod

As described in the issue, PxL scripts can look up the node name of a pod with px.pod_id_to_node_name, but there is no way to get the node's IP address. That makes it hard to filter out traffic that comes from the node itself, such as kubelet liveness, readiness and startup probes.

The metadata service already sends the pod's status.hostIP to the agents in PodUpdate.host_ip, but the agents only used it to keep host network pods out of the IP to pod lookup. This PR stores the host IP in PodInfo and adds two UDFs that return it:

  • px.pod_id_to_host_ip(pod_id)
  • px.pod_name_to_host_ip(pod_name)

Like the other pod metadata UDFs, both return an empty string if the pod is unknown. For the use case in the issue, a script can now do:

df = px.DataFrame('http_events', start_time='-5m')
df.host_ip = px.pod_id_to_host_ip(df.ctx['pod_id'])
df = df[df.remote_addr != df.host_ip]

Relevant Issues: Fixes #1251

Type of change: /kind feature

Test Plan: Added pod_id_to_host_ip_test and pod_name_to_host_ip to //src/carnot/funcs/metadata:metadata_ops_test, and a host_ip() check to the HandlePodUpdate test in //src/shared/metadata:metadata_state_test. I could not run the Bazel targets locally because my build machine is aarch64 and the toolchain needs an x86_64 host, so I'm relying on CI for those. The new code follows the existing pod_name_to_pod_ip and pod_id_to_node_name UDFs. clang-format is clean on the changed files and cpplint reports nothing new.

Changelog Message:

Added the `px.pod_id_to_host_ip` and `px.pod_name_to_host_ip` PxL functions, which return the IP address of the node a pod runs on.

PxL scripts can look up the node name of a pod, but not the IP address
of that node. This makes it hard to filter out traffic that originates
from the node, such as kubelet liveness and readiness probes, which
arrive from the node's IP address.

The metadata service already sends the pod's status.hostIP to the
agents in PodUpdate.host_ip, but the agents only used it to filter
host network pods out of the IP to pod lookup. PodInfo now stores the
host IP, and two new UDFs expose it:

- px.pod_id_to_host_ip(pod_id)
- px.pod_name_to_host_ip(pod_name)

Both return an empty string if the pod is unknown, like the other pod
metadata UDFs.

Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
@NopeCharon
NopeCharon requested review from a team as code owners October 27, 2026 07:02

This branch is waiting to be deployed

1 waiting deployment
pr-actions-approval — b3366a80 Waiting Oct 27, 2026 by NopeCharon via authorize #3146
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.

Feature request: Discover node IP from PxL script

1 participant