0
0
Kubernetesdevops~3 mins

Why Ingress and egress rules in Kubernetes? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if a simple set of rules could stop network chaos and protect your apps effortlessly?

The Scenario

Imagine you run a busy office where everyone needs to enter and leave through the same door without any guidance or rules.

Visitors, employees, and deliveries all crowd the entrance, causing confusion and delays.

The Problem

Without clear rules, people block each other, some enter where they shouldn't, and important deliveries get lost.

Manually telling everyone where to go every time wastes time and causes mistakes.

The Solution

Ingress and egress rules act like smart traffic lights and signs for your network.

They control who can come in (ingress) and who can go out (egress), making sure only the right traffic flows at the right time.

Before vs After
Before
Allow all traffic without restrictions
After
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-specific-ingress
spec:
  podSelector:
    matchLabels:
      role: backend
  ingress:
  - from:
    - ipBlock:
        cidr: 192.168.1.0/24
  egress:
  - to:
    - ipBlock:
        cidr: 10.0.0.0/24
What It Enables

With ingress and egress rules, you can safely control network traffic, protect your apps, and keep your system running smoothly.

Real Life Example

Think of a company that only allows customer support staff to access the database servers, while blocking all other departments from that sensitive area.

Key Takeaways

Manual network control is confusing and error-prone.

Ingress and egress rules automate and secure traffic flow.

This keeps your Kubernetes apps safe and efficient.