Hi!
I can't figure out how to access kube-dns from my host. Using minikube I could just route range 10.96.0.0/12 into vboxnet0 and it would "magically" just work. I can now just add the kube-dns cluster IP to my resolv.conf to access the all services inside K8s from my host. Example:
ip route add 10.96.0.0/12 via $(minikube ip) dev vboxnet0
echo "nameserver 10.96.0.10" >> /etc/resolv.conf
dig <service>.default.svc.cluster.local @10.96.0.10
curl http://<service>.default.svc.cluster.local
Can something similar be done with Kind?
what OS are you using?
docker for mac does not have reachable container IP addresses without some fun "hacks"
docker for windows / linux should be possible to do something like this but I haven't tried yet.
@BenTheElder Damn you are fast! I'm using Linux
:sweat_smile:
so the node IP addresses should be reachable from the host and anything accessible on their "host ports" should work, but I'm not sure how exactly you'd wire this up.
I suspect @mauilion or @aojea can probably beat me to that ;-)
ip route add 10.96.0.10 via $(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' kind-control-plane) :)
@BenTheElder @aojea Haha damn you guys are impressively fast, thanks a lot! @aojea works like a charm thanks! Makes development so much easier when you can access the internal K8s hostnames locally
ProTip! If you are using dnsmasq add server=/cluster.local/10.96.0.10 to /etc/dnsmasq.conf
I ended up with this script if some else is interested:
#!/usr/bin/env bash
set -e
default_service_cidr=$(kubectl cluster-info dump | grep -Po 'service-cluster-ip-range=\K(.*\/\d{2})')
kind_node_ip=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' kind-control-plane)
if [ -z "$(ip route show $default_service_cidr)" ]; then
sudo ip route add $default_service_cidr via $kind_node_ip
fi
/close
thanks for the nice script
@aojea: Closing this issue.
In response to this:
/close
thanks for the nice script
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Most helpful comment
ip route add 10.96.0.10 via $(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' kind-control-plane):)