...
Code Block |
---|
hosts custom.hosts example.com { 1.2.3.4 example.com fallthrough } |
For multiple hosts
Code Block |
---|
hosts custom.hosts example.com test.com {
1.2.3.4 example.com
6.6.6.6 test.com
fallthrough
} |
Start by editing the coredns configmap:
...
Code Block |
---|
apiVersion: v1 data: Corefile: | .:53 { errors health { lameduck 5s } ready kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure fallthrough in-addr.arpa ip6.arpa ttl 30 } prometheus :9153 forward . /etc/resolv.conf { max_concurrent 1000 } cache 30 loop reload loadbalance hosts custom.hosts example.com test.com { 1.2.3.4 example.com 6.6.6.6 test.com fallthrough } } |
Force CoreDNS to reload the ConfigMap by entering:
Code Block | ||||
---|---|---|---|---|
| ||||
kubectl delete pod --namespace kube-system -l k8s-app=kube-dns |
Performing an nslookup from a pod should show the new IP address for example.com
Code Block |
---|
root@ssh-server-5bd5774cf7-fgvt4:/# nslookup example.com
Server: 10.96.0.10
Address: 10.96.0.10#53
Name: example.com
Address: 1.2.3.4 |
References
Reference | URL |
---|---|
** Add a Custom Host to Kubernetes | https://hjrocha.medium.com/add-a-custom-host-to-kubernetes-a06472cedccb |
Coredns Host Plugin | https://coredns.io/plugins/hosts/ |
Customizing DNS Service | https://kubernetes.io/docs/tasks/administer-cluster/dns-custom-nameservers/ |
Debugging DNS Resolution | https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/ |
Custom DNS Entries For Kubernetes | https://coredns.io/2017/05/08/custom-dns-entries-for-kubernetes/ |
...