Policy Rule Structure: CCA practice questions
Every Cilium policy, namespaced or cluster-wide, is built from the same Rule type. A CiliumNetworkPolicy carries one rule in spec or a list of rules in specs, the latter being handy when several rules should be added or removed as a unit.
By Ibrahim Yesilay · Published · Updated
Independent community practice, not affiliated with or endorsed by CNCF or The Linux Foundation.
What Policy Rule Structure covers in CCA
Every Cilium policy, namespaced or cluster-wide, is built from the same Rule type. A CiliumNetworkPolicy carries one rule in spec or a list of rules in specs, the latter being handy when several rules should be added or removed as a unit. Each rule has a selector, an ingress list, an egress list, optional deny lists, labels and a free-text description.
The selector is either an endpointSelector, based on the Kubernetes LabelSelector and matched against endpoint labels, or a nodeSelector, matched against node labels. The two are mutually exclusive, one of them must be set, and nodeSelector is only valid in a CiliumClusterwideNetworkPolicy, where it creates a host policy. A rule that has neither an ingress nor an egress section does nothing.
Ingress rules name allowed sources and egress rules name allowed destinations. The L3 part can be fromEndpoints/toEndpoints, entities, fromNodes/toNodes when node selector labels are enabled, CIDR lists and CIDR sets with exceptions, toServices for Kubernetes Services, or toFQDNs for DNS names. toFQDNs is restrictive: an egress rule that uses it cannot also contain toEndpoints, toCIDR or another L3 selector, though it may carry toPorts. The older fromRequires and toRequires fields were removed in Cilium 1.19.
The L4 part lives in toPorts. Each entry lists ports with a number or a named port, an optional endPort for ranges, and a protocol of TCP, UDP or ANY. ICMP is not matched there but in a separate icmps field, whose entries give a type as a number or CamelCase name and a family of IPv4 or IPv6. For TLS, serverNames under toPorts limits the SNI a pod may use, which requires the L7 proxy.
The L7 part is a rules block inside a toPorts entry. It is a union: http or dns, never both for one port. When several rules with the same port select overlapping endpoints, L7 rules of the same type are merged and different types cause the policy to be rejected. HTTP rules match method, path and host as extended POSIX regular expressions, plus required headers. DNS rules use matchName or matchPattern, where an asterisk matches any characters except the dot, so it stays within one label, and a leading **. matches subdomains at any depth.
Labels identify rules. Policies imported from Kubernetes automatically get io.cilium.k8s.policy.name set to the resource name, which tooling uses to find or delete them.
Key points
- endpointSelector and nodeSelector are mutually exclusive; nodeSelector needs a cluster-wide policy.
- Port ranges use port plus endPort; ICMP types go in icmps, not toPorts.
- One port carries either http or dns L7 rules; mixing types for overlapping endpoints rejects the policy.
- A toFQDNs egress rule may hold toPorts but no other L3 selector.
Three sample questions
10 CCA questions on Policy Rule Structure, 10 with explanations. How practice works
Question 1
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
name: "secure-api"
spec:
endpointSelector:
matchLabels:
app: api
ingress:
- fromEndpoints:
- matchLabels:
app: frontend- A.metadata
- B.ingress
- C.endpointSelector
- D.fromEndpoints
Correct answer: C
Question 2
- A.toCIDR
- B.toFQDNs
- C.toEndpoints
- D.toDNS
Correct answer: B
Question 3
- A.All ingress and egress of the selected pods is denied
- B.None; the rule has no effect
- C.All ingress is denied and egress stays allowed
- D.The API server rejects the policy as invalid
Correct answer: B
Sources: CNCF CCA curriculum (CCA_Curriculum.pdf), Cilium docs: Policy Enforcement Modes, Cilium docs: Policy Enforcement
Practice this topic
Focus mode keeps every question on Policy Rule Structure until you leave it. 10 free guest answers, then a free account; no credit card.
Or open CCA practice across all topics.
Sources
The explanation above was checked against these official documents.
- Cilium docs: Policy Enforcement Modes (checked 2026-10-28)
- Cilium docs: Layer 3 Policies (checked 2026-10-28)
- Cilium docs: Layer 4 Policies (checked 2026-10-28)
- Cilium docs: Layer 7 Policies (checked 2026-10-28)