Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
operator: Add core logic for IPAM pools
This commit adds the core logic for allocating pod CIDRs from specific pools to nodes. The logic is not yet hooked up with the CiliumNode watcher, that will follow in a subsequent commit. The main idea behind the `PoolAllocator` is that it tracks both the available IP pools, but also which node has allocated which CIDR from which pool. Each pool is implemented as a slice of `CIDRAllocators` (based on the `github.com/cilium/ipam/cidrset` package), which means it manages the free-lists for each pool, but does not keep track of who allocated the CIDR. This is done separately to easily be able to obtain a list of CIDRs allocated to a node, without having to iterate over all pools. As with other IPAM allocators, a main concern is state restoration after the operator has been restarted. The approach we take here is similar to the one used by clusterpool (v1): In an initial phase (indicated by `PoolAllocator.ready=false`), the watcher passes in all known CiliumNodes to `AllocateToNode`. This will cause the `PoolAllocator` to mark any previously (before the operator restart) allocated CIDR as occupied. Once all CiliumNodes have been observed, the flip is switched via `RestoreFinished`, at which point the watcher will have to invoke `AllocateToNode` again for every node, allowing new CIDRs now to be allocated to that node if necessary. This ensures that we make sure we know what CIDRs have been previously allocated before we hand out new CIDRs. Co-authored-by: Tobias Klauser <tobias@cilium.io> Signed-off-by: Tobias Klauser <tobias@cilium.io> Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
- Loading branch information