Skip to content

feat(k8saudit): show CiliumEndpoint under the owning Pod timeline - #1262

Merged
kyasbal merged 3 commits into
push-zwspwslosuqzfrom
push-onrkxyrnyvxz
Nov 17, 2026
Merged

kyasbal merged 3 commits into
push-zwspwslosuqzfrom
push-onrkxyrnyvxz

Conversation

@kyasbal

@kyasbal kyasbal commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

Shows the CiliumEndpoint of a Pod under the Pod timeline (owns → <pod>[kind:ciliumendpoint]), even when audit logs do not record the CiliumEndpoint manifest.

Stacked on #1261. Part of the GKE Dataplane V2 log support stack.

Motivation

The Cilium agent creates a CiliumEndpoint with the same namespace and name as its Pod and sets the Pod as the owner. The owner reference mapper linked it to the Pod only when audit logs recorded its manifest with ownerReferences. Audit logs often record custom resources at the Metadata level without bodies, so the CiliumEndpoint stayed in a separate cilium.io/v2 > ciliumendpoint timeline, away from the Pod lifecycle.

Changes

  • common/k8saudit/impl/mapper_owner_reference.go: added podOwnedTypesByName = {"cilium.io#ciliumendpoint"}. Resources of these types are aliased under the Pod with the same namespace and name, whether or not their manifests are recorded.
  • The alias path is the same as the one derived from ownerReferences in the manifest, so both rules point to the same timeline (no duplicates or errors; covered by tests).
  • Updated the k8saudit README en/ja.

Screenshots

Verified on real audit logs: the CiliumEndpoint appears under its Pod with the same revisions as the cilium.io/v2 timeline.

📷 Screenshot — e2e_pod_lifecycle_cilium.png (same image as #1260): the owns row payment-api-…[kind:ciliumendpoint] under the Pod, next to the cilium-agent, cilium-cni and network policy events.

image

Verification

  • make pre-commit
  • make build-go && make lint-go && make test-go
  • Ran the Kubernetes audit logs feature on a real Dataplane V2 cluster and checked the owns alias 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 introduces a mechanism to link resources owned by a Pod with the same namespace and name (such as CiliumEndpoint) to their parent Pods, even when audit logs do not record their manifests. This is achieved by updating resourceOwnerReferenceTimelineMapperTask to support a podOwnedTypesByName map and adding the isOwnedByPodWithSameName helper function. Corresponding documentation and unit tests have been added. The review feedback suggests optimizing isOwnedByPodWithSameName by replacing fmt.Sprintf with string concatenation to avoid unnecessary allocations in a hot path, normalizing apiVersion to handle core resources consistently, and using case-insensitive comparison for resource kinds.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Code Quality Report — ✅ Cloud Build success

Cloud Build completed without an embedded report envelope.


Commit: 7cdc92754104 · Cloud Build Logs

The Cilium agent creates a CiliumEndpoint with the same namespace and name as its Pod and sets the Pod as the owner. The owner reference mapper linked the CiliumEndpoint to the Pod only when audit logs recorded its manifest, but audit logs often record custom resources without their bodies.

Link resources of the declared types to the Pod with the same namespace and name regardless of their manifests. The alias path is the same as the one derived from the ownerReferences in the manifest, so both rules point to the same timeline. This shows the creation and the deletion of the CiliumEndpoint next to the lifecycle of the Pod.
… nil check

Extract parseOwnerIdentity from ProcessLog to keep cognitive complexity within budget, remove the redundant nil check on bodyReader (guaranteed non-nil by GetLastBodyReader when ok is true), and test missing apiVersion in ownerReferences.
@kyasbal
kyasbal added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 696908f Nov 17, 2026
22 checks passed
@kyasbal
kyasbal deleted the push-onrkxyrnyvxz 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