Azure Kubernetes Service (AKS) connect servise to custom domain via ingress

Lets assume we have simple Kubernetes service in Azure, which is sample webpage. It doesnt matter if it is type is NodePort or LoadBalancer or ClusterIp. And we want to connect it to our domain name, for example to

Lets se (p.s if image is small, please zoom website ):

And it is our website:

First you should have Helm (The package manager for Kubernetes) installed.  You may install this on below link proper to your OS, I installed it for Windows.

Install HELM

After that, create file named helm-rbac.yaml as below:

apiVersion: v1
kind: ServiceAccount
 name: tiller
 namespace: kube-system
kind: ClusterRoleBinding
 name: tiller
 kind: ClusterRole
 name: cluster-admin
 - kind: ServiceAccount
 name: tiller
 namespace: kube-system

And give command below for create service account and role binding:

kubectl apply -f helm-rbac.yaml

After Helm successfully installed and service account created you may install ingress with below command:

helm install stable/nginx-ingress --namespace kube-system --set controller.hostNetwork=true,controller.kind=DaemonSet

Then wait 20-30 seconds give command below to see your ingress controller and external IP of ingress. If External IP is in Pending status, just wait few seconds and give below command again to get your IP address of ingress:

kubectl get services --all-namespaces


As you see my  External IP of Ingress controller is This address will be need you later.

So, now you can go to Azure Portal and create a DNS Zone for your domain.

After adding DNS Zone, click to your Zone name on DNS Zones list, and then click Record Set.

If you want to redirect your main domain, example to your service, then keep Name field empty, otherwise write your subdomain name for example, in my own example I redirect it to main domain, so I keep it empty. Alias record set should be selected. On Azure resource section you should select  Public IP address name which assigned to ingress controller, if you dont know its correct name, and you have more publicē ip addresses, you may find it easily. Give command:

kubectl get services --all-namespaces

Copy External IP of ingress controller (we already found it in above)  and then give below command, just change ip address with your ingress ip address:

az network public-ip list --query "[?ipAddress==''].[name]"

It will return your resource name, so you may Select in in azure portal. Then click OK button in Azure portal.

Additionally, you should redirect your domain to the AZURE NS, for example, my domain is in Firstly go to your domain panel, for example it is in In your case it can be different or other.  Change NS to below NS:

get NS of Azure:


And then go to your domain panel (in my case it is update fileds like below:


Then in order to apply ingress rules create file ingress.yaml as below change domain name and service name  to a service which you want to redirect:

apiVersion: extensions/v1beta1
kind: Ingress
 name: hello-world-ingress
 annotations: nginx letsencrypt-staging /
 namespace: default
 - hosts:
 - host:
 - path: /
 serviceName: trainingmanager-service
 servicePort: 80

And give below command to apply this script:

kubectl apply -f ingress.yaml 

So, now check if it works!

P.S If it is first time you redirects your domain to Azure NS it can be take time.

And of course it will open with security warning due to it doesn’t have verified certificate you may install trusted certificated but it is different topic.

Join the Conversation

1 Comment

  1. Hi alakbarv,

    Excellent tutorial.

    It works only when you call the domain without the www for example “”. if I append www before the domain it won’t work for example “”?

Leave a comment

Your email address will not be published.