Skip to content

Commit e5ad17d

Browse files
authored
Merge pull request kubernetes-sigs#100 from njucjc/fix-node-ip-forward
Fix: forward node ip bugfix
2 parents 72193d7 + 7b107d9 commit e5ad17d

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

pkg/k8s/engine_controller.go

+13-7
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,6 @@ func (c *EngineController) getMergedSubnets(nodeInfo []v1alpha1.NodeInfo) []stri
129129
subnets := make([]string, 0)
130130
for _, n := range nodeInfo {
131131
subnets = append(subnets, n.Subnets...)
132-
if c.forwardNodeIP {
133-
nodeSubnet := net.IPNet{
134-
IP: net.ParseIP(n.PrivateIP),
135-
Mask: []byte{0xff, 0xff, 0xff, 0xff},
136-
}
137-
subnets = append(subnets, nodeSubnet.String())
138-
}
139132
}
140133
subnets, _ = cidrman.MergeCIDRs(subnets)
141134
return subnets
@@ -205,7 +198,20 @@ func (c *EngineController) syncNodeInfo(nodes []v1alpha1.NodeInfo) {
205198
}
206199
}
207200

201+
func (c *EngineController) appendNodeIP(gw *v1alpha1.Gateway) {
202+
for i := range gw.Status.Nodes {
203+
nodeSubnet := net.IPNet{
204+
IP: net.ParseIP(gw.Status.Nodes[i].PrivateIP),
205+
Mask: []byte{0xff, 0xff, 0xff, 0xff},
206+
}
207+
gw.Status.Nodes[i].Subnets = append(gw.Status.Nodes[i].Subnets, nodeSubnet.String())
208+
}
209+
}
210+
208211
func (c *EngineController) syncGateway(gw *v1alpha1.Gateway) {
212+
if c.forwardNodeIP {
213+
c.appendNodeIP(gw)
214+
}
209215
aep := gw.Status.ActiveEndpoint
210216
subnets := c.getMergedSubnets(gw.Status.Nodes)
211217
cfg := make(map[string]string)

0 commit comments

Comments
 (0)