Excluded namespaces
About 471 words
spec.defaultDeny.exclude lists namespaces the default deny leaves alone. Their pods accept and send anything, as they did before the policy. This page explains what that means for the rest of the policy, and when to use it.
spec:
type: policy
cluster: resource:prod
defaultDeny:
exclude: [kube-system]What changes, and what doesn't
The default-deny policy selects every pod whose namespace isn't on the list:
endpointSelector:
matchExpressions:
- key: io.kubernetes.pod.namespace
operator: NotIn
values:
- kube-systemPods in an excluded namespace aren't in default deny, so nothing is dropped for them. Everything else stays the same:
- Endpoints in an excluded namespace are still endpoints. They get their
allow-…policy, with every flow. The console marks them Open namespace,backstage-cilium-renderprints(open)in front of them, and their policy's description ends inIts namespace is left out of the default deny: this only allows.Since the allow policies setenableDefaultDeny: false, these change nothing while the namespace is open. - Their flows are allowed on the other end. If an enforced endpoint reaches an endpoint in an excluded namespace, the enforced side gets its egress rule as usual. Open or not, the catalog's flows are in the manifests, so taking a namespace off the list enforces exactly what the catalog says.
- FQDN destinations get their own DNS rule, because the pods don't get the one in
default-deny. FQDN rules and the DNS proxy explains why.
An endpoint counts as excluded when all of its namespaces are. One that's spread over an excluded namespace and an enforced one is half-enforced, which is rarely what you want, and the policy warns.
What to leave open
kube-system is the usual start. It holds the cluster DNS, Cilium itself, and the cloud provider's controllers, many on the host network (which a policy can't select anyway). Its traffic is the cluster's own plumbing, and modelling every flow of it buys little.
Beyond that, exclusion is a rollout tool: start with a long list and shorten it as the catalog catches up, as described in Turn on the default deny. A namespace that stays on the list for good is one whose pods can reach anything on your cluster, so keep the list short and the reasons known.
What exclusion is not
It's not a way to exempt one workload. The list holds namespaces, and an endpoint can't opt out on its own. If one workload in an enforced namespace needs to reach anything, say so with a rule entity to entity:all, where the owner of the policy can see it.
