Ingress NGINX (Community)

Introduction

In addition to the Application Gateway Ingress Controller (AGIC) the CMaaS customers can deploy an ingress controller of their choice. When choosing the AGIC the CMaaS team will ensure availability of the Aplication Gateway. When using a different ingress controller (e.g. NGINX or Traefik) the customer is responsible. In all cases the correct configuration and use of the ingress controller is the responsibility of the customer. This article is only an example on how to use the NGINX ingress controller. The customer should correctly configure the ingress controller to meet their needs.

An ingress controller is a piece of software that provides reverse proxy, configurable traffic routing, and TLS termination for Kubernetes services. Kubernetes ingress resources are used to configure the ingress rules and routes for individual Kubernetes services. When you use an ingress controller and ingress rules, a single IP address can be used to route traffic to multiple services in a Kubernetes cluster.

Getting started

Install Helm and check your current kubernetes version to install the NGINX ingress controller on a supported version of Kubernetes. Make sure that you’re using the latest release of Helm and have access to the ingress-nginx Helm repository. The steps outlined in this article may not be compatible with previous versions of the Helm chart, NGINX ingress controller, or Kubernetes.

Connect to your aks cluster and continue to the next step.

Supported Versions table

Check the table on this page to know which version of NGINX is compatible with your kubernetes version.

Install the nginx ingress controller

Add Helm chart

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update

Install Controller

To create a basic NGINX ingress controller without customizing the defaults, use the following example. The command will create the namespace if it not exists.

#!/usr/bin/bash

NAMESPACE=ingress-basic
CONTROLLER_TAG=<controller_version>  # e.g. v1.5.1

helm install ingress-nginx ingress-nginx/ingress-nginx `
  --create-namespace `
  --namespace testns `
  --set controller.service.annotations."service\.beta\.kubernetes\.io/azure-load-balancer-health-probe-request-path"=/healthz `
  --set controller.image.tag=$CONTROLLER_TAG

For more installation options see this page

Check the load balancer service

When the installation is complete, check the load balancer service by using kubectl get services.

kubectl get services --namespace ingress-basic -o wide -w ingress-nginx-controller

When the Kubernetes load balancer service is created for the NGINX ingress controller, an IP address is assigned under EXTERNAL-IP, as shown in the following example output:

NAME                       TYPE           CLUSTER-IP    EXTERNAL-IP     PORT(S)                      AGE   SELECTOR
ingress-nginx-controller   LoadBalancer   10.0.0.115   EXTERNAL-IP     80:30957/TCP,443:32414/TCP   1m   app.kubernetes.io/component=controller,app.kubernetes.io/instance=ingress-nginx,app.kubernetes.io/name=ingress-nginx

No ingress rules have been created yet, so the NGINX ingress controller’s default 404 page is displayed if you browse to the external IP address. Ingress rules are configured in the following steps.

Using the nginx ingress controller

To start using the NGINX ingress controller, create an ingress with the following parameter: ingressClassName: nginx as shown in the example below.

Example Ingress


# Ingress
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
spec:
  ingressClassName: nginx
  rules:
    - host: test.agic.contoso.com
      http:
        paths:
          - path: /
            backend:
              service:
                name: test-service
                port:
                  number: 80
            pathType: Prefix

Test Pod Deployment

To make sure your pod is accessible trough NGINX, run the following command with your load balancer ip address:

# linux
curl -I -H 'test.agic.contoso.com' <publitc-ip-address>

# powershell
Invoke-WebRequest <publitc-ip-address> -Headers @{ host="test.agic.contoso.com" }

Uninstall nginx controller

To uninstall the controller run the following command:

helm uninstall ingress-nginx --namespace ingress-basic