Update 'k3s: enable DNS resolution from host to k3s services'
parent
13898c894d
commit
b83bb21f03
36
k3s%3A-enable-DNS-resolution-from-host-to-k3s-services.md
Normal file
36
k3s%3A-enable-DNS-resolution-from-host-to-k3s-services.md
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
The following enables DNS resolution from host to k3s services for `default.svc.cluster.local` & `svc.cluster.local` domains:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo mkdir -p /etc/systemd/resolved.conf.d
|
||||||
|
cat <<EOF | sudo tee /etc/systemd/resolved.conf.d/k3s-kube-dns.conf
|
||||||
|
[Resolve]
|
||||||
|
DNS=$(kubectl -n kube-system get ep kube-dns -o jsonpath='{.subsets[0].addresses[0].ip}')
|
||||||
|
FallbackDNS=
|
||||||
|
Domains=default.svc.cluster.local svc.cluster.local
|
||||||
|
DNSSEC=no
|
||||||
|
Cache=no-negative
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sudo systemctl restart systemd-resolved
|
||||||
|
```
|
||||||
|
|
||||||
|
Verification:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ resolvectl
|
||||||
|
|
||||||
|
Global
|
||||||
|
Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
|
||||||
|
resolv.conf mode: stub
|
||||||
|
Current DNS Server: 10.42.0.2
|
||||||
|
DNS Servers: 10.42.0.2
|
||||||
|
DNS Domain: default.svc.cluster.local svc.cluster.local
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
$ host kube-dns.kube-system.svc.cluster.local
|
||||||
|
kube-dns.kube-system.svc.cluster.local has address 10.43.0.10
|
||||||
|
|
||||||
|
$ nc -vz kube-dns.kube-system.svc.cluster.local 53
|
||||||
|
Connection to kube-dns.kube-system.svc.cluster.local (10.43.0.10) 53 port [tcp/domain] succeeded!
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user