⚡ ~/naveed Tech Blog
⚡ Portfolio Home ✍️ Engineering Blog Deep Dives 🎯 Interview Hub 1,000+ Scenarios ☸️ Kubernetes Mastery Hub 24 Modules 🎮 DevOps Arcade & Quizzes Subnet Blitz ⚡ 🗺️ DevOps Roadmaps PDFs & Guides 🤖 Morpheus Analysis AI Quant ↗ 🛠️ Developer Tools Utilities 🧪 Labs & Experiments 📄 Interactive CV & Certs 🔗 All Links & Socials ⚡ Join The Dispatch (Weekly SRE Newsletter) →

Kubernetes Ingress vs Egress: How to Lock Both Cluster Doors

Kubernetes ingress vs egress diagram showing a routed front door and a policy controlled back door

Kubernetes ingress vs egress comes down to one question: which way is the traffic moving from the Pod? Ingress is traffic coming in, egress is traffic going out, and the defaults are not symmetrical. Inbound traffic needs a route before it reaches your Pods, while outbound traffic is open until a NetworkPolicy isolates the Pod. This guide shows how to control both directions with working YAML, DNS safe rollout steps and tests you can run before production traffic depends on the result.

Kubernetes ingress vs egress comes down to one question: which way is the traffic moving from the Pod? Ingress is traffic coming in, egress is traffic going out, and the defaults are not symmetrical. Inbound traffic needs a route before it reaches your Pods, while outbound traffic is open until a NetworkPolicy isolates the Pod. This guide shows how to control both directions with working YAML, DNS safe rollout steps and tests you can run before production traffic depends on the result.

What Is Kubernetes Ingress vs Egress in Plain Terms?

Kubernetes ingress vs egress describes traffic direction from the Pod. Ingress traffic arrives at a Pod from a user, a Service or another Pod. Egress traffic leaves a Pod toward a database, an internal service or an external API. The same connection is egress for the sender and ingress for the receiver, so both ends matter.

Picture the cluster as a building with two doors. The front door handles visitors coming in. The back door handles staff going out to suppliers, banks and partner offices. Most teams spend their time on the front door because that is where users arrive, load balancers sit and TLS certificates get renewed. The back door gets far less attention, even though every workload uses it all day.

In Kubernetes terms, ingress traffic is any connection that arrives at a Pod. A browser request that lands on your web Pod is ingress. A call from your web Pod to your API Pod is ingress for the API Pod. Egress traffic is any connection a Pod starts. The web Pod calling the API Pod is egress for the web Pod, and the API Pod calling a payment provider is egress for the API Pod.

That dual view is the part engineers miss during incidents. When a connection fails under NetworkPolicy, the question is never only whether the destination allows it. The source Pod needs an egress rule that allows the connection, and the destination Pod needs an ingress rule that allows it, when both Pods are isolated in those directions. Reply packets for an allowed connection are handled by the data plane, so you write rules for who may open connections, not for responses.

The front door is usually closed by default in a practical sense. Nothing outside the cluster reaches a Pod until you expose it through a Service, an Ingress, a Gateway API route or a load balancer. The back door works the other way. A Pod that no NetworkPolicy selects can open connections to other Pods, to node addresses and to the public internet. That asymmetry is the whole security story in this post, and it is why egress control deserves the same design time as inbound routing.

A useful mental model for reviews: ingress answers who may reach this workload, egress answers where this workload may go. If your design documents only answer the first question, the second answer is currently anywhere.

Network engineers also split this traffic into north-south and east-west flows. North-south traffic crosses the cluster boundary, such as a user request arriving at the web tier or the payments Pod calling an external API. East-west traffic stays inside, such as the web Pod calling the API Pod or the API Pod querying the database. Ingress and egress rules apply to both kinds, because direction is measured at the Pod rather than at the cluster edge. A Pod to Pod call inside one namespace is still egress for the sender and ingress for the receiver, which is why internal traffic needs the same policy attention as internet traffic.

⚡ EXCLUSIVE SRE & KUBERNETES PLAYBOOK

The 970+ Incident Handbook & K8s Runbooks are exclusive to subscribers — unlock for FREE

Get battle-tested production runbooks, AWS architecture blueprints, and zero-downtime CI/CD post-mortems sent directly to your inbox. 100% free, no spam.

How Does Kubernetes Ingress vs Egress Differ by Default?

The default behaviour differs sharply. Inbound access needs an explicit Service, Ingress or Gateway API route before external traffic reaches a Pod. Outbound access is open until a NetworkPolicy selects the Pod for egress. NetworkPolicy isolation is per direction, policies are additive allow lists, and enforcement depends on the CNI plugin in your cluster.

The comparison below is the reference most teams need during design reviews. It separates routing, which decides where traffic goes, from policy, which decides whether traffic may flow at all. Confusing those two layers is how clusters end up with a polished front door and an unguarded back door.

AspectIngressEgress
DirectionTraffic arriving at a PodTraffic a Pod initiates
Typical sources and targetsUsers, load balancers, other PodsDatabases, internal services, external APIs
External exposure defaultClosed until a Service, Ingress or Gateway route exposes the workloadOpen to cluster and internet destinations until policy isolates the Pod
Main routing controlsIngress, Gateway API, Service type LoadBalancerService DNS names, egress gateways, NAT and proxy settings
Main policy controlNetworkPolicy ingress rulesNetworkPolicy egress rules, CNI FQDN policy
Common failureRoute or TLS misconfiguration returns 404 or 503Default deny without a DNS allowance breaks name resolution
Security questionWho may reach this workload?Where may this workload connect?

Three NetworkPolicy rules explain nearly every surprise in this area. First, Pods start non-isolated: with no policy selecting a Pod, all traffic in both directions is allowed. Second, isolation is per direction: a policy that selects a Pod and lists Ingress in policyTypes restricts inbound traffic, while outbound traffic stays open until an egress policy selects the same Pod. Third, policies are additive allow lists with no deny rules and no ordering, so the allowed traffic is the union of every policy that selects the Pod.

One more rule decides whether any of this matters in your cluster. NetworkPolicy is an API contract, and the CNI plugin enforces it. Calico and Cilium both enforce NetworkPolicy in production clusters. A plugin without policy support accepts the objects and ignores them, which means your YAML can look correct while traffic stays open. Managed clusters differ here, so verify enforcement on your own cluster with a test Pod instead of trusting a feature list.

Why Does Kubernetes Ingress vs Egress Matter After a Pod Compromise?

Egress control limits what a compromised Pod can do next. With open egress, an attacker can send data to an external server, download tooling and keep a command channel running. With an egress allow list, the same Pod can reach only named destinations, which turns a full exfiltration path into a blocked connection attempt.

Ingress controls decide how an attacker gets in. Egress controls decide how much damage the attacker can do after getting in. A single compromised Pod with open egress can send database extracts to any server on the internet, download extra tooling from a public host, and maintain a quiet connection to an attacker controlled endpoint. None of those actions needs inbound access, which is why a strong front door does not compensate for an open back door.

Consider a checkout service that talks to a payments database inside the cluster and to one external payment API. With an egress allow list, that Pod can resolve DNS, reach the payments database on its port, and reach the payment API on port 443. A call to an unknown host fails at connection time. The attacker still has a compromised Pod to deal with, but the easiest exfiltration and command paths are closed, and the blocked attempts become visible in policy logs where your CNI supports them.

Egress control also limits lateral movement inside the cluster. A frontend Pod that has no business talking to the database directly should not be able to open that connection, even if an attacker finds a way to run code in it. NetworkPolicy expresses that boundary with labels: the database accepts connections from the API tier, and the frontend tier has no egress rule toward the database at all.

Be honest about the limits while you design this. Egress policy does not fix a vulnerable application, does not inspect encrypted payloads, and does not stop data leaving through an allowed destination that an attacker can abuse. It is one layer that shrinks the blast radius and buys detection time. That is a worthwhile trade for a control that costs a few YAML files per namespace.

How Do You Route Kubernetes Ingress vs Egress Traffic at the Front Door?

Front door routing uses Ingress or Gateway API to send external requests to Services by host and path. A Gateway owns the listener and TLS settings, and an HTTPRoute maps paths such as / and /cart to backend Services. Routing decides where traffic goes; NetworkPolicy still decides whether the receiving Pod may accept it.

Inbound routing answers a narrow question: given a host and a path, which Service receives the request? The classic Ingress resource answers it with rules that an ingress controller implements. Gateway API splits the job into roles: a GatewayClass names the controller, a Gateway defines listeners and TLS, and an HTTPRoute attaches routing rules to a Gateway. The example below routes the root path to a web Service and the cart path to a cart Service.

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: shop-gateway
  namespace: shop
spec:
  gatewayClassName: eg
  listeners:
    - name: https
      protocol: HTTPS
      port: 443
      hostname: shop.example.com
      tls:
        mode: Terminate
        certificateRefs:
          - name: shop-tls
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: shop-routes
  namespace: shop
spec:
  parentRefs:
    - name: shop-gateway
  hostnames:
    - shop.example.com
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /cart
      backendRefs:
        - name: cart
          port: 8080
    - matches:
        - path:
            type: PathPrefix
            value: /
      backendRefs:
        - name: web
          port: 8080

If your cluster still runs Ingress NGINX, the migration path, controller choices and cutover checks are covered in our kubernetes gateway api migration guide. If you are choosing the proxy layer itself, the trade-offs between the common options are in our caddy vs nginx vs traefik reverse proxy comparison.

Keep the layering clear while you work. The route above makes the web and cart Pods reachable from outside. It does not decide which Pods may talk to each other inside the namespace, and it does not restrict what those Pods may call. Those decisions belong to NetworkPolicy, which is where the next sections spend their time.

How Do You Lock Kubernetes Ingress vs Egress With Default Deny?

Start with a default deny egress policy that selects every Pod in the namespace and allows nothing, then add a DNS allowance to kube-dns on UDP and TCP port 53. Policies are additive, so the DNS rule restores name resolution while every other outbound connection stays blocked until you allow it by name.

The safe starting point for egress control is a policy that selects all Pods in a namespace, lists Egress in policyTypes, and contains no egress rules. That object is the foundation of the kubernetes egress networkpolicy pattern used through the rest of this guide. Because isolation starts on selection, that single object turns outbound traffic from open to denied for every Pod it selects, including Pods created later.

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny-egress
  namespace: shop
spec:
  podSelector: {}
  policyTypes:
    - Egress

Apply that on its own and name resolution breaks immediately, because CoreDNS runs in kube-system and the new policy blocks the path to it. Applications keep running and keep failing lookups after timeouts, which sends responders toward CoreDNS while the real cause sits in the policy they just applied. The fix is a second policy that allows egress to the DNS Pods on both UDP and TCP port 53. TCP matters because large DNS responses fall back to it.

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-dns-egress
  namespace: shop
spec:
  podSelector: {}
  policyTypes:
    - Egress
  egress:
    - to:
        - namespaceSelector:
            matchLabels:
              kubernetes.io/metadata.name: kube-system
          podSelector:
            matchLabels:
              k8s-app: kube-dns
      ports:
        - protocol: UDP
          port: 53
        - protocol: TCP
          port: 53

Two details in that manifest carry most of the weight. The namespaceSelector and podSelector sit in the same list item, which means AND: DNS Pods inside kube-system. Split them into two list items and the rule becomes OR, which allows far more than intended. And the port in a policy is the Pod port after Service translation, so rules must name the container port your workload listens on, not the Service port in front of it.

Roll this out one namespace at a time rather than across the whole cluster at once. Apply the DNS allowance first, confirm lookups still work, then apply default deny, then add workload rules. That order keeps the failure window small and makes each change testable on its own.

How Do You Allow Only Needed Destinations in Kubernetes Ingress vs Egress Policies?

Write one egress rule per real dependency, scoped to the workload that needs it. A cart Pod might reach the payments database on port 5432 and nothing else, while the payments Pod reaches an external API on port 443. Standard NetworkPolicy matches labels, namespaces, IP ranges and ports, so external destinations are expressed as CIDR ranges.

Default deny plus DNS gives you a quiet namespace. The next step is one allow rule per dependency, written for the workload that owns the dependency. Resist the urge to open a broad rule for the whole namespace because one service needs it. Scoping by podSelector keeps the blast radius of a mistake inside one workload.

The cart service in the shop namespace needs the payments database and nothing else outside its own tier. Its egress rule names the database Pods by label and the database port.

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: cart-egress
  namespace: shop
spec:
  podSelector:
    matchLabels:
      app: cart
  policyTypes:
    - Egress
  egress:
    - to:
        - podSelector:
            matchLabels:
              app: payments-db
      ports:
        - protocol: TCP
          port: 5432

The database side needs the matching ingress rule, because the connection needs both ends to agree once both Pods are isolated. The database accepts connections from cart Pods on the same port and from nothing else.

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: payments-db-ingress
  namespace: shop
spec:
  podSelector:
    matchLabels:
      app: payments-db
  policyTypes:
    - Ingress
  ingress:
    - from:
        - podSelector:
            matchLabels:
              app: cart
      ports:
        - protocol: TCP
          port: 5432

External destinations are where standard NetworkPolicy runs out of vocabulary. It matches IP ranges through ipBlock, so reaching a payment API means allowing the provider address ranges on port 443. The payments workload below may reach one documented provider range and nothing else outside the cluster.

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: payments-egress
  namespace: shop
spec:
  podSelector:
    matchLabels:
      app: payments
  policyTypes:
    - Egress
  egress:
    - to:
        - ipBlock:
            cidr: 203.0.113.0/24
      ports:
        - protocol: TCP
          port: 443

Treat that address range as an example to replace with the ranges your provider publishes, and review it when the provider changes its network. The ipBlock form also supports an except list for carving addresses out of a wider range, which helps when a provider range overlaps addresses you never want to reach. This approach works while the ranges are stable and documented. It stops working when the provider serves traffic from rotating CDN addresses, because the rule chases addresses instead of naming the service. That gap is exactly what FQDN policy and egress gateways exist to close, which the next two sections cover.

How Do FQDN Rules Change Kubernetes Ingress vs Egress Control?

FQDN rules let policy name a domain instead of an IP range. With Cilium, a toFQDNs rule allows connections to addresses learned from the Pod DNS lookups, and a separate DNS rule must route queries through the Cilium DNS proxy. Calico offers domain rules through GlobalNetworkPolicy in its enterprise and cloud offerings.

A rule that says allow payments.example.com on port 443 reads the way engineers think about dependencies. Standard NetworkPolicy cannot express it, because the API matches addresses, not names. CNI specific policy fills that gap, and Cilium is the most common example in production clusters today.

Cilium FQDN enforcement has two layers, and missing either one produces a policy that looks right and blocks traffic. The DNS layer sends the Pod DNS queries through the Cilium DNS proxy, which records the addresses returned for matching names. The connection layer, written with toFQDNs, allows traffic to those learned addresses on the named ports. Allowing the DNS query does not allow the connection, and the connection rule learns nothing until the DNS proxy sees the lookup.

apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
  name: payments-egress
  namespace: shop
spec:
  endpointSelector:
    matchLabels:
      app: payments
  egress:
    - toEndpoints:
        - matchLabels:
            k8s:io.kubernetes.pod.namespace: kube-system
            k8s:k8s-app: kube-dns
      toPorts:
        - ports:
            - port: "53"
              protocol: ANY
          rules:
            dns:
              - matchPattern: "*"
    - toFQDNs:
        - matchName: payments.example.com
      toPorts:
        - ports:
            - port: "443"
              protocol: TCP

Name matching needs care during reviews, because small pattern mistakes silently widen or narrow the rule. matchName is an exact match, so payments.example.com does not cover other subdomains. matchPattern accepts wildcards, and a pattern such as *.example.com matches subdomains without matching the bare domain. The DNS proxy also needs the Cilium L7 proxy enabled, so confirm that setting before you debug a policy that never learns addresses.

Calico reaches the same goal through a different API. A GlobalNetworkPolicy can allow egress with a destination.domains list, and domain based network sets group destinations for reuse. Calico documentation places DNS policy in the enterprise and cloud offerings, trusts only listed DNS servers, and warns that domain rules do not work at egress gateway Pods. Check which tier your cluster runs before you promise domain rules to an application team.

When Does an Egress Gateway Beat NetworkPolicy for Kubernetes Ingress vs Egress?

An egress gateway wins when you need one auditable exit point for external traffic. A dedicated proxy can apply authorization, originate TLS and record every external call in one place. NetworkPolicy still matters underneath it, because policy is what stops Pods from bypassing the gateway and calling external addresses directly.

NetworkPolicy decides whether a Pod may open a connection. An egress gateway decides where external connections leave the cluster and what happens to them on the way out. Those are different jobs, and regulated environments often need both: policy blocks direct outbound paths, and the gateway becomes the single exit that security teams can monitor, allow list at the HTTP layer and place behind fixed public addresses.

In Istio terms, an egress gateway is a dedicated proxy that outbound traffic to external services must pass through. It gives you one verifiable exit point where authorization policy, observability and TLS origination apply. In ambient mode, a waypoint proxy acts as the egress gateway, and Gateway API resources route mesh traffic toward external destinations defined with ServiceEntry objects. The operational shape is the same either way: external services get named definitions, traffic flows through a small set of gateway Pods, and application Pods lose any direct path out.

Choose the gateway when at least one of these needs is real: fixed egress addresses for partner allow lists, HTTP level rules or logging on external calls, TLS origination for services that speak plain HTTP internally, or a compliance requirement for a single monitored exit. Choose plain NetworkPolicy or FQDN policy when the need is simpler, such as stopping Pods from reaching arbitrary addresses. The gateway adds moving parts, capacity planning and a new failure domain, so it should earn its place.

One boundary is worth stating plainly in every design review of this topic. Gateway API by itself is a routing API for inbound and mesh traffic. Installing Gateway API does not restrict which external addresses a Pod may call. Egress restriction still comes from NetworkPolicy, CNI policy or a mesh egress path that policy forces traffic through.

How Do You Verify Kubernetes Ingress vs Egress Rules in Production?

Verify with a test Pod that carries the same labels as the workload, because policy follows labels. Check DNS resolution, an allowed destination and a blocked destination, then read the policy objects back with kubectl. A rule set is only proven when the allowed path succeeds and the blocked path fails on purpose.

Policy that has never been tested is a hope, not a control. The test that matters uses a Pod with the same labels as the workload, because selectors match labels rather than Pod names. A debug Pod without the workload labels proves nothing about the workload path.

kubectl get networkpolicy -n shop
kubectl describe networkpolicy cart-egress -n shop
kubectl -n shop run netcheck --rm -it --restart=Never   --image=nicolaka/netshoot --labels="app=cart" -- /bin/bash

Inside the test Pod, run three checks in order. Start with DNS, because every later result depends on name resolution working. Then test the allowed destination, and finish with a destination that policy should block, using a short timeout so the test completes quickly.

nslookup payments-db.shop.svc.cluster.local
curl -m 5 -v telnet://payments-db:5432
curl -m 5 https://example.com

The expected results tell a clean story. The lookup returns an address, the database connection opens, and the external request times out. If the external request succeeds, either the CNI is not enforcing policy, another policy allows the path, or the test Pod labels do not match the selector you think they match. Each cause has a different fix, so read the policies back before changing anything.

Run the same checks after every policy change, and keep the commands in the runbook next to the manifests. Node level problems can mimic policy failures, so when Pods themselves look unhealthy, work through the checks in our kubernetes production runbook for NotReady nodes before you blame the policy layer.

For a first production rollout, stage the work over several changes instead of landing the full rule set at once. Ship the DNS allowance and the workload allow rules first, watch application error rates and DNS latency for a day, and only then apply default deny. Some CNI offerings also provide audit or staged policy modes that report what a policy would block before it blocks anything, which is worth using where your plugin supports it. The staged order feels slower, but it converts a risky flag day into a series of small, reversible steps with evidence at each one.

Why Do Kubernetes Ingress vs Egress Policies Fail in Production?

Most failures come from a short list: DNS blocked by default deny, a CNI that does not enforce policy, selectors combined with OR instead of AND, rules written against Service ports instead of Pod ports, and FQDN rules missing the DNS proxy layer. Each failure has a distinct symptom, so match the symptom before changing YAML.

NetworkPolicy failures feel mysterious because dropped packets produce timeouts rather than clear errors. The table below maps the failures we see most often to the check that separates them. Work the rows in order during an incident, since the early rows explain the majority of cases.

SymptomLikely causeCheckFix
Every name lookup times out after a policy changeDefault deny egress without a DNS allowancenslookup from the affected Pod, then list policies in the namespaceAdd the kube-dns allowance on UDP and TCP 53
Policy applied, traffic still flows everywhereCNI does not enforce NetworkPolicy, or another policy allows the pathTest from a labelled Pod and read every policy selecting itConfirm CNI enforcement, then remove or narrow the allowing policy
Rule allows far more than intendednamespaceSelector and podSelector split into separate list items, creating ORRead the peer list in the applied policyCombine both selectors in one list item for AND
Connection refused or timed out on a known ServiceRule names the Service port instead of the Pod targetPortCompare Service targetPort with the policy portUse the container port in the policy
FQDN rule never allows the external APIDNS queries bypass the Cilium DNS proxy, or L7 proxy disabledCheck the dns rule and the cilium-config enable-l7-proxy valueAdd the DNS proxy rule and enable the L7 proxy
Payment API breaks after an IP based rule shipsProvider addresses rotated behind a CDNResolve the name and compare with the ipBlock rangesMove to FQDN policy or an egress gateway

Two habits prevent most of these rows. Keep policy manifests in version control beside the workload manifests, so reviewers see the network contract change with the code change. And test in a staging namespace with the same labels and the same CNI before the policy reaches production, because enforcement behaviour is a property of the cluster, not of the YAML alone.

What Should Senior Engineers Standardise for Kubernetes Ingress vs Egress?

Standardise the sequence, not just the YAML. Every namespace gets default deny with a DNS allowance, every workload declares its egress dependencies beside its manifests, and every change ships with a labelled test Pod check. Reach for FQDN policy or an egress gateway only where IP rules cannot express the destination honestly.

The teams that keep egress control working treat it as a platform standard rather than a per incident project. The standard has five parts, and each part exists because its absence caused an outage or a security finding somewhere.

First, the namespace baseline ships by default: default deny for egress, the DNS allowance beside it, and ingress rules that name expected callers. That baseline is the kubernetes egress networkpolicy standard every new namespace inherits. New namespaces inherit the baseline from the platform template, so protection does not depend on an application team remembering it. Second, every workload declares its outbound dependencies in the same repository as its manifests. A dependency that is not declared does not get an allow rule, which forces the conversation early. Third, external destinations use the weakest tool that expresses them honestly: labels inside the cluster, CIDR ranges for stable provider addresses, FQDN policy for named APIs, and an egress gateway when the organisation needs one monitored exit.

Fourth, verification is part of the change, not a follow-up task. The labelled test Pod checks run in the pipeline or the change review, and the expected blocked result is recorded alongside the expected allowed result. Fifth, policy gets reviewed when dependencies change. An allow rule for a retired integration is standing permission with no owner, and stale rules accumulate quietly because nothing breaks when they linger.

Keep the honest limits in the design document. Egress policy shrinks blast radius and blocks casual exfiltration paths. It does not patch applications, inspect encrypted payloads or stop abuse of an allowed destination. Pair it with image scanning, runtime detection and least privilege service accounts, and the two doors of the cluster finally get the same level of care.

Frequently Asked Questions

Direct answers to common technical, architectural, and production troubleshooting questions.

What is the difference between ingress and egress in kubernetes ingress vs egress terms?

Ingress is traffic arriving at a Pod and egress is traffic a Pod initiates. The same connection counts as egress for the sending Pod and ingress for the receiving Pod. Inbound exposure needs a Service, Ingress or Gateway API route, while outbound traffic stays open until a NetworkPolicy isolates the Pod for egress.

Is egress open by default in kubernetes ingress vs egress behaviour?

Egress is open by default for any Pod that no NetworkPolicy selects, so it can open connections to other Pods and to external addresses. Egress becomes restricted only when a policy selects the Pod and lists Egress in policyTypes, after which only explicitly allowed destinations are reachable.

Why does default deny egress break DNS in kubernetes ingress vs egress rollouts?

CoreDNS runs in kube-system, and a default deny egress policy blocks the path to it. Name lookups then fail after timeouts while Pods still show as Running. The fix is an explicit egress allowance to the kube-dns Pods on UDP and TCP port 53, applied before or with the default deny policy.

Can kubernetes ingress vs egress policy allow only payments.example.com?

Standard NetworkPolicy cannot, because it matches IP ranges, ports and labels rather than domain names. Cilium toFQDNs rules can allow a named domain when DNS queries pass through the Cilium DNS proxy. Calico offers domain rules through GlobalNetworkPolicy in its enterprise and cloud offerings. An egress gateway is the other option when you need one monitored exit point.

How do I test kubernetes ingress vs egress rules before production?

Run a test Pod with the same labels as the workload, because policy follows labels. Confirm DNS resolution works, confirm an allowed destination connects, and confirm a blocked destination times out. Read the applied policies back with kubectl describe, and repeat the checks after every policy change.

Naveed Ahmed

Naveed Ahmed (Kumbhar)

Senior DevOps & Cloud Engineer with 10+ years specializing in AWS, Kubernetes, Platform Engineering, SRE incident response, and autonomous AI infrastructure agents.

Passionate about cloud architecture & systems engineering? Connect on LinkedIn →