Skip to content

Commit 92cd7d5

Browse files
author
Wei Tie
committed
network policy should use internal address for contiv client
network policy should use internal address instead for interacting with contiv.
1 parent a04b4ae commit 92cd7d5

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

netmaster/daemon/daemon.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ func (d *MasterDaemon) InitServices() {
523523
isLeader := func() bool {
524524
return d.currState == "leader"
525525
}
526-
networkpolicy.InitK8SServiceWatch(d.ListenURL, isLeader)
526+
networkpolicy.InitK8SServiceWatch(d.ControlURL, isLeader)
527527
}
528528
}
529529

netmaster/k8snetwork/networkpolicy.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,11 @@ func (k8sNet *k8sContext) watchK8sEvents(errChan chan error) {
373373
}
374374

375375
// InitK8SServiceWatch monitor k8s services
376-
func InitK8SServiceWatch(listenURL string, isLeader func() bool) error {
376+
func InitK8SServiceWatch(listenAddr string, isLeader func() bool) error {
377377
npLog = log.WithField("k8s", "netpolicy")
378378

379-
listenAddr := strings.Split(listenURL, ":")
380-
if len(listenAddr[0]) <= 0 {
381-
listenAddr[0] = "localhost"
382-
}
383-
contivClient, err := client.NewContivClient("http://" + listenAddr[0] + ":" + listenAddr[1])
379+
npLog.Infof("Create contiv client at http://%s", listenAddr)
380+
contivClient, err := client.NewContivClient("http://" + listenAddr)
384381
if err != nil {
385382
npLog.Errorf("failed to create contivclient %s", err)
386383
return err

0 commit comments

Comments
 (0)