Guides
How to Set Up Nginx Ingress on Kubernetes
By Ravindra Bagale, DevOps trainer · LinkedIn · Published: · Last updated:
Install the nginx Ingress controller, apply an Ingress with host and path to your Service, then curl with the right Host header.
Friends, Ingress is the front door: host and path to a Service. Chala mitrano — install the controller before you apply rules.
मित्रांनो, Ingress फ्रंट डोर: host/path ते Service. Chala mitrano — rules आधी controller install.
मित्रों, Ingress सामने का दरवाज़ा: host/path से Service। Chala mitrano — rules से पहले controller install।
Quick answer
Hold this vertical picture:
- Install ingress-nginx once.
- Write Ingress YAML.
- kubectl apply.
- curl with Host header.
- describe if 503.
Language: English · मराठी · हिंदी
Nginx Ingress path
Why Ingress
Hostnames and paths beat raw NodePorts for apps.
Why: Sharing one entry IP for many apps.
What: Ingress object + controller.
How: Rules point at Services.
Example 1: Ingress object sketch
Type this:
mkdir -p /tmp/ing && printf '%s\n' 'apiVersion: networking.k8s.io/v1' 'kind: Ingress' 'metadata:' ' name: web' 'spec:' ' ingressClassName: nginx' ' rules:' ' - host: web.lab.local' ' http:' ' paths:' ' - path: /' ' pathType: Prefix' ' backend:' ' service:' ' name: web' ' port:' ' number: 80' > /tmp/ing/ingress.yaml && head -6 /tmp/ing/ingress.yaml
You will see:
apiVersion: networking.k8s.io/v1
What it means: Ingress maps host/path to a Service.
Example 2: Controller install reminder
Type this:
printf '%s\n' 'Install the ingress-nginx controller once per cluster before Ingress objects work'
You will see:
Install the ingress-nginx controller once per cluster before Ingress objects work
What it means: An Ingress without a controller stays useless.
Example 9: ingressClassName
Type this:
printf '%s\n' 'ingressClassName: nginx'
You will see:
What it means: Selects which controller owns the object when several exist.
Concept 1: Controller first
Nothing listens without it.
Why: Ingress objects alone do nothing.
What: Install ingress-nginx; set ingressClassName.
How: Watch ADDRESS populate.
Example 3: kubectl apply ingress
Type this:
printf '%s\n' 'kubectl apply -f ingress.yaml && kubectl get ingress'
You will see:
kubectl apply -f ingress.yaml && kubectl get ingress
What it means: ADDRESS column fills when the controller assigns an LB/IP.
Example 4: curl with Host header
Type this:
printf '%s\n' 'curl -H "Host: web.lab.local" http://127.0.0.1/'
You will see:
curl -H "Host: web.lab.local" http://127.0.0.1/
What it means: Host header must match the rule when DNS is not ready.
Example 10: Local kind port hint
Type this:
printf '%s\n' 'On kind, map node ports or use a port-forward to the controller Service for lab curls'
You will see:
On kind, map node ports or use a port-forward to the controller Service for lab curls
What it means: Cloud uses a LoadBalancer; labs often port-forward.
Concept 2: Host and path
Match what browsers send.
Why: Wrong Host means default backend.
What: rules.host + paths.
How: curl -H Host for labs.
Example 5: path based routing
Type this:
printf '%s\n' 'path: /api -> service api:80' 'path: / -> service web:80'
You will see:
path: /api -> service api:80
path: / -> service web:80
What it means: Longer prefixes can split apps on one host.
Example 6: describe ingress events
Type this:
printf '%s\n' 'kubectl describe ingress web'
You will see:
kubectl describe ingress web
What it means: Shows backend and controller errors.
Example 7: Service must exist
Type this:
printf '%s\n' 'backend service name web must already exist in the same namespace'
You will see:
backend service name web must already exist in the same namespace
What it means: Wrong Service name = 503 from the controller.
Concept 3: Backends and TLS
Service must exist; TLS later.
Why: 503 usually means bad backend.
What: describe ingress; add tls secret later.
How: Clean up lab rules.
Example 8: TLS note
Type this:
printf '%s\n' 'tls: secretName web-tls # cert-manager can create it later'
You will see:
tls: secretName web-tls # cert-manager can create it later
What it means: HTTPS is the next chapter after HTTP Ingress works.
Example 11: Delete lab ingress
Type this:
printf '%s\n' 'kubectl delete -f ingress.yaml'
You will see:
kubectl delete -f ingress.yaml
What it means: Clean rules when the demo ends.
Example 12: Why not NodePort forever
Type this:
printf '%s\n' 'NodePort exposes high ports; Ingress gives hostnames and paths teams expect'
You will see:
NodePort exposes high ports; Ingress gives hostnames and paths teams expect
What it means: Amazon/Flipkart edge uses host routing.
Ingress card
1 Install ingress-nginx 2 Write Ingress host/path 3 apply 4 curl with Host 5 Fix 503 via Service name
Suppose: ADDRESS empty
Controller not running or waiting for LB.
Suppose: 503
Backend Service missing or wrong port.
Ravindra Bagale's Tip
At Flipkart-style clusters, ingress-nginx plus a clear host rule is the default demo. Reviewers ask what a 503 means.
Flipkart-style clusters मध्ये ingress-nginx + host rule default demo. Reviewers 503 चा अर्थ विचारतात.
Flipkart-style clusters में ingress-nginx + host rule default demo है। Reviewers 503 का अर्थ पूछते हैं।
Check yourself (quiz)
Q1. Ingress without controller?
No traffic handling
Q2. Glue to pods?
Service name + port
Q3. Lab curl trick?
Host header
Q4. 503 meaning?
Bad/missing backend Service
Q5. ingressClassName?
Which controller owns it
Q6. TLS next?
tls secret / cert-manager
Reading tracking
Mark this guide when you finish. Your browser remembers it on this device.
controller → Ingress → curl Host → Service.
Did you understand? Let us try it once more.
Frequently asked questions
Ingress vs Service?
Ingress HTTP routes; Service is the stable VIP to pods.
Why a controller?
It programs the proxy/LB.
Host header?
Matches rules when DNS is missing.
503?
Backend Service missing or wrong.
TLS?
Add tls secretName; cert-manager can issue.
kind lab?
Port-forward or node port to the controller.