GKE Dataplane V2: Scaling Cilium identities with labels and annotations

In GKE Dataplane V2 (DPv2), the networking stack is powered by Cilium. One of its core strengths is an identity-based security model. Instead of managing firewall rules for thousands of IP addresses, Cilium assigns a numeric identity to every pod based on its security labels.

Understanding how these identities are allocated is crucial for building high-scale clusters and avoiding performance bottlenecks.

How labels transform into identities

When you create a pod, Cilium parses its labels and maps them to a unique 24-bit numeric ID. This ID is what travels with your network packets, allowing nodes to enforce policies with minimal overhead.

The 24-bit identity space

Cilium uses a 32-bit integer for identities, but only 24 bits are used on the wire. This space is divided to ensure efficiency:

  • Bits 0-15: The cluster-local identity (allowing up to 65,535 global identities per cluster).

  • Bit 24: The “Local Scope” flag. If this bit is set, the identity is node-local (used for external CIDRs or FQDNs).

Wait, what about Bits 16-23? In upstream Cilium, these bits are reserved for ClusterMesh (multi-cluster identities). Even though GKE Dataplane V2 is a managed environment and doesn’t expose ClusterMesh, the underlying identity allocator still respects this 16-bit boundary for cluster-local identities. This is why you have a hard limit of 65,535 global identities per cluster.

Real-world example: The scaling trap

Let’s see how metadata choices impact identity allocation using the cilium-dbg CLI inside a GKE DPv2 node.

1. The ideal case: Shared identities

When pods share the same labels, they share the same identity.

Pod frontend-a:


metadata:

labels:

app: frontend

env: prod

Checking the identity:


# Inside anetd pod

cilium-dbg endpoint list | grep frontend-a

# Output: default/frontend-a 29980

2. The scaling trap: Unique labels

Some CI/CD tools add a unique label (like a build ID) to every pod. This forces Cilium to create a new identity for every single pod.

Pod frontend-b:


metadata:

labels:

app: frontend

env: prod

build-id: "v1.0.123" # Unique per deployment/pod

Checking the identity:


cilium-dbg endpoint list | grep frontend-b

# Output: default/frontend-b 44632

If you have 10,000 pods each with a unique label, you consume 10,000 identities. This increases memory usage on every node and puts immense pressure on the Kubernetes API server as CiliumIdentity resources churn.

3. The performance win: Using annotations

Cilium ignores annotations when calculating identities. If you need to track metadata that doesn’t affect network policy, use an annotation.

Pod frontend-c:


metadata:

labels:

app: frontend

env: prod

annotations:

build-id: "v1.0.456" # Unique tracking ID

Checking the identity:


cilium-dbg endpoint list | grep frontend-c

# Output: default/frontend-c 29980

Even though frontend-c has a unique ID, it shares identity 29980 with frontend-a. This is the key to scaling to thousands of pods without breaking the network control plane.

Local identities and CIDRs

Not everything has a label. When you define a NetworkPolicy allowing traffic to an external IP, Cilium allocates a Local Identity.

NetworkPolicy snippet:


egress:

- to:

- ipBlock:

cidr: 1.1.1.1/32

This triggers an allocation in the local scope:


cilium-dbg identity list | grep 1.1.1.1

# Output: 16777218 cidr:1.1.1.1/32

The ID 16777218 in binary is 1 00000000 00000000 00000010. The 24th bit is set, signaling to the data path that this is a node-local identity.

Best practices for GKE DPv2

  1. Labeling: Only use labels that are required for NetworkPolicy selection.

  2. Move Tracking to Annotations: Use annotations for timestamps, commit hashes, or unique IDs.

  3. Monitor Identity Count: Use kubectl get ciliumidentities to keep an eye on your cluster’s global identity consumption.

  4. Avoid Churn: Frequent creation and deletion of unique identities can lead to API server latency and increased CPU usage on nodes.

By understanding the 16-bit cluster-local limit and choosing annotations over labels for metadata, you can ensure your GKE Dataplane V2 cluster scales smoothly to meet any workload.

4 Likes