diff --git a/cluster/kube/metallb/client.go b/cluster/kube/metallb/client.go index aec1ca9b..5bae6969 100644 --- a/cluster/kube/metallb/client.go +++ b/cluster/kube/metallb/client.go @@ -131,7 +131,7 @@ func (c *client) setupClient(ctx context.Context) error { can get stuff like this to access metal lb metrics 75 nslookup -type=SRV _monitoring._tcp. - 102 curl -I controller.metallb-system.svc.cluster.local:7472/metrics + 102 curl -I controller.metallb-system.svc:7472/metrics */ diff --git a/cluster/util/service_discovery_agent.go b/cluster/util/service_discovery_agent.go index 12561e5d..bcd2a01c 100644 --- a/cluster/util/service_discovery_agent.go +++ b/cluster/util/service_discovery_agent.go @@ -7,6 +7,7 @@ import ( "math/rand" "net" "time" + "os" "github.com/akash-network/node/util/runner" "github.com/boz/go-lifecycle" @@ -23,6 +24,16 @@ var ( errServiceClient = errors.New("service client failure") ) +// getEnv gets the value of an environment variable, or returns a default +// value if the environment variable is not set. +func getEnv(key string, defaultVal string) string { + val := os.Getenv(key) + if val != "" { + return val + } + return defaultVal +} + func NewServiceDiscoveryAgent(logger log.Logger, kubeConfig *rest.Config, portName, serviceName, namespace string, endpoint *net.SRV) (ServiceDiscoveryAgent, error) { // short circuit if a value is passed in, this is a convenience function for using manually specified values if endpoint != nil { @@ -231,7 +242,8 @@ func (sda *serviceDiscoveryAgent) discoverKube() (clientFactory, error) { func (sda *serviceDiscoveryAgent) discoverDNS() (clientFactory, error) { // FUTURE - try and find a 3rd party API that allows timeouts to be put on this request - _, addrs, err := net.LookupSRV(sda.portName, "TCP", fmt.Sprintf("%s.%s.svc.cluster.local", sda.serviceName, sda.namespace)) + clusterDomain := getEnv("CLUSTER_DOMAIN", "cluster.local") + _, addrs, err := net.LookupSRV(sda.portName, "TCP", fmt.Sprintf("%s.%s.svc.%s", sda.serviceName, sda.namespace, clusterDomain)) if err != nil { sda.log.Error("dns discovery failed", "error", err, "portName", sda.portName, "service-name", sda.serviceName, "namespace", sda.namespace) return nil, err