Kubernetes Ingress

Nidhi Ashtikar
3 min readMay 1, 2024

--

Simple fanout, Name-based virtual hosting, TLS, Load balancing

Know About Ingress: Kubernetes Ingress and Kubernetes Ingress — Host-Based Ingress and Path-Based Ingress

Simple fanout:

Routes incoming requests to multiple backend services based on defined paths.

Imagine you have an e-commerce platform with separate services for handling product catalog, user authentication, and order processing.

With simple fanout in Kubernetes Ingress, you can configure paths like /catalog, /auth, and /order to route incoming requests to their respective backend services.

For example, a request to example.com/catalog would be directed to the product catalog service, while a request to example.com/auth would go to the authentication service.

Require an Ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: simple-fanout-ingress
spec:
rules:
- http:
paths:
- path: /catalog
pathType: Prefix
backend:
service:
name: catalog-service
port:
number: 80
- path: /auth
pathType: Prefix
backend:
service:
name: auth-service
port:
number: 80
- path: /order
pathType: Prefix
backend:
service:
name: order-service
port:
number: 80

Name-based virtual hosting:

Routes request to different backend services based on the requested hostname.

Suppose your e-commerce platform hosts multiple stores for different brands or sellers, each with its own domain name.

You can use name-based virtual hosting to route requests to the appropriate backend service based on the requested domain.

For instance, requests to brand1store.com would be directed to one backend service handling products for Brand 1, while requests to brand2store.com would be directed to a different backend service for Brand

Require an Ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: name-based-ingress
spec:
rules:
- host: brand1store.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: brand1-service
port:
number: 80
- host: brand2store.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: brand2-service
port:
number: 80

TLS:

Secures communication between clients and backend services using encryption.

To secure communication between clients and the e-commerce platform, you can enable TLS encryption.

This ensures that sensitive information such as user credentials and payment details is protected during transmission over the network.

When a user accesses the platform via https://example.com, TLS encrypts the data exchanged between the client's browser and the backend services, safeguarding it from eavesdropping and tampering.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: tls-ingress
spec:
tls:
- hosts:
- example.com
secretName: tls-secret
rules:
- host: example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: secure-service
port:
number: 443

Load balancing:

Distributes incoming traffic across multiple backend pods to ensure high availability and reliability of applications.

As traffic to the e-commerce platform increases, you can deploy multiple instances (pods) of each backend service to handle the load efficiently.

Kubernetes Ingress, with built-in load balancing capabilities, distributes incoming requests across these backend pods. For example, if the product catalog service has three pods running, the Ingress controller balances the incoming requests evenly among these pods, ensuring optimal resource utilization and responsiveness for users browsing the catalog.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: load-balancing-ingress
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: load-balanced-service
port:
number: 80

If you found this guide helpful then do click on 👏 the button.

Follow for more Learning like this 😊

If there’s a specific topic you’re curious about, feel free to drop a personal note or comment. I’m here to help you explore whatever interests you!

Thanks for spending your valuable time learning to enhance your knowledge!

--

--

Nidhi Ashtikar
Nidhi Ashtikar

Written by Nidhi Ashtikar

Experienced AWS DevOps professional with a passion for writing insightful articles.

No responses yet