5 Things you didn’t know about Cilium Network Polices

Christian Hernandez

Published: April 27, 2026

Not all CNIs are created equal, and many assume that CiliumNetworkPolicies are the same as standard Kubernetes NetworkPolicies. At first glance, they can look similar. You define selectors, specify ingress or egress rules, and control which workloads can talk to each other. But once you look a little closer, it becomes clear that Cilium is operating at a very different level. Built on eBPF, Cilium moves policy enforcement into the kernel and attaches identity directly to workloads, unlocking capabilities that go well beyond what traditional CNIs were designed to handle.

Book: Kubernetes Network Policies Done The Right Way

Microsegmentation in Kubernetes starts with network policies - but getting them right is harder than it looks. Many clusters remain wide open, relying on broad or incomplete rules that offer little real protection against lateral movement. Our guide, Kubernetes Network Policies Done the Right Way, explains how to design and enforce policies that reflect real traffic patterns, align with zero-trust principles, and scale across hybrid environments.

Learn how to move from theory to practical enforcement with Cilium and Hubble Enterprise, and see how observability and automation turn segmentation into a continuous process rather than a one-time configuration.

For NetOps Engineers, this is where things get interesting. If you are comfortable with subnets, ACLs, and basic L3/L4 filtering, Cilium expands that model into identity aware, application-aware, and even DNS aware controls. It is not just about allowing traffic between IPs anymore. It is about defining intent based on service accounts, enforcing policies cluster-wide, filtering traffic by domain names, inspecting HTTP requests at Layer 7, and getting deep observability without bolting on a separate tool.

In this blog, we will walk through five things you may not realize Cilium Network Policies can do that set them apart from standard Kubernetes networking.

Identity Based Model

Before we jump into hands-on policy examples, let’s first walk through the security model that makes Cilium different from traditional IP based enforcement.

Kubernetes gives every Pod its own IP address. That model is simple and avoids NAT, but it also means a busy cluster can have a very large and constantly changing set of IP addresses. Enforcing security the traditional way with IP based rules, you can run into scale problems. For example, allowing role=frontend Pods to talk to role=backend Pods means every node hosting a backend Pod must maintain a list of all frontend Pod IPs. Every time a Pod is created or deleted, those IP based rules must be updated across the cluster. In high churn environments, that can mean frequent rule updates and even delays while policies converge within the cluster.

Cilium takes a different approach by separating security from IP addresses and tying it to identity derived from Kubernetes labels. Each set of labels maps to a numeric security identity, and policies are enforced based on those identities instead of individual IPs. When a new role=frontend Pod starts, it reuses the existing identity associated with that label set. Backend nodes do not need their rules rewritten for every new frontend IP. Only the identity needs to be resolved, which reduces rule churn and improves scalability while keeping policy aligned with Kubernetes semantics.

You can see this being more powerful when you take into consideration that Cilium can inject a Layer 4 proxy into any network connection, transparently. This is used as the foundation to enforce higher level network policies and enable other L7 capabilities via Envoy.

With that in mind, let’s go over some example Cilium Network Policies that extend the standard Kubernetes Networking Policies.

Cluster Wide CiliumNetworkPolcies

Using Cilium as a CNI gives you the ability to do cluster level policies. At a glance, the key difference between CiliumNetworkPolicy and CiliumClusterwideNetworkPolicy comes down to scope. CiliumNetworkPolicy is namespace scoped and is usually managed by application teams to control traffic for their own workloads.

CiliumClusterwideNetworkPolicy applies across the entire cluster and is evaluated no matter which namespace a workload lives in. This cluster wide policy concept does not exist in standard Kubernetes NetworkPolicy, where every rule must be defined and maintained at the namespace level.

A good use of a CiliumClusterwideNetworkPolicy, is to prevent any Pod from accessing the cloud metadata service, which is a frequent target in container breakouts.

apiVersion: cilium.io/v2
kind: CiliumClusterwideNetworkPolicy
metadata:
  name: deny-cloud-metadata
spec:
  endpointSelector: {}
  egressDeny:
  - toCIDR:
    - 169.254.169.254/32

Once applied, all Pods are denied egress to the cloud metadata service, working as a global guardrail for the entire cluster.

$ kubectl exec -it \
deploy/webapp -- curl --fail-early --connect-timeout 5 http://169.254.169.254

curl: (28) Failed to connect to 169.254.169.254 after 5001 ms: Timeout was reached

These cluster-level policies shine when you need consistent, platform level barriers that should be applied for any workload in your setup. As you saw in the example, It is well suited for things like blocking access to cloud metadata endpoints, but can be used for enforcing egress restrictions, protecting core infrastructure services, or setting a default zero trust posture across the cluster. Because these policies are defined once and enforced globally, they reduce duplication and configuration drift, especially in multi-tenant environments. For platform and security teams, this fills an important gap left by standard Kubernetes NetworkPolicies and provides a much cleaner way to express and enforce global networking policies.

CiliumNetworkPolicies by ServiceAccount

Cilium’s support for ServiceAccount based network policies brings a more human idea of identity into Kubernetes networking. Instead of trusting pod labels or chasing changing IPs, policies can be written around which ServiceAccount a workload runs as. This makes it a much approachable way to apply zero-trust principles inside the cluster, where only explicitly trusted workloads can reach sensitive services. Since ServiceAccounts tend to be stable and already tied to RBAC, these policies are not only stronger from a security perspective but also simpler to reason about and maintain.

To see this in action, I have a sample pod webapp, deployed to my Kubernetes cluster:

$ kubectl get sa,svc,deploy,pods -l app=webapp
NAME                       AGE
serviceaccount/webapp-sa   27m

NAME             TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)   AGE
service/webapp   ClusterIP   10.96.11.50   <none>        80/TCP    27m

NAME                                READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/webapp-deployment   1/1     1            1           27m

NAME                                     READY   STATUS    RESTARTS   AGE
pod/webapp-deployment-654cd8c566-6q24b   1/1     Running   0          21m

This webapp can be accessed by other workloads in the namespace:

$ kubectl exec -it \
good-pod -- curl --fail-early --connect-timeout 5  webapp/public
[
  {
    "id": 1,
    "body": "public information"
  }
]

However, I may not want all workloads within a namespace to access this webapp:

$ kubectl exec -it \
bad-pod -- curl --fail-early --connect-timeout 5  webapp/public
[
  {
    "id": 1,
    "body": "public information"
  }
]

I can mitigate this by only allowing workloads running as a specific serviceAccount to access my webapp, for example:

apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
  name: "k8s-svc-account"
spec:
  endpointSelector:
    matchLabels:
      io.cilium.k8s.policy.serviceaccount: webapp-sa
  ingress:
  - fromEndpoints:
    - matchLabels:
        io.cilium.k8s.policy.serviceaccount: good
    toPorts:
    - ports:
      - port: '80'
        protocol: TCP
      rules:
        http:
        - method: GET
          path: "/public$"

Note, I’m only allowing workloads running as the serviceAccount named good to access workloads running as the serviceAccount named webapp-sa.

With this applied, I ensure my workload is running as the serviceAccount that is allowed:

$ kubectl get pod good-pod -o jsonpath='{.spec.serviceAccountName}{"\n"}'
good

I should still be able to access the webapp from this Pod:

$ kubectl exec -it \
good-pod -- curl --fail-early --connect-timeout 5  webapp/public
[
  {
    "id": 1,
    "body": "public information"
  }
]

While the others are denied access via this CiliumNetworkPolicy:

$ kubectl exec -it \
bad-pod -- curl --fail-early --connect-timeout 5  webapp/public

curl: (28) Failed to connect to webapp port 80 after 5000 ms: Timeout was reached
command terminated with exit code 28

In practice, this approach shines in multi-tenant setups or platform environments or whenever a Kubernetes cluster is shared by different workloads. It helps cleanly separate workload traffic from controllers and infrastructure components, and it significantly reduces the risk of lateral movement if a pod is compromised. For NetworkOps teams, ServiceAccount aware policies feel familiar, closer to identity based access control than traditional IP rules, while fitting naturally into how Kubernetes already models trust.

DNS based CiliumNetworkPolicies

Cilium’s policy language supports things like DNS and FQDN based rules, explicit deny rules, and even L7 controls for HTTP methods. Unlike standard Kubernetes policies that only allow you to work with IPs, ports, and namespaces, Cilium lets you have finer grained control over policies. An important part of Cilium’s approach is its DNS policy that lets you write rules based on domain names instead of hard-coding IP addresses.

For example, if I want to restrict a workload to only have access to a specific API endpoint by DNS name, I can apply the following policy:

apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
  name: allow-catfact-only
  namespace: demo
spec:
  endpointSelector: {}
  egress:
  - toEndpoints:
      - matchLabels:
         "k8s:io.kubernetes.pod.namespace": kube-system
         "k8s:k8s-app": kube-dns
    toPorts:
      - ports:
          - port: "53"
            protocol: ANY
        rules:
          dns:
            - matchName: "*"
  - toFQDNs:
      - matchName: "catfact.ninja"
    toPorts:
      - ports:
          - port: "80"
            protocol: TCP
          - port: "443"
            protocol: TCP

This will allow access to the DNS name of the service, even if the IP address is changed:

$ kubectl -n demo exec -it \
deploy/webapp -- curl https://catfact.ninja/fact
{"fact":"A cat's brain is more similar to a human's brain than that of a dog.","length":66}

The rule then goes on only allowing queries to the specified endpoints. All others are denied:

$ kubectl -n demo exec -it \
deploy/webapp -- curl https://dogapi.dog/api/v2/facts

curl: (6) Could not resolve host: dogapi.dog
command terminated with exit code 6

Cilium does this by observing DNS responses and dynamically tracks the IPs associated with those names, applying policy based on the resolved addresses while respecting DNS TTLs and configured match patterns.This approach makes policies easier to read and maintain, especially when dealing with external services whose IPs change frequently. This makes Cilium network policies fit naturally into modern Kubernetes environments where services are dynamic, identities matter more than addresses, and networking needs to keep up with the pace of application change.

Layer 7 CiliumNetworkPolicies

Cilium allows you to enforce Layer 7 rules on top of the standard network controls, meaning you can filter traffic not just by IPs and ports, but by application level protocols like HTTP. With HTTP rules, you can specify which URLs, methods, or headers are allowed or denied between workloads.

For example, you could allow traffic to a service only if it’s a GET request to a specific endpoint, while blocking all other requests.

apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
  name: "allow-public-get"
spec:
  description: "Allow HTTP GET /public from app=client to app=webapp"
  endpointSelector:
    matchLabels:
      app: webapp
  ingress:
  - fromEndpoints:
    - matchLabels:
        app: client
    toPorts:
    - ports:
      - port: "80"
        protocol: TCP
      rules:
        http:
        - method: "GET"
          path: "/public"

This will allow access to the /public endpoint:

$ kubectl exec -it client-pod -- curl http://webapp/public
[
  {
    "id": 1,
    "body": "public information"
  }
]

This goes beyond typical firewall-style controls, however, as you can see with the 403 error.

$ kubectl exec -it client-pod -- curl -I http://webapp/private
HTTP/1.1 403 Forbidden
content-length: 15
content-type: text/plain
date: Wed, 11 Feb 2026 00:58:45 GMT
server: envoy

This lets you set traffic based rules on actual application behavior, not just network topology.

Under the hood, Cilium uses envoy to assist with inspection HTTP requests in real time. Policies can be applied at the pod or cluster level, and they combine seamlessly with identity-based endpoint selectors. This allows you to create fine-grained, zero-trust style controls for microservices. HTTP rules can also be combined with DNS or FQDN rules (shown above), so you can enforce that only certain services are reachable and only in the ways you explicitly allow. For NetOps engineers, who are accustomed to ACLs, this feels like adding context aware inspection to your network filters, making Kubernetes workloads much safer and more predictable.

Observability is Built In

One of the powerful advantages of running Cilium as your CNI is that you automatically get Hubble, which is our “batteries included” observability platform. There’s no separate agent to deploy, no sidecar to manage, and no additional setup required. Hubble is powered directly by Cilium’s eBPF datapath, which means observability is effectively “for free” as soon as Cilium is installed. It gives you deep visibility into network flows, DNS queries, HTTP requests, and even Layer 7 policy decisions, all without modifying your applications. Instead of guessing why traffic is being dropped or allowed, you can see the exact flow events in real time.

Hubble also provides multiple ways to consume that visibility. The Hubble CLI feels very similar to tcpdump, letting you filter live traffic by namespace, pod, labels, protocols, or verdicts like DROPPED and FORWARDED.

For instance, I can use the hubble CLI to see any traffic that has been DROPPED to a specific workload:

$ hubble observe \
--verdict DROPPED \
--to-pod default/webapp-deployment-654cd8c566-hzhvv -o compact

Feb 12 00:02:13.782: default/bad-pod:42006 (ID:5748) <> default/webapp-deployment-654cd8c566-hzhvv:80 (ID:4749) policy-verdict:none INGRESS DENIED (TCP Flags: SYN)
Feb 12 00:02:13.782: default/bad-pod:42006 (ID:5748) <> default/webapp-deployment-654cd8c566-hzhvv:80 (ID:4749) Policy denied DROPPED (TCP Flags: SYN)
Feb 12 00:02:30.166: default/bad-pod:42006 (ID:5748) <> default/webapp-deployment-654cd8c566-hzhvv:80 (ID:4749) policy-verdict:none INGRESS DENIED (TCP Flags: SYN)
Feb 12 00:02:30.166: default/bad-pod:42006 (ID:5748) <> default/webapp-deployment-654cd8c566-hzhvv:80 (ID:4749) Policy denied DROPPED (TCP Flags: SYN)
Feb 12 00:03:02.422: default/bad-pod:42006 (ID:5748) <> default/webapp-deployment-654cd8c566-hzhvv:80 (ID:4749) policy-verdict:none INGRESS DENIED (TCP Flags: SYN)
Feb 12 00:03:02.422: default/bad-pod:42006 (ID:5748) <> default/webapp-deployment-654cd8c566-hzhvv:80 (ID:4749) Policy denied DROPPED (TCP Flags: SYN)

Another great thing is the ability to see protocols such as DNS communication:

$ hubble observe --protocol dns --last 7
Mar  3 17:43:01.775: demo/webapp-deployment-654cd8c566-jng87:46848 (ID:3231) -> kube-system/coredns-7d764666f9-f4x2d:53 (ID:65398) dns-request proxy DROPPED (DNS Query catfact.ninja.demo.svc.cluster.local. A)
Mar  3 17:43:01.775: demo/webapp-deployment-654cd8c566-jng87:46848 (ID:3231) -> kube-system/coredns-7d764666f9-f4x2d:53 (ID:65398) dns-request proxy DROPPED (DNS Query catfact.ninja.demo.svc.cluster.local. A)
Mar  3 17:43:01.775: demo/webapp-deployment-654cd8c566-jng87:46848 (ID:3231) -> kube-system/coredns-7d764666f9-f4x2d:53 (ID:65398) dns-request proxy DROPPED (DNS Query catfact.ninja.demo.svc.cluster.local. AAAA)
Mar  3 17:43:01.775: demo/webapp-deployment-654cd8c566-jng87:60221 (ID:3231) -> kube-system/coredns-7d764666f9-grvrk:53 (ID:65398) dns-request proxy FORWARDED (DNS Query catfact.ninja. AAAA)
Mar  3 17:43:01.775: demo/webapp-deployment-654cd8c566-jng87:60221 (ID:3231) -> kube-system/coredns-7d764666f9-grvrk:53 (ID:65398) dns-request proxy FORWARDED (DNS Query catfact.ninja. A)
Mar  3 17:43:01.776: demo/webapp-deployment-654cd8c566-jng87:60221 (ID:3231) <- kube-system/coredns-7d764666f9-grvrk:53 (ID:65398) dns-response proxy FORWARDED (DNS Answer "104.21.65.30,172.67.188.187" TTL: 30 (Proxy catfact.ninja. A))
Mar  3 17:43:01.776: demo/webapp-deployment-654cd8c566-jng87:60221 (ID:3231) <- kube-system/coredns-7d764666f9-grvrk:53 (ID:65398) dns-response proxy FORWARDED (DNS Answer "2606:4700:3030::6815:411e,2606:4700:3031::ac43:bcbb" TTL: 30 (Proxy catfact.ninja. AAAA))

This built-in feature is incredibly useful for debugging policies or understanding workload to workload communication in Kubernetes.

On top of that, Hubble offers a rich UI that visually maps service interactions, making it easy to see dependencies and spot issues at a glance. It also has the ability to build CiliumNetworkPolcies in the UI as well!

For teams adopting a zero trust model with Cilium, Hubble completes the story by showing not just what should happen according to policy, but what is actually happening in the cluster.

Summary

Cilium Network Policies are not just a drop-in replacement for standard Kubernetes NetworkPolicies, they are a superset. They extend the model in ways that better match how modern clusters operate. By shifting from IP-based thinking to identity, DNS awareness, application context, and built-in observability, Cilium gives platform and security teams stronger controls without adding operational complexity. For Kubernetes professionals with a networking background, this is a natural evolution. The fundamentals still apply, but the controls are more granular, more dynamic, and more aligned with zero trust principles.

Want to see these in action? Check out the demo video below!

5 Things you didn’t know about Cilium Network Polices

/authors/christian-hernandez

Christian Hernandez, Technical Marketing Engineer