The goal of this step is to install and use nginx ingress to receive and route traffic from a custom domain.
- You have an AKS Cluster deployed
- You have kubectl installed on your machine
- Kubectl has access to AKS cluster
- You have helm installed on AKS cluster
- Azure CLI is installed
- This repository is cloned/forked (or you will type yaml files)
1. Using helm, install nginx ingress
helm install stable/nginx-ingress
$ kubectl get svc -w
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 6d
torrid-gerbil-nginx-ingress-controller LoadBalancer 10.0.135.104 168.63.26.34 80:32101/TCP,443:30399/TCP 3m
torrid-gerbil-nginx-ingress-default-backend ClusterIP 10.0.37.193 <none> 80/TCP 3m
Using the Azure CLI associate the IP with an Azure DNS (i.e. mydomain-io.westeurope.cloudapp.azure.com).
# get the Public IP resource id
az network public-ip list --query "[?ipAddress!=null]|[?contains(ipAddress, '<YOUR-IP-ADDRESS>')].[id]" --output tsv
/subscriptions/00000000-00fc-44a0-b02c-ffffffffffff/resourceGroups/MC_aks-xxxxx/providers/Microsoft.Network/publicIPAddresses/kubernetes-a26a4e576b74411e88fecd2264a455a7
# Copy the Public IP identifier and associate with an Azure DNS (must be unique)
az network public-ip update --ids /subscriptions/00000000-00fc-44a0-b02c-ffffffffffff/resourceGroups/MC_aks-xxxxx/providers/Microsoft.Network/publicIPAddresses/kubernetes-a26a4e576b74411e88fecd2264a455a7 --dns-name mydomain-io
Browsing to the Azure DNS will show the default ingress backend
After a while, browsing to www.your-domain displays the default ingress backend.
5. Add ingress route for www.your-domain
Let's replace the www ingress with a new deployment by installing the AKS Hello World helm chart
helm repo add azure-samples https://azure-samples.github.io/helm-charts/
helm install azure-samples/aks-helloworld
Apply the ingress below, pointing the aks-hello services as the default backend for www.your-domain.
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: www
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- host: www.<your-domain>
http:
paths:
- path: /
backend:
serviceName: aks-helloworld
servicePort: 80