diff --git a/charts/metallb/templates/speaker.yaml b/charts/metallb/templates/speaker.yaml index 965118ad75e..90ba6e8884e 100644 --- a/charts/metallb/templates/speaker.yaml +++ b/charts/metallb/templates/speaker.yaml @@ -241,6 +241,9 @@ spec: {{- if .Values.loadBalancerClass }} - --lb-class={{ .Values.loadBalancerClass }} {{- end }} + {{- if .Values.speaker.wanConfig }} + - --ml-wan-config + {{- end }} env: - name: METALLB_NODE_NAME valueFrom: diff --git a/internal/speakerlist/speakerlist.go b/internal/speakerlist/speakerlist.go index 26a74f6c99f..21e03e80225 100644 --- a/internal/speakerlist/speakerlist.go +++ b/internal/speakerlist/speakerlist.go @@ -43,7 +43,7 @@ type SpeakerList struct { } // New creates a new SpeakerList and returns a pointer to it. -func New(logger log.Logger, nodeName, bindAddr, bindPort, secret, namespace, labels string, stopCh chan struct{}) (*SpeakerList, error) { +func New(logger log.Logger, nodeName, bindAddr, bindPort, secret, namespace, labels string, WANNetwork bool, stopCh chan struct{}) (*SpeakerList, error) { sl := SpeakerList{ l: logger, stopCh: stopCh, @@ -57,6 +57,9 @@ func New(logger log.Logger, nodeName, bindAddr, bindPort, secret, namespace, lab } mconfig := memberlist.DefaultLANConfig() + if WANNetwork { + mconfig = memberlist.DefaultWANConfig() + } // mconfig.Name MUST be equal to the spec.nodeName field of the speaker pod as we match it // against the nodeName field of Endpoint objects inside usableNodes(). diff --git a/speaker/main.go b/speaker/main.go index 4130f9476bf..70fec3dba2b 100644 --- a/speaker/main.go +++ b/speaker/main.go @@ -76,6 +76,7 @@ func main() { mlBindPort = flag.String("ml-bindport", os.Getenv("METALLB_ML_BIND_PORT"), "Bind port for MemberList (fast dead node detection)") mlLabels = flag.String("ml-labels", os.Getenv("METALLB_ML_LABELS"), "Labels to match the speakers (for MemberList / fast dead node detection)") mlSecretKeyPath = flag.String("ml-secret-key-path", os.Getenv("METALLB_ML_SECRET_KEY_PATH"), "Path to where the MemberList's secret key is mounted") + mlWANConfig = flag.Bool("ml-wan-config", false, "WAN network type for MemberList default config, bool") myNode = flag.String("node-name", os.Getenv("METALLB_NODE_NAME"), "name of this Kubernetes node (spec.nodeName)") port = flag.Int("port", 7472, "HTTP listening port") logLevel = flag.String("log-level", "info", fmt.Sprintf("log level. must be one of: [%s]", logging.Levels.String())) @@ -136,7 +137,7 @@ func main() { mlSecret = string(mlSecretBytes) } - sList, err := speakerlist.New(logger, *myNode, *mlBindAddr, *mlBindPort, mlSecret, *namespace, *mlLabels, stopCh) + sList, err := speakerlist.New(logger, *myNode, *mlBindAddr, *mlBindPort, mlSecret, *namespace, *mlLabels, *mlWANConfig, stopCh) if err != nil { os.Exit(1) }