Guide to Azure HTTP Ingress with Examples

Vineet Sharma
4 min readJan 24, 2025

In the world of cloud-native applications, managing inbound traffic is crucial for delivering scalable and reliable services. Azure Kubernetes Service (AKS) provides a robust platform for containerized workloads, and one of its key features is the ability to configure HTTP ingress. HTTP ingress allows you to efficiently route incoming HTTP and HTTPS traffic to the appropriate backend services running in your Kubernetes cluster. This guide explores everything you need to know about HTTP ingress in Azure, from the basics to advanced configurations, with practical examples.

What is HTTP Ingress in Kubernetes?

Ingress in Kubernetes is an API object that manages external access to services within a cluster. While Services in Kubernetes expose pods, Ingress provides a unified entry point for routing HTTP and HTTPS traffic, often with features like:

  • Path-based routing
  • Host-based routing
  • Load balancing
  • SSL termination

In Azure, HTTP ingress typically involves using an Ingress Controller, such as NGINX or Azure Application Gateway Ingress Controller (AGIC).

Why Use HTTP Ingress in Azure?

Azure provides several ways to expose services, including:

  • Load Balancer: Exposes services at the network level.
  • Ingress: Provides an application layer (HTTP/HTTPS) routing mechanism.

Using HTTP ingress in Azure offers:

  1. Centralized Traffic Management: A single entry point for multiple services.
  2. Cost Efficiency: One IP address for multiple applications/domains.
  3. Advanced Routing: Path- and host-based routing capabilities.
  4. SSL/TLS Management: Termination at the ingress layer.
  5. Enhanced Security: Integration with Web Application Firewall (WAF).

Azure Ingress Controller Options

Azure supports several ingress controllers. Below are the most commonly used ones:

1. NGINX Ingress Controller

  • Open-source and widely adopted.
  • Suitable for most Kubernetes environments.
  • Simple and lightweight.

2. Azure Application Gateway Ingress Controller (AGIC)

  • Fully managed service integrated with Azure Application Gateway.
  • Built-in Web Application Firewall (WAF).
  • Deep integration with Azure services.
  • Ideal for enterprise-grade applications.

3. Traefik

  • Lightweight and developer-friendly ingress controller.
  • Comes with a dashboard and advanced features like middleware.

In this guide, we’ll focus on setting up NGINX and Azure Application Gateway ingress controllers with examples.

Setting Up HTTP Ingress in Azure Kubernetes Service (AKS)

Prerequisites

Before setting up ingress, ensure you have the following:

  1. Azure CLI installed (Download Azure CLI).
  2. A running AKS cluster.
  3. kubectl CLI installed.
  4. Basic understanding of Kubernetes objects (e.g., Pods, Services).

Step 1: Deploy a Sample Application

Create a sample application with a simple deployment and service.

Deployment Manifest (deployment.yaml):

apiVersion: apps/v1
kind: Deployment
metadata:
name: demo-app
labels:
app: demo-app
spec:
replicas: 2
selector:
matchLabels:
app: demo-app
template:
metadata:
labels:
app: demo-app
spec:
containers:
- name: demo-app
image: nginx
ports:
- containerPort: 80

Service Manifest (service.yaml):

apiVersion: v1
kind: Service
metadata:
name: demo-app
spec:
selector:
app: demo-app
ports:
- protocol: TCP
port: 80
targetPort: 80
type: ClusterIP

Deploy the application:

kubectl apply -f deployment.yaml
kubectl apply -f service.yaml

Step 2: Install an Ingress Controller

Option A: Install NGINX Ingress Controller

  1. Add the NGINX Helm repository:
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx helm repo update

2. Install the NGINX ingress controller:

helm install nginx-ingress ingress-nginx/ingress-nginx --namespace ingress-basic --create-namespace

3. Verify the installation:

kubectl get pods -n ingress-basic

Option B: Install Azure Application Gateway Ingress Controller (AGIC)

  1. Create an Azure Application Gateway:
az network application-gateway create -n appgw -g <Resource-Group> --sku WAF_v2 --capacity 2 --frontend-port 80

2. Enable AGIC in your AKS cluster:

az aks enable-addons -n <Cluster-Name> -g <Resource-Group> --addons ingress-appgw --appgw-id <AppGW-Resource-ID>

Configuring HTTP Ingress

Example 1: Basic HTTP Routing

Create an ingress resource to expose the demo-app service.

Ingress Manifest (ingress-basic.yaml):

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

Deploy the ingress resource:

kubectl apply -f ingress-basic.yaml

Access the application at http://demo.example.com (after configuring DNS).

Example 2: TLS/SSL Termination

Secure your ingress with TLS.

  1. Create a TLS secret:
kubectl create secret tls demo-tls --key tls.key --cert tls.crt

2. Update the ingress manifest:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: demo-ingress
namespace: default
spec:
tls:
- hosts:
- demo.example.com
secretName: demo-tls
rules:
- host: demo.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: demo-app
port:
number: 80

3. Redeploy the ingress resource:

kubectl apply -f ingress-tls.yaml

Access the application at https://demo.example.com.

Example 3: Path-Based Routing

Route traffic to multiple services based on paths.

Ingress Manifest (ingress-path.yaml):

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: multi-service-ingress
spec:
rules:
- host: example.com
http:
paths:
- path: /app1
pathType: Prefix
backend:
service:
name: app1-service
port:
number: 80
- path: /app2
pathType: Prefix
backend:
service:
name: app2-service
port:
number: 80

Example 4: Host-Based Routing

Direct traffic to different services based on the requested host.

Ingress Manifest (ingress-host.yaml):

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

Deploy the ingress resource:

kubectl apply -f ingress-host.yaml

Update your DNS to resolve app1.example.com and app2.example.com to the ingress controller’s external IP.

Troubleshooting Tips

  1. Check Ingress Logs:
kubectl logs -n ingress-basic <nginx-controller-pod>

2. Verify DNS Configuration: Ensure your domain resolves to the ingress IP.

3. Test with curl:

curl -k -H "Host: demo.example.com" http://<Ingress-IP>

Conclusion

Configuring HTTP ingress in Azure Kubernetes Service (AKS) enables efficient and scalable traffic routing to your applications. By using tools like NGINX or Azure Application Gateway, you can implement advanced traffic management features such as SSL termination, path-based routing, and load balancing. Whether you’re building simple applications or enterprise-grade solutions, HTTP ingress provides a powerful foundation for exposing your Kubernetes workloads.

Experiment with the examples provided, and adapt them to suit your specific requirements. Azure’s extensive integration capabilities make it an ideal platform for running Kubernetes with ingress controllers.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response

Recommended from Medium

Lists

See more recommendations