NetworkPolicy objects for the Admin Server and the
Admin UI. They are off by default and recommended for production.
They are off by default because a cluster whose CNI does not implement
NetworkPolicy accepts the objects and enforces nothing. Shipping them enabled
would advertise isolation that some clusters silently do not provide. Enable
them once you have confirmed your CNI enforces policy.
What the policies allow
Both policies setpolicyTypes: [Ingress, Egress], so everything not listed
below is denied.
Namespaces are matched on the
kubernetes.io/metadata.name label, which
Kubernetes sets on every namespace from version 1.21 onward. You do not need to
label your ingress controller or monitoring namespaces by hand.
Prometheus scrapes /metrics on the same port that serves the API, so the
monitoring rule opens no additional port.
Flows that deliberately have no rule
Admin UI to Admin Server
Admin UI to Admin Server
The Admin UI container serves static files. It never proxies to the API —
your browser calls the Admin Server directly through the ingress. The Admin
UI therefore needs no egress rule to the Admin Server, and the generated
policy denies that path.
Admin Server to database pods
Admin Server to database pods
The Admin Server reads database metrics and logs through the API server’s
pods/proxy and pods/log endpoints, not by connecting to database pods.
All of that traffic is already covered by the API server egress rule, so no
rule to the database pod range is generated.Kubelet health probes
Kubelet health probes
Readiness and health probes originate on the node, and every CNI that
enforces
NetworkPolicy permits them so that pods can pass their probes.
No rule is required and none is generated.Narrowing external egress
networkPolicy.externalEgress covers two destinations that a policy cannot
name: the Kubernetes API server and, when adminServer.env.oauthProvider
is set, the identity provider. NetworkPolicy matches on CIDR only. It has no
concept of a host name, so neither destination is expressible by name.
The default is deliberately wide:
Identity provider egress
Each provider’s requirements are listed with its setup instructions:Google OAuth
Egress requirements and the Private Google Access address ranges.
Microsoft Entra ID
Egress requirements for Entra ID and Microsoft Graph.
Extra rules
Anything the generated rules do not cover goes in theextraIngress and
extraEgress lists, which are appended verbatim as additional items under
ingress: and egress:. Each entry is therefore a complete rule with its own
from/to and ports, not a bare peer:
Verify enforcement
First confirm your CNI enforces policy at all. Create two pods, deny traffic to one, and check that the connection stops working:networkPolicy.enabled will not protect
anything.
networkPolicy.externalEgress does not cover your
control plane endpoint.