Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove hardcoded cluster domain #159

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cluster/kube/metallb/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

*/

Expand Down
14 changes: 13 additions & 1 deletion cluster/util/service_discovery_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"math/rand"
"net"
"time"
"os"

"github.com/akash-network/node/util/runner"
"github.com/boz/go-lifecycle"
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down