我创建了无头服务和一组statefulset容器。使用NodeJS,我可以查找这些pod的所有IP。但是我不知道如何使用GoLang做到这一点。
dns.resolveSrv(serviceName, function (err, addresses) {
// The app performs a DNS lookup to obtain SRV records.
if (err) {
response.end("Could not look up DNS SRV records: " + err);
return;
}...
我做到了:
_, addrs, err := net.LookupSRV("dns-tcp", "tcp", "demoapp.default.svc.cluster.local")
if err != nil {
log.Println(err.Error())
return "dns wrong"
给我错误
lookup _dns-tcp._tcp.demoapp.default.svc.cluster.local on 10.96.0.10:53: no such host