我已经使用 docker 驱动程序设置了 minikube,但问题与 virtualbox 驱动程序是一样的。
我在 Fedora 39 上并且我遵循这里的解释: https://minikube.sigs.k8s.io/docs/handbook/addons/ingress-dns/
nslookup hello-jane.test $(minikube ip)
Server: 192.168.49.2
Address: 192.168.49.2#53
Non-authoritative answer:
Name: hello-jane.test
Address: 192.168.49.2
Name: hello-jane.test
Address: 192.168.49.2
这样可行!
也可以从容器内部进行:
root@debian2:/# ping hello-jane.test
PING hello-jane.test (192.168.49.2) 56(84) bytes of data.
64 bytes from 192-168-49-2.kubernetes.default.svc.cluster.local (192.168.49.2): icmp_seq=1 ttl=64 time=0.015 ms
但是从主机,没有指定集群 IP
nslookup hello-jane.test
Server: 127.0.0.53
Address: 127.0.0.53#53
** server can't find hello-jane.test: NXDOMAIN
当然 ping 不通。
我猜是因为systemd-resolve
这可能会干扰……
systemd-resolve --status
Global
Protocols: LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
Link 2 (enp0s31f6)
Current Scopes: none
Protocols: -DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
Link 3 (wlp0s20f3)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
Protocols: +DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 192.168.15.153
DNS Servers: 192.168.15.153
Link 4 (br-236f66aa6691)
Current Scopes: none
Protocols: -DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Link 5 (docker0)
Current Scopes: none
Protocols: -DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
Link 16 (ipsec0)
Current Scopes: LLMNR/IPv4 LLMNR/IPv6
Protocols: -DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
Link 17 (vboxnet0)
Current Scopes: none
Protocols: -DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
Link 18 (br-288fd084c2f1)
Current Scopes: LLMNR/IPv4 LLMNR/IPv6
Protocols: -DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
Link 22 (veth9f99f5c)
Current Scopes: LLMNR/IPv6
Protocols: -DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
它的配置没有改变。但如果我添加 minikube IP/etc/systemd/resolved.conf
作为 DNS,它就可以工作了!但当然其他 DNS 不再解析了。
我应该说一下,我没有做这个Linux OS with resolvconf
部分,因为 Fedora 使用的是 systemd-resolved。这是原因吗?