Day- 45: Understanding Ingress in Kubernetes

Hello DevOps Professionals! πŸ‘‹

Aaj hum baat karenge ek important concept ke baare mein jo Kubernetes environments mein traffic management ke liye use hota hai, aur wo hai Ingress. Agar aap Kubernetes cluster mein applications deploy kar rahe hain aur unhe external world se connect karna chahte hain, to Ingress aapka best friend ban sakta hai. Let’s dive into what Ingress is, why we use it, its advantages, and how to implement it with a real-life example. πŸš€

What is Ingress?

What is Kubernetes Ingress, and How it works? – Heffen Vox

Ingress ek Kubernetes object hai jo aapke cluster ke andar run hone wale services ko external world se connect karne ka ek organized tareeka deta hai. Agar simple language mein samjha jaye, to Ingress ek gateway jaisa kaam karta hai jisme aap different routing rules define kar sakte hain, jisse incoming requests automatically sahi service tak pahunch jayein.

Imagine kijiye ki aapke paas ek multi-service application hai jisme alag-alag services hain, jaise frontend, backend, aur APIs. Ingress aapko help karta hai in services ke beech traffic ko route karne mein, bina har ek service ke liye alag Load Balancer ya NodePort create kiye.

Why Use Ingress?

To ab sawal aata hai ki kyon use karein Ingress? πŸ€”

  1. Simplified Traffic Management: Ingress aapko single entry point se multiple services ke liye routing manage karne ki facility deta hai.

  2. Cost-Effective: Multiple Load Balancers create karne ki zaroorat nahi, jo aapka cloud cost bhi kam karega.

  3. Flexible Routing: Aap different rules define kar sakte hain jaise URL-based routing, path-based routing, etc.

  4. TLS/SSL Termination: Ingress TLS certificates handle kar sakta hai, jisse aap apne applications ko secure kar sakte hain.

Advantages of Using Ingress

  • Centralized Access Control: Ingress aapko ek central point deta hai jaha se aap different services ke liye access control kar sakte hain.

  • Scalability: Ingress aapke applications ko easily scale karne ki facility provide karta hai, without changing the configuration for each service.

  • Better Security: Ingress aapko HTTPS/TLS termination ka support deta hai, jo aapke data ko secure karne mein help karta hai.

Real-Life Example

Sochiye, aap ek e-commerce platform manage kar rahe hain jisme alag-alag services hain: frontend, product service, payment service, etc. Har service ke liye alag Load Balancer create karna costly ho sakta hai, aur isiliye aap Ingress use karte hain.

Ingress ke through aap URL paths ko different services par route kar sakte hain:

  • / - Frontend

  • /products - Product Service

  • /payments - Payment Service

Manifest File for Ingress

Ab chaliye ek example manifest file dekhte hain jisme hum Ingress object define karenge.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
  namespace: default
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: frontend-service
            port:
              number: 80
      - path: /products
        pathType: Prefix
        backend:
          service:
            name: product-service
            port:
              number: 80
      - path: /payments
        pathType: Prefix
        backend:
          service:
            name: payment-service
            port:
              number: 80

Is manifest file mein humne define kiya hai ki kaise example.com domain ke under different paths ko alag-alag services par route kiya jaye.

Testing Ingress

Ab aapko check karna hai ki aapka Ingress sahi se kaam kar raha hai ya nahi. Chaliye kuch commands dekhte hain:

  1. Ingress Create Karne Ke Baad Check Karein:
kubectl get ingress -n default
  1. Curl Command se Test Karein:
curl -H "Host: example.com" http://<Ingress-Controller-IP>
curl -H "Host: example.com" http://<Ingress-Controller-IP>/products
curl -H "Host: example.com" http://<Ingress-Controller-IP>/payments

In commands se aap test kar sakte hain ki kya traffic sahi service tak pahunch raha hai.

Conclusion

Ingress Kubernetes mein traffic management ko simplify karne ka ek powerful tool hai. Yeh na sirf aapko cost-efficiency provide karta hai, balki better scalability aur security bhi offer karta hai. Agar aap apne Kubernetes cluster mein ek well-organized aur centralized traffic management solution chahte hain, to Ingress is the way to go.

Connect and Follow Me on Socials

LINKDIN | GITHUB |TWITTER

1
Subscribe to my newsletter

Read articles from priyadarshi ranjan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

priyadarshi ranjan
priyadarshi ranjan

Greetings! πŸ‘‹ I'm Priyadarshi Ranjan, a dedicated DevOps Engineer embarking on an enriching journey. Join me as I delve into the dynamic realms of cloud computing and DevOps through insightful blogs and updates. πŸ› οΈ My focus? Harnessing AWS services, optimizing CI/CD pipelines, and mastering infrastructure as code. Whether you're peers, interns, or curious learners, let's thrive together in the vibrant DevOps ecosystem. 🌐 Connect with me for engaging discussions, shared insights, and mutual growth opportunities. Let's embrace the learning curve and excel in the dynamic realm of AWS and DevOps technology!