Skip to content

Commit 7181d6f

Browse files
dparalenmurali-reddy
authored andcommitted
Prefer node PodCIDR from an annotation (#720)
Current implementation never considers the "kube-router.io/pod-cidr" annotation when creating an ipset for the node pod network CIDR. The Node.Spec.PodCIDR is always used instead. This patch prefers the annotation PodCIDR over the Node.Spec.PodCIDR
1 parent 54eedcd commit 7181d6f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/controllers/routing/network_routes_controller.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,15 @@ func (nrc *NetworkRoutingController) syncNodeIPSets() error {
549549
currentPodCidrs := make([]string, 0)
550550
currentNodeIPs := make([]string, 0)
551551
for _, node := range nodes.Items {
552-
currentPodCidrs = append(currentPodCidrs, node.Spec.PodCIDR)
552+
podCIDR := node.GetAnnotations()["kube-router.io/pod-cidr"]
553+
if podCIDR == "" {
554+
podCIDR = node.Spec.PodCIDR
555+
}
556+
if podCIDR == "" {
557+
glog.Warningf("Couldn't determine PodCIDR of the %v node", node.Name)
558+
continue
559+
}
560+
currentPodCidrs = append(currentPodCidrs, podCIDR)
553561
nodeIP, err := utils.GetNodeIP(&node)
554562
if err != nil {
555563
return fmt.Errorf("Failed to find a node IP: %s", err)

0 commit comments

Comments
 (0)