mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-10-04 17:46:04 +00:00
The code now calculates and find out the CIDRs for every node in any sync period. I will fix this TODO by maintaining a set for available CIDRs left. Firstly, I will insert 256 CIDRs into the available set. Once someone get one CIDR, remove this CIDR from the available set. If one node get deleted, we will reinsert the CIDR associates with this node back to available CIDR. Once there are nothing left in available CIDR set, generate another 256 CIDRs and insert them into the available set. As a result, we do not need to generate CIDRs in every monitor process and we only need to assign CIDR to node which does not have it. This commit also fix the error that CIDR may overflow when we use the function generateCIDRs. There will be no more ip overflowing, all assigan CIDR will be valid