Skip to content
Install the CLI

Concept Policy, networking, and operations

Network policy

Maintaining default-deny Kubernetes network policies across a cluster is tedious and easy to break. Letting one web service query one database normally requires an outbound rule in the caller’s namespace, a matching inbound rule in the database’s namespace, and a DNS rule so the caller can resolve the hostname. When you enable generated network policy in Kix, Kix builds both ends of those firewall rules from the service connections your packages already declare.

By default in Kubernetes, every pod can reach every other pod across every namespace. When network policy generation is enabled, Kix writes a default-deny policy in every namespace where it deploys workloads. Unmatched inbound and outbound traffic is blocked there, while cloud system namespaces stay untouched so provider-managed agents keep working.

Each service connection in the dependency graph then opens a narrow path on both ends. The calling workload gets an outbound rule to the target Service’s pod labels and ports (plus cluster DNS), and the target workload gets a matching inbound rule from that caller’s pods and namespace. Because Kix compiles the whole cluster together, both policies update together whenever ports, namespaces, or pod labels change.

Kix also orders every workload after the network policies that select its pods. During deployment, policies apply before new pods start. During pruning, pods finish shutting down and clearing finalizers before Kix removes their network policies and API server access.

How Kix discovers connections from endpoint facts

Section titled “How Kix discovers connections from endpoint facts”

Not every reference between Kubernetes manifests represents network traffic. Mounting a ConfigMap or naming a ServiceAccount affects deploy order without opening any port, whereas reading a database Service’s hostname or URL means a pod will dial that endpoint at runtime.

Kix tracks that difference on output values. Address outputs carry endpoint metadata alongside their text, and ConfigMaps or Secrets pass that metadata onward to whichever Deployment, StatefulSet, DaemonSet, or Job mounts or reads them. When a workload consumes that address, Kix knows both the caller and the target Service and opens the matching port between them.

Kix also derives rules for standard Kubernetes traffic patterns without extra configuration:

  • Cluster DNS and the Kubernetes API server: Workloads with egress policies get access to the cluster’s DNS endpoints, and workloads whose ServiceAccount has RBAC role bindings get outbound access to the Kubernetes API server.
  • Public load balancers, gateways, peers, and metrics: External LoadBalancer Services and ingress or gateway routes open inbound access to the backend ports they expose. StatefulSets get peer-to-peer rules so replicas can form a cluster, and Prometheus or VictoriaMetrics scrape monitors open matching paths between the collector and target pods.
  • Cloud workload identities: Pods whose ServiceAccount uses AWS, Google Cloud, or Azure workload identity get the outbound rules needed to fetch short-lived tokens from the cloud identity endpoint or node metadata server.

Kix writes policy resources matching the network policy enforcer in your cluster, and fails local checks if network policy is enabled without an enforcer.

When Cilium runs in the cluster, Kix generates Cilium network policies using pod, node, and cluster-entity selectors, and adds cluster-wide DNS and health-probe policies when Cilium enforces rules across every pod in the cluster. On Google Kubernetes Engine (with Dataplane V2) and Amazon EKS (with Amazon VPC CNI network policy enabled), Kix generates standard Kubernetes NetworkPolicy objects instead.

Standard Kubernetes NetworkPolicy has no built-in selectors for cluster nodes, the API server, or external addresses, so Kix represents those targets with IP CIDR blocks from your cluster network settings. When cloud subnet layouts make an IP CIDR rule allow broader in-cluster traffic than intended, Kix’s scorecard warns when setting a cluster CIDR option can narrow the rule and records unavoidable platform limits as informational notes.

A dependency graph sees connections between resources inside your Kix build. Two kinds of traffic sit outside that graph: calls to or from external addresses (such as public HTTPS APIs or admission webhooks called by the API server), and pods created at runtime by an operator from a custom resource.

Kix covers both without dropping default-deny isolation. Packages that call external endpoints or serve admission webhooks declare those intents once in the package definition, and operator packages attach operand policies selecting the pod labels their operator creates. For pods managed outside Kix, you can declare platform intents in the cluster configuration.

Next, read Scorecard levels to see how Kix separates always-on reference checks from phased security and reliability rules. For Cilium and GKE/EKS CIDR behavior, platform limits, and configuration options, see Cluster configuration: Network policy and Enable generated network policy.