Azure Kubernetes Service (AKS) Ingress Controller

An essential component for managing external access to your Kubernetes applications.

This document provides a comprehensive guide to understanding and configuring Ingress controllers within Azure Kubernetes Service (AKS). Ingress controllers are crucial for managing external access to services within your Kubernetes cluster, enabling features like load balancing, SSL termination, and name-based virtual hosting.

What is an Ingress Controller?

In Kubernetes, an Ingress resource is an API object that manages external access to services in a cluster, typically HTTP. Ingress may provide load balancing, SSL termination, and name-based virtual hosting. An Ingress controller is a piece of software that fulfills the Ingress resource configuration. It watches the Kubernetes API for Ingress resources and configures a load balancer (often an Azure Load Balancer or a third-party solution) to route traffic accordingly.

Common Ingress Controllers for AKS

AKS supports several popular Ingress controllers, each with its own strengths and configuration nuances. The most common ones include:

Deploying the NGINX Ingress Controller

One of the most straightforward ways to get started is by deploying the official Kubernetes NGINX Ingress Controller. You can typically deploy it using Helm:


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

# Install the ingress-nginx chart
helm install ingress-nginx ingress-nginx/ingress-nginx \
  --namespace ingress-nginx \
  --create-namespace
                

After installation, an Azure Load Balancer will be provisioned to expose the Ingress controller. You can find its external IP address using:


kubectl get service -n ingress-nginx ingress-nginx-controller
                

Configuring Ingress Resources

Once your Ingress controller is running, you define your routing rules using Ingress resources. Here's an example of an Ingress resource that routes traffic to two different services based on the hostname and path:


apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-app-ingress
  namespace: default
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /  # Example annotation for NGINX
spec:
  ingressClassName: nginx # Ensure this matches your controller's class
  rules:
  - host: myapp.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: frontend-service
            port:
              number: 80
      - path: /api
        pathType: Prefix
        backend:
          service:
            name: backend-api-service
            port:
              number: 8080
  tls:
  - hosts:
    - myapp.example.com
    secretName: myapp-tls-secret # Kubernetes secret containing your TLS certificate
                

Key Components of an Ingress Resource:

Advanced Configurations

Ingress controllers offer a rich set of features for advanced routing and security:

Important: The specific annotations and configurations can vary significantly between different Ingress controller implementations. Always refer to the official documentation for the Ingress controller you are using.

Troubleshooting Common Issues

Next Steps

Explore the specific documentation for your chosen Ingress controller to leverage its full capabilities: