Skip to content

Commit

Permalink
Merge pull request #6 from hanweisen/main
Browse files Browse the repository at this point in the history
create ippool use GlobalCIDRsMap
  • Loading branch information
kosmos-robot authored Aug 31, 2023
2 parents 93e9fe8 + b6a5c93 commit d5548df
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/controllers/calicoippool/calicoippool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,22 +341,29 @@ func (c *Controller) Reconcile(key utils.QueueKey) error {
delete(c.globalExtIPPoolSet, ipPool)
}
}

getCIDR := func(cidr string, cidrMap map[string]string) string {
if c, exist := cidrMap[cidr]; exist {
return c
} else {
return cidr
}
}
cidrMap := cluster.Spec.GlobalCIDRsMap
podCIDRS := cluster.Status.PodCIDRs
serviceCIDR := cluster.Status.ServiceCIDRs
for _, cidr := range podCIDRS {
extIPPool := ExternalClusterIPPool{
cluster: cluster.Name,
ipType: PODIPType,
ipPool: cidr,
ipPool: getCIDR(cidr, cidrMap),
}
c.globalExtIPPoolSet[extIPPool] = struct{}{}
}
for _, cidr := range serviceCIDR {
extIPPool := ExternalClusterIPPool{
cluster: cluster.Name,
ipType: SERVICEIPType,
ipPool: cidr,
ipPool: getCIDR(cidr, cidrMap),
}
c.globalExtIPPoolSet[extIPPool] = struct{}{}
}
Expand Down

0 comments on commit d5548df

Please sign in to comment.