Part-108: 🚀Kubernetes Ingress – Context Path Based Routing in Google Kubernetes Engine

When running multiple applications in Kubernetes, exposing them through different LoadBalancers becomes costly and hard to manage.
This is where Ingress comes in – it allows path-based routing, so a single LoadBalancer can serve multiple applications.


This content originally appeared on DEV Community and was authored by Latchu@DevOps

When running multiple applications in Kubernetes, exposing them through different LoadBalancers becomes costly and hard to manage.
This is where Ingress comes in – it allows path-based routing, so a single LoadBalancer can serve multiple applications.

In this guide, we’ll deploy 3 Nginx apps in GKE and configure Ingress so that:

  • /app1/* → routes to app1 service
  • /app2/* → routes to app2 service
  • /* → routes to app3 service (default)

i1

🟢 Step-01: Introduction

We will:

  1. Deploy App1, App2, App3 with Nginx containers.
  2. Expose them via NodePort services.
  3. Configure a single Ingress with path-based rules.

🟡 Step-02: Deploy App1, App2 & App3

🔹 app1-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: app1-nginx-deployment
  labels:
    app: app1-nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app1-nginx
  template:
    metadata:
      labels:
        app: app1-nginx
    spec:
      containers:
        - name: app1-nginx
          image: ghcr.io/stacksimplify/kube-nginxapp1:1.0.0
          ports:
            - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: app1-nginx-nodeport-service
spec:
  type: NodePort
  selector:
    app: app1-nginx
  ports:
    - port: 80
      targetPort: 80

🔹 app2-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: app2-nginx-deployment
  labels:
    app: app2-nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app2-nginx
  template:
    metadata:
      labels:
        app: app2-nginx
    spec:
      containers:
        - name: app2-nginx
          image: ghcr.io/stacksimplify/kube-nginxapp2:1.0.0
          ports:
            - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: app2-nginx-nodeport-service
spec:
  type: NodePort
  selector:
    app: app2-nginx
  ports:
    - port: 80
      targetPort: 80

🔹 app3-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: app3-nginx-deployment
  labels:
    app: app3-nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app3-nginx
  template:
    metadata:
      labels:
        app: app3-nginx
    spec:
      containers:
        - name: app3-nginx
          image: ghcr.io/stacksimplify/kubenginx:1.0.0
          ports:
            - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: app3-nginx-nodeport-service
spec:
  type: NodePort
  selector:
    app: app3-nginx
  ports:
    - port: 80
      targetPort: 80

🔹 ingress-cpr.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-cpr
  annotations:
    kubernetes.io/ingress.class: "gce"   # GKE Ingress Controller
spec:
  defaultBackend:
    service:
      name: app3-nginx-nodeport-service
      port:
        number: 80
  rules:
    - http:
        paths:
          - path: /app1
            pathType: Prefix
            backend:
              service:
                name: app1-nginx-nodeport-service
                port:
                  number: 80
          - path: /app2
            pathType: Prefix
            backend:
              service:
                name: app2-nginx-nodeport-service
                port:
                  number: 80

🟣 Step-04: Deploy & Verify

# Apply manifests
kubectl apply -f ingress/

# Check pods
kubectl get pods

# Check services
kubectl get svc

# Check Ingress
kubectl get ingress
kubectl describe ingress ingress-cpr

👉 Wait 3–5 minutes for the LoadBalancer to be created.

i2

🔴 Step-05: Access the Applications

Once the LoadBalancer is ready, check the ADDRESS field in Ingress output.

http://<INGRESS-ADDRESS>/app1/index.html
http://<INGRESS-ADDRESS>/app2/index.html
http://<INGRESS-ADDRESS>/

i3

🟠 Step-06: Verify in Google Cloud Console

Go to:

➡️ Load Balancing → Click on the LoadBalancer → Explore tabs:

  • DETAILS: Frontend, Host/Path rules, Backend services, Health checks
  • MONITORING: Traffic & Latency
  • COMPONENTS: Forwarding rules, Target proxies, Certificates

i4

🟤 Step-07: Clean Up

kubectl delete -f ingress/

i5

✅ Summary

  • We deployed 3 Nginx apps.
  • Exposed them via NodePort Services.
  • Configured Ingress for context path routing.
  • Verified traffic routing through a single GKE LoadBalancer.

This is one of the most common real-world patterns for microservices routing in Kubernetes 🎯.

🌟 Thanks for reading! If this post added value, a like ❤️, follow, or share would encourage me to keep creating more content.

— Latchu | Senior DevOps & Cloud Engineer

☁️ AWS | GCP | ☸️ Kubernetes | 🔐 Security | ⚡ Automation
📌 Sharing hands-on guides, best practices & real-world cloud solutions


This content originally appeared on DEV Community and was authored by Latchu@DevOps


Print Share Comment Cite Upload Translate Updates
APA

Latchu@DevOps | Sciencx (2025-10-03T09:36:19+00:00) Part-108: 🚀Kubernetes Ingress – Context Path Based Routing in Google Kubernetes Engine. Retrieved from https://www.scien.cx/2025/10/03/part-108-%f0%9f%9a%80kubernetes-ingress-context-path-based-routing-in-google-kubernetes-engine/

MLA
" » Part-108: 🚀Kubernetes Ingress – Context Path Based Routing in Google Kubernetes Engine." Latchu@DevOps | Sciencx - Friday October 3, 2025, https://www.scien.cx/2025/10/03/part-108-%f0%9f%9a%80kubernetes-ingress-context-path-based-routing-in-google-kubernetes-engine/
HARVARD
Latchu@DevOps | Sciencx Friday October 3, 2025 » Part-108: 🚀Kubernetes Ingress – Context Path Based Routing in Google Kubernetes Engine., viewed ,<https://www.scien.cx/2025/10/03/part-108-%f0%9f%9a%80kubernetes-ingress-context-path-based-routing-in-google-kubernetes-engine/>
VANCOUVER
Latchu@DevOps | Sciencx - » Part-108: 🚀Kubernetes Ingress – Context Path Based Routing in Google Kubernetes Engine. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/10/03/part-108-%f0%9f%9a%80kubernetes-ingress-context-path-based-routing-in-google-kubernetes-engine/
CHICAGO
" » Part-108: 🚀Kubernetes Ingress – Context Path Based Routing in Google Kubernetes Engine." Latchu@DevOps | Sciencx - Accessed . https://www.scien.cx/2025/10/03/part-108-%f0%9f%9a%80kubernetes-ingress-context-path-based-routing-in-google-kubernetes-engine/
IEEE
" » Part-108: 🚀Kubernetes Ingress – Context Path Based Routing in Google Kubernetes Engine." Latchu@DevOps | Sciencx [Online]. Available: https://www.scien.cx/2025/10/03/part-108-%f0%9f%9a%80kubernetes-ingress-context-path-based-routing-in-google-kubernetes-engine/. [Accessed: ]
rf:citation
» Part-108: 🚀Kubernetes Ingress – Context Path Based Routing in Google Kubernetes Engine | Latchu@DevOps | Sciencx | https://www.scien.cx/2025/10/03/part-108-%f0%9f%9a%80kubernetes-ingress-context-path-based-routing-in-google-kubernetes-engine/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.