Skip to content

feat(dpv2policy): add Dataplane V2 network policy log feature - #1259

Merged
kyasbal merged 4 commits into
mainfrom
push-ustqwvvvkroy
Nov 17, 2026
Merged

kyasbal merged 4 commits into
mainfrom
push-ustqwvvvkroy

Conversation

@kyasbal

@kyasbal kyasbal commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds a dedicated Dataplane V2 Network Policy Logs feature that visualizes GKE Dataplane V2 network policy logs (logs/policy-action of the k8s_node resource type) on the timelines of the source and destination Pods and the network policies that decided each connection.

This is the first PR of a stack that adds GKE Dataplane V2 (Cilium / anetd) log support:

  1. This PR (feat(dpv2policy): add Dataplane V2 network policy log feature #1259): dpv2policy, a new feature for policy-action logs (excluded from k8snode)
  2. feat(k8snode): link cilium-cni logs in container runtime logs to Pods #1260 k8snode: link cilium-cni logs in the container runtime log to Pods
  3. feat(k8scontainer): enrich cilium-agent logs with subsystem, level and Pod references #1261 k8scontainer: enrich cilium-agent logs with subsystem, level and Pod references
  4. feat(k8saudit): show CiliumEndpoint under the owning Pod timeline #1262 k8saudit: show CiliumEndpoint under the owning Pod timeline

Motivation

  • policy-action logs were fetched by the Kubernetes node log query, but they have no MESSAGE field. They showed up with empty summaries under Node/<node>/policy-action and were not linked to the Pods or the policies involved.
  • During network troubleshooting, users want to see which connections were allowed or denied, between which Pods, and by which policy, next to the Pod lifecycle.

Changes

  • New feature package pkg/task/inspection/googlecloud/dpv2policy/: contract (task IDs, extractor, log type, timeline types and paths) and impl/ (query, ingester, grouper, mapper, module), with README en/ja.
    • Feature title "Dataplane V2 Network Policy Logs", order 3500, disabled by default. Available for the same inspection types as the Kubernetes node logs.
    • Query: resource.type="k8s_node" and LOG_ID("policy-action"). The shared node name filter also applies.
  • Summary and severity: [DENY x6] ingress TCP <ns>/<pod>:<port> -> <ns>/<pod>:<port> (implicit deny), (by NetworkPolicy <ns>/<name>), (by ClusterNetworkPolicy <name>, reserved:deny-any-ingress). A rule that Cilium lists more than once is shown once. Denials use the WARNING severity so that dropped connections stand out.
  • Timeline mapping:
    • The outbound timeline (type netpol) under the source Pod and the inbound timeline under the destination Pod. Remote Pods without workload fields are still linked by namespace and name.
    • The timeline of each NetworkPolicy, FQDNNetworkPolicy and ClusterNetworkPolicy resource. Resources are resolved first by the UID in the Cilium policy labels (via k8saudit.ResourceUIDInventoryTaskID), then by known API versions.
    • The policy-action timeline under the reporting Node only when neither endpoint is a Pod.
  • k8snode: excluded LOG_ID("policy-action") from the node log query.
  • No .khi compatibility concerns: no new enums, and timeline type styles are serialized in each .khi file.

Screenshots

Verified against network policy logs generated on a GKE Autopilot cluster with Dataplane V2 and network policy logging enabled (3,121 policy-action logs: 19 denials and 3,102 allowed connections).

📷 Screenshot 1 — e2e_policy_action_overview.png: netpol outbound/inbound timelines under each Pod and the NetworkPolicy / FQDNNetworkPolicy / ClusterNetworkPolicy timelines. Orange markers are denials.

image

📷 Screenshot 2 — e2e_policy_deny.png: denials only. A ClusterNetworkPolicy denial is linked to the policy and to both Pods.

image

Verification

  • make pre-commit
  • make build-go && make lint-go && make test-go (including the task graph conformance tests for every inspection type)
  • Ran the feature on real network policy logs together with the Kubernetes audit, event, node and container logs. Checked the timelines, summaries and policy resolution with the KHI MCP tools.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements GKE Dataplane V2 network policy log inspection tasks under the new googlecloud/dpv2policy package, allowing policy-action logs to be parsed and mapped to Pod, network policy, and Node timelines. It also updates the general k8snode query to exclude these logs. The reviewer feedback recommends removing a redundant defensive nil check on the required reader parameter in ExtractPolicyAction to align with project guidelines, as well as removing the corresponding test case that would otherwise panic.

@kyasbal
kyasbal added this pull request to stack #1263 November 12, 2026 01:56
Add a dedicated inspection feature for GKE Dataplane V2 network policy logs (logs/policy-action of the k8s_node resource type). Each log is linked to the outbound and inbound network policy timelines of its source and destination Pods, to the NetworkPolicy, FQDNNetworkPolicy and ClusterNetworkPolicy resources that decided the connection, and to the reporting Node when neither endpoint is a Pod. Policy resources are resolved by the UID recorded in the Cilium policy labels when audit logs know it, and by known API versions otherwise. The summary shows each policy rule once even when Cilium lists it more than once.

Exclude policy-action logs from the Kubernetes node log query because they have no message field and were shown with empty summaries under the node timelines.
@github-actions

Copy link
Copy Markdown

Code Quality Report — ✅ Cloud Build success

Cloud Build completed without an embedded report envelope.


Commit: b12e2b3c1d93 · Cloud Build Logs

@kyasbal
kyasbal added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit e0eef4d Nov 17, 2026
22 checks passed
@kyasbal
kyasbal deleted the push-ustqwvvvkroy branch November 17, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant