Skip to content

Commit b8b2e9b

Browse files
Ravi Sankar Pentadeads2k
Ravi Sankar Penta
authored andcommitted
Allow egress-router to connect to cluster service network for DNS, etc.
openshift/origin#19885 allows egress routers to connect to the node IP but when openshift node is configured to use service network IP as DNS IP then egress router pod will not be able to resolve DNS requests. This change will address this issue.
1 parent e318417 commit b8b2e9b

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

pkg/network/node/cniserver/cniserver.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ const CNIServerRunDir string = "/var/run/openshift-sdn"
5151
const CNIServerSocketName string = "cni-server.sock"
5252
const CNIServerSocketPath string = CNIServerRunDir + "/" + CNIServerSocketName
5353

54-
// Config file containing MTU, and default full path
54+
// Config file contains server to plugin config data
5555
const CNIServerConfigFileName string = "config.json"
5656
const CNIServerConfigFilePath string = CNIServerRunDir + "/" + CNIServerConfigFileName
5757

5858
// Server-to-plugin config data
5959
type Config struct {
60-
MTU uint32 `json:"mtu"`
60+
MTU uint32 `json:"mtu"`
61+
ServiceNetworkCIDR string `json:"serviceNetworkCIDR"`
6162
}
6263

6364
// Explicit type for CNI commands the server handles

pkg/network/node/cniserver/cniserver_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func TestCNIServer(t *testing.T) {
6262
defer os.RemoveAll(tmpDir)
6363
socketPath := filepath.Join(tmpDir, CNIServerSocketName)
6464

65-
s := NewCNIServer(tmpDir, &Config{MTU: 1500})
65+
s := NewCNIServer(tmpDir, &Config{MTU: 1500, ServiceNetworkCIDR: "172.30.0.0/16"})
6666
if err := s.Start(serverHandleCNI); err != nil {
6767
t.Fatalf("error starting CNI server: %v", err)
6868
}

pkg/network/node/node.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,8 @@ func (node *OsdnNode) Start() error {
349349
}
350350

351351
glog.V(2).Infof("Starting openshift-sdn pod manager")
352-
if err := node.podManager.Start(cniserver.CNIServerRunDir, node.localSubnetCIDR, node.networkInfo.ClusterNetworks); err != nil {
352+
if err := node.podManager.Start(cniserver.CNIServerRunDir, node.localSubnetCIDR,
353+
node.networkInfo.ClusterNetworks, node.networkInfo.ServiceNetwork.String()); err != nil {
353354
return err
354355
}
355356

pkg/network/node/pod.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func getIPAMConfig(clusterNetworks []common.ClusterNetwork, localSubnet string)
168168
}
169169

170170
// Start the CNI server and start processing requests from it
171-
func (m *podManager) Start(rundir string, localSubnetCIDR string, clusterNetworks []common.ClusterNetwork) error {
171+
func (m *podManager) Start(rundir string, localSubnetCIDR string, clusterNetworks []common.ClusterNetwork, serviceNetworkCIDR string) error {
172172
if m.enableHostports {
173173
iptInterface := utiliptables.New(utilexec.New(), utildbus.New(), utiliptables.ProtocolIpv4)
174174
m.hostportSyncer = kubehostport.NewHostportSyncer(iptInterface)
@@ -181,7 +181,7 @@ func (m *podManager) Start(rundir string, localSubnetCIDR string, clusterNetwork
181181

182182
go m.processCNIRequests()
183183

184-
m.cniServer = cniserver.NewCNIServer(rundir, &cniserver.Config{MTU: m.mtu})
184+
m.cniServer = cniserver.NewCNIServer(rundir, &cniserver.Config{MTU: m.mtu, ServiceNetworkCIDR: serviceNetworkCIDR})
185185
return m.cniServer.Start(m.handleCNIRequest)
186186
}
187187

pkg/network/node/pod_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ func TestPodManager(t *testing.T) {
318318
podManager := newDefaultPodManager()
319319
podManager.podHandler = podTester
320320
_, cidr, _ := net.ParseCIDR("1.2.0.0/16")
321-
err := podManager.Start(tmpDir, "1.2.3.0/24", []common.ClusterNetwork{{ClusterCIDR: cidr, HostSubnetLength: 8}})
321+
err := podManager.Start(tmpDir, "1.2.3.0/24", []common.ClusterNetwork{{ClusterCIDR: cidr, HostSubnetLength: 8}}, "172.30.0.0/16")
322322
if err != nil {
323323
t.Fatalf("could not start PodManager: %v", err)
324324
}
@@ -417,7 +417,7 @@ func TestDirectPodUpdate(t *testing.T) {
417417
podManager := newDefaultPodManager()
418418
podManager.podHandler = podTester
419419
_, cidr, _ := net.ParseCIDR("1.2.0.0/16")
420-
err = podManager.Start(tmpDir, "1.2.3.0/24", []common.ClusterNetwork{{ClusterCIDR: cidr, HostSubnetLength: 8}})
420+
err = podManager.Start(tmpDir, "1.2.3.0/24", []common.ClusterNetwork{{ClusterCIDR: cidr, HostSubnetLength: 8}}, "172.30.0.0/16")
421421
if err != nil {
422422
t.Fatalf("could not start PodManager: %v", err)
423423
}

0 commit comments

Comments
 (0)