I have an AKS kubernetes cluster inside a virtual network on azure with mainly linux pods.
In the same virtual network there is a windows server hosting a DNS server and domain controller for the domain mydomain.local, also other windows VMs that pods in AKS need access to.
We have set the domain controller ip address in the virtual network settings so that AKS actually works using it to resolve names. Name resolution is ok as long as the FQDN of the destination VM is used, like "sql-server.mydomain.local".
I would like to be able in a pod to reference the VM by simple name (i.e.: "sql-server") without specifying the full domain name. Normally on premises I would simply edit the /etc/resolv.conf of the kubernetes nodes, adding the search domain there.
I know how to edit the CoreDNS settings via coredns-custom ConfigMap, but I cannot find any setting about adding a search domain for the pods.
Is there any way to do this actually?
Thank you
1 Answer 1
I suggest you read first about DNS in kubernetes https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy Especially about Pod’s DNS Policy.
In my case I was able to add search domain for each deployment. Setting is dnsConfig. It does append search domain to the resolv.conf See example below
spec:
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
containers:
- name: ubuntu
image: ubuntu
args:
- sleep
- "10000"
nodeSelector:
beta.kubernetes.io/os: linux
dnsConfig:
searches:
- example.local
Resolv.conf then has "example.local" domain in it.
cat /etc/resolv.conf
nameserver 10.96.0.10
search default.svc.cluster.local svc.cluster.local cluster.local example.local
options ndots:1
Hope this will help in your case too.
-
hi and thank you for your answer. adding the dns to the pod/deployment yaml works correctly but duplicating the search domain into each deployment/stateful-set is really bad, there should be something cluster-wide (or docker-wide?) to do the same thing on default for every podfrancesco paolo schiavone– francesco paolo schiavone2019年11月18日 15:10:17 +00:00Commented Nov 18, 2019 at 15:10