Kubernetes traffic logs are only useful when they retain workload identity
A flow record can tell you which IP addresses exchanged traffic. In Kubernetes, that may be the least useful part of the story: pods scale, restart, and move between nodes, taking their IP addresses with them. By the time you investigate an entry such as `10.4.2.18` connecting to `10.4.8.44`, the pods behind those addresses may already be gone. That’s why workload attribution matters. Google Cloud’s [VPC Flow Logs](https://docs.cloud.google.com/vpc/docs/using-flow-logs) can attach [Google Kubernetes Engine](https://docs.cloud.google.com/kubernetes-engine/docs/concepts/kubernetes-engine-overview) metadata to sampled network flows, including the pod, workload, namespace, and service associated with an IP. You can see who communicated at the network layer without installing extra agents or sidecars. For deeper in-cluster detail, flow logs can sit alongside the CNI and dataplane observability tools you already use.What the metadata tells you
When VPC Flow Logs are enabled on a subnet hosting a GKE cluster, sampled pod traffic can carry the Kubernetes context associated with each IP at the time of sampling. That context remains useful after a pod disappears. Records can identify the cluster and its location; the pod, namespace, and owning controller, such as a Deployment, StatefulSet, or DaemonSet; and the Kubernetes service receiving the traffic. Standard VPC fields also include the node VM and zone at each end of a flow. There’s another layer if your GKE workloads are registered in [App Hub](https://docs.cloud.google.com/app-hub/docs/overview?e=48754805). Flow records can then include `apphubSource` and `apphubDestination` labels for the business application, environment, and criticality of each endpoint. That can help connect the dots when a cluster service talks to a registered resource outside the cluster, such as a Cloud Run service.Set up the data before querying it
Flow Analyzer reads from a log bucket upgraded to [Observability Analytics](https://cloud.google.com/network-intelligence-center/docs/flow-analyzer/enable-log-analytics), formerly Log Analytics. The `_Default` bucket is a common choice, but the upgrade is permanent: ```sh gcloud logging buckets update _Default \ --location=global \ --enable-analytics ``` You can enable VPC Flow Logs across an organization with one configuration covering subnets in every VPC network, including those used by clusters created later. This requires the Network Management Admin role. Keep `include-all-metadata` enabled to capture pod and namespace details. To manage cost and volume, you can also set a sampling rate with `--flow-sampling`, an aggregation interval with `--aggregation-interval`, or a filter with `--filter-expr`. ```sh gcloud network-management vpc-flow-logs-configs create CONFIG_NAME \ --location=global \ --organization=ORGANIZATION_ID \ --metadata=include-all-metadata ``` GKE Standard clusters also need [intranode visibility](https://cloud.google.com/kubernetes-engine/docs/how-to/intranode-visibility) enabled; Autopilot clusters already have it. Enabling the feature restarts control plane and node components and adds some per-node overhead, so try it on a non-production cluster first. ```sh gcloud container clusters update CLUSTER_NAME \ --location=LOCATION \ --enable-intra-node-visibility ```Turn flow records into useful answers
VPC Flow Logs send records to Cloud Logging, where you can search them in Logs Explorer or Log Analytics. For day-to-day analysis, [Flow Analyzer](https://docs.cloud.google.com/network-intelligence-center/docs/flow-analyzer/overview), part of Network Intelligence Center, presents the same data as an interactive chart and table. You can group or filter by cluster, namespace, workload, pod, or service. The examples here use [Online Boutique](https://github.com/GoogleCloudPlatform/microservices-demo), an open-source microservices demo running on a GKE Autopilot cluster in `us-central1`. A `loadgenerator` deployment sends synthetic shopper traffic to `frontend`. The frontend calls `productcatalogservice`, `cartservice`, `currencyservice`, `recommendationservice`, `shippingservice`, `adservice`, and `checkoutservice`.Map communication by workload
When you’re investigating an incident or reviewing an architecture change, start with a simple question: which workloads are talking, and how much traffic are they exchanging? Grouping flows by Kubernetes workload replaces shifting IP addresses with names you can act on. In Flow Analyzer, open **Network Intelligence Center > Flow Analyzer** and select **last 1 hour**. Set both **Source** and **Destination** to organize flows by **GKE workload**, add the **GKE workload is known** filter to show pod-to-pod traffic, then run the query.
*Grouping traffic by source and destination GKE workload in Flow Analyzer maps microservice dependencies without raw IP lookups.*
Sort the results by volume and the table becomes a practical dependency map. Here, `frontend` receives requests from `loadgenerator`, while `productcatalogservice` gets calls from both `recommendationservice` and `frontend`. Workload names also make unexpected communication easier to spot.
Trace callers of a specific service
If a service is slowing down or you’re planning a change, you’ll want to know which workloads depend on it and how much traffic each sends. In Flow Analyzer, change **Traffic aggregation** to **Client ↔ server (bidirectional)** so requests and responses count together. Under **Server**, filter **GKE workload** to `productcatalogservice`; run the query and open **Details** on the top row.
*Filtering for `productcatalogservice` with bidirectional aggregation shows caller share and a timeline for each client-server pair.*
The results show each caller’s share of the catalog service’s traffic and a timeline for each pair. If one caller’s traffic rises while the others stay steady, you have a useful lead. For latency analysis, switch the display mode to latency to rank those same callers by round-trip time.
Find traffic crossing zone boundaries
In a regional GKE cluster, services placed in different zones can exchange traffic across zone boundaries, adding inter-zone data transfer charges. VPC Flow Logs include the zone at both ends of a flow, which helps identify the pod pairs responsible. Switch Flow Analyzer from **Basic filters** to **SQL filters**, then enter `src_gcp_zone dest_gcp_zone` in the **WHERE** box. Organize flows by **Source GCP zone**, **Source GKE pod**, **Destination GCP zone**, and **Destination GKE pod**.Cross-zone traffic has a clear fix
The biggest value of this query is that it turns a cluster-wide traffic bill into a list of specific pod pairs. In this cluster, the busiest cross-zone flow runs between a frontend pod in us-central1-b and a currencyservice pod in us-central1-c. checkoutservice, shippingservice and productcatalogservice pairs follow. The table ranks those flows by volume and shows the zones at both ends.
If you need to dig into a flow, choose Explore in Log Analytics to open its SQL query. From there, you can customize it with joins or time buckets. GKE also offers a direct way to favor local traffic: set trafficDistribution: PreferSameZone on the Service. Older GKE versions use PreferClose. That setting prefers healthy endpoints in the caller’s zone, but each zone still needs enough replicas to handle its own requests.
Know what the logs can’t show
VPC Flow Logs have limits that matter when you interpret the results. For pod-to-internet traffic, the masquerade agent replaces the pod IP with the node IP before sampling, so the logs won’t include pod annotations. Keeping internal destinations in the non-masquerade list preserves pod names for those flows. If ip-masq-agent runs with intranode visibility, include the cluster’s node and pod IP ranges in that list to avoid connectivity problems.
Network policy blocks happen before traffic reaches the VPC network, so VPC Flow Logs won’t reveal them. Use NetworkPolicy logging to investigate blocked traffic.
Flow logs are sampled, too. Their byte and packet counts can help rank and track traffic over time, but they aren’t a reliable record of every connection.
Put the walkthroughs to work
If VPC Flow Logs are already enabled for your clusters, upgrade the _Default bucket and open Flow Analyzer to reproduce the three walkthroughs. The practical lesson is straightforward: the logs can point you toward costly cross-zone paths, while the sampling and visibility limits tell you how far to trust the numbers.