Skip to content

Commit

Permalink
feat: when use nodelocaldns do not nat the address
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Nov 21, 2019
1 parent 1d88816 commit 1984cbe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/daemon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Configuration struct {
KubeOvnClient clientset.Interface
NodeName string
ServiceClusterIPRange string
NodeLocalDNSIP string
PprofPort int
}

Expand All @@ -49,6 +50,7 @@ func ParseFlags() (*Configuration, error) {
argOvsSocket = pflag.String("ovs-socket", "", "The socket to local ovs-server")
argKubeConfigFile = pflag.String("kubeconfig", "", "Path to kubeconfig file with authorization and master location information. If not set use the inCluster token.")
argServiceClusterIPRange = pflag.String("service-cluster-ip-range", "10.96.0.0/12", "The kubernetes service cluster ip range, default: 10.96.0.0/12")
argNodeLocalDnsIP = pflag.String("node-local-dns-ip", "", "if use nodelocaldns the local dns server ip should be set here, default empty.")
argPprofPort = pflag.Int("pprof-port", 10665, "The port to get profiling data, default: 10665")
)

Expand Down Expand Up @@ -90,6 +92,7 @@ func ParseFlags() (*Configuration, error) {
PprofPort: *argPprofPort,
NodeName: nodeName,
ServiceClusterIPRange: *argServiceClusterIPRange,
NodeLocalDNSIP: *argNodeLocalDnsIP,
}

if config.Iface == "" {
Expand Down
4 changes: 4 additions & 0 deletions pkg/daemon/gateway.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package daemon

import (
"net"
"os"
"strings"
"time"
Expand Down Expand Up @@ -251,6 +252,9 @@ func (c *Controller) getSubnetsNeedNAT(protocol string) ([]string, error) {

func (c *Controller) getSubnetsCIDR(protocol string) ([]string, error) {
var ret = []string{c.config.ServiceClusterIPRange}
if c.config.NodeLocalDNSIP != "" && net.ParseIP(c.config.NodeLocalDNSIP) != nil {
ret = append(ret, c.config.NodeLocalDNSIP)
}
subnets, err := c.subnetsLister.List(labels.Everything())
if err != nil {
klog.Error("failed to list subnets")
Expand Down

0 comments on commit 1984cbe

Please sign in to comment.