I have a kubernetes service running on Azure. After the deployment and service are created, the service publishes an External-IP address and I am able to access the service on that IP:Port.
However, I want to access the service through a regular domain name. I know that the kubernetes cluster running on Azure has its own DNS, but how can I figure out what the service DNS name is???
I am running multiple services, and they refer to one another using the <_ServiceName>.<_Namespace>.svc.cluster.local naming convention, but if I attempt to access the Service using <_ServiceName>.<_Namespace>.svc.<_kubernetesDNS>.<_location>.azureapp.com, it doesnt work.
Any help would be greatly appreciated.
In Azure, you can use the "Public IP addresses" resource and associate public Ip that is being used by your service, to a DNS name under the default Azure DNS Namespace : .location.couldapp.azure.com
. eg: demo.k8s.service.centralindia.couldapp.azure.com
Note: The Dns record should be unique.
Else try creating Azure DNS to create your own domain.
Firstly in order to use DNS you should have Service type LoadBalancer. It will create ExternalIp for your service. So if you have and Service which type is LoadBalancer you may take your external IP address of service with below command:
kubectl get services --all-namespaces
Then copy external ip and give below commands via PowerShell
P.S change IP adress with your own external ip address and service name with your own service name
$IP="23.101.60.87"
$DNSNAME="yourservicename-aks"
$PUBLICIPID=az network public-ip list --query "[?ipAddress!=null]|[?contains(ipAddress, '$IP')].[id]" --output tsv
az network public-ip update --ids $PUBLICIPID --dns-name $DNSNAME
So after this commands just give command below via PowerShell again, it will show you your DNS:
az network public-ip list --query "[?ipAddress!=null]|[?contains(ipAddress, '$IP')].[dnsSettings.fqdn]" -o table
Reference: http://alakbarv.azurewebsites.net/2019/01/25/azure-kubernetes-service-aks-get-dns-of-your-service/
Expose the service as 'Load Balancer' type and it will automatically create an Azure Load Balancer, with a Public IP. An Azure Public IP also have a domain name you can use under the azure.com domain.
https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-ip-addresses-overview-arm