Expose an Application with Ingress¶
Goal¶
In this tutorial you will expose an application to external users using Kubernetes Ingress.
By the end you will understand how traffic flows through the cluster and how Ingress routes requests to services.
Problem¶
Applications running inside Kubernetes are not accessible from outside the cluster by default.
Pods run on an internal network, so external users cannot reach them directly.
Ingress solves this problem by providing HTTP and HTTPS routing into the cluster.
Architecture¶
Traffic flow in this tutorial:
Each component plays a specific role:
| Component | Role |
|---|---|
| Ingress | entry point for external traffic |
| Service | stable internal endpoint |
| Pod | runs the application container |
Prerequisites¶
Before starting ensure:
- a Kubernetes cluster is running
- kubectl is configured
- an Ingress controller is installed
Check cluster access:
Expected output:
Step 1 : Deploy the Application¶
Create a deployment file deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-app
spec:
replicas: 2
selector:
matchLabels:
app: web-app
template:
metadata:
labels:
app: web-app
spec:
containers:
- name: web
image: nginx
ports:
- containerPort: 80
Apply the deployment.
Verify the pods are running.
Expected output:
Step 2 : Create a Service¶
Pods are ephemeral and their IP addresses change.
A Service provides a stable internal endpoint for the application.
Create service.yaml.
apiVersion: v1
kind: Service
metadata:
name: web-service
spec:
selector:
app: web-app
ports:
- port: 80
targetPort: 80
type: ClusterIP
Apply the service.
Verify it exists.
Expected output:
Step 3 : Create the Ingress Resource¶
The Ingress resource defines how external traffic reaches the service.
Create ingress.yaml.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: web-ingress
spec:
rules:
- host: myapp.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web-service
port:
number: 80
Apply the Ingress configuration.
Verify the Ingress resource.
Expected output:
Step 4 : Test the Application¶
Find the address of the Ingress controller.
Example output:
Add an entry to your hosts file if necessary:
Then open the application in a browser:
You should see the default Nginx welcome page.Step 5 : Verify Traffic Flow¶
You can verify the components involved.
Check the Ingress:
Check the service:
Check the pods:
This confirms the full routing path.
What Just Happened¶
You created a complete request path:
| Layer | Resource |
|---|---|
| External entry point | Ingress |
| Internal routing | Service |
| Application | Pods |
Traffic now flows through the cluster like this:
This is the standard pattern for exposing HTTP applications in Kubernetes.Troubleshooting¶
Ingress Not Accessible
Verify the Ingress controller is installed.
Look for something like:
Service Not Routing Traffic
Check service endpoints.
Expected output:
Pods Not Running
Check deployment status.
Inspect pod logs if needed.
Clean Up¶
Delete the resources when finished.
Key Takeaways¶
In this tutorial you learned how to:
- deploy an application
- create a Kubernetes Service
- expose the service using Ingress
- route external HTTP traffic to pods Ingress is the standard method for exposing web applications in Kubernetes.
➡ Continue to the Advanced Kubernetes Guides