forked from spidernet-io/spiderpool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request spidernet-io#2045 from Icarus9913/fix/wk/allocatio…
…n-doc implement IP allocation process document
- Loading branch information
Showing
1 changed file
with
22 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,38 @@ | ||
# IP Allocation | ||
|
||
When a pod is creating, it will follow steps below to get an IP. | ||
When a pod is creating, it will follow steps below to get IP allocations. | ||
|
||
1. Get all ippool candidates. | ||
1. Get all IPPool candidates. | ||
|
||
For which ippool is used by a pod, the following rules are listed from high to low priority. | ||
For which IPPool is used by a pod, the following rules are listed from **high to low priority** which means the previous rule would **override** the latter rule. | ||
|
||
* SpiderSubnet annotation. "ipam.spidernet.io/subnets" and "ipam.spidernet.io/subnet" will choose to use auto-created ippool if the SpiderSubnet feature is enabled. See [SpiderSubnet](../usage/spider-subnet.md) for detail. | ||
* SpiderSubnet annotation. `ipam.spidernet.io/subnets` and `ipam.spidernet.io/subnet` will choose to use auto-created ippool if the SpiderSubnet feature is enabled. See [SpiderSubnet](../usage/spider-subnet.md) for details. | ||
|
||
* Honor pod annotation. "ipam.spidernet.io/ippool" and "ipam.spidernet.io/ippools" could be used to specify an ippool. See [Pod Annotation](../usage/annotation.md) for detail. | ||
* Honor pod annotation. `ipam.spidernet.io/ippools" and "ipam.spidernet.io/ippool` could be used to specify an ippool. See [Pod Annotation](../concepts/annotation.md) for details. | ||
|
||
* Namespace annotation. "ipam.spidernet.io/defaultv4ippool" and "ipam.spidernet.io/defaultv6ippool" could be used to specify an ippool. See [namespace annotation](../usage/annotation.md) for detail. | ||
* Namespace annotation. `ipam.spidernet.io/defaultv4ippool` and `ipam.spidernet.io/defaultv6ippool` could be used to specify an ippool. See [namespace annotation](../concepts/annotation.md) for details. | ||
|
||
* CNI configuration file. It can be set to "default_ipv4_ippool" and "default_ipv6_ippool" in the CNI configuration file. See [configuration](../usage/config.md) for detail. | ||
* CNI configuration file. It can be set to `default_ipv4_ippool` and `default_ipv6_ippool` in the CNI configuration file. See [configuration](../concepts/config.md) for details. | ||
|
||
* Cluster default subnet.(you can do not specify any annotations and it will try to use cluster default subnet auto-created ippool if the SpiderSubnet feature it enabled) | ||
It can be set to "clusterDefaultIPv4Subnet" and "clusterDefaultIPv6Subnet" in the "spiderpool-conf" ConfigMap. See [configuration](../usage/config.md) for detail. | ||
* Cluster default IPPool. We can set SpiderIPPool CR object with `default` property, in which we'll regard it as a default pool in cluster. See [configuration](../concepts/spiderippool.md) for details. | ||
|
||
* Cluster default ippool. | ||
It can be set to "clusterDefaultIPv4IPPool" and "clusterDefaultIPv6IPPool" in the "spiderpool-conf" ConfigMap. See [configuration](../usage/config.md) for detail. | ||
2. Filter valid IPPool candidates. | ||
|
||
2. Filter valid ippool candidates. | ||
After getting IPv4 and IPv6 IPPool candidates, it looks into each IPPool and figures out whether it meets following rules, and learns which candidate IPPool is available. | ||
|
||
After getting IPv4 and IPv6 ippool candidates, it looks into each ippool and figures out whether it meets following rules, and learns which candidate ippool is available. | ||
* The "disable" field of the IPPool is "false". This property means the IPPool is not available to be used. | ||
* Check current environment with IP version settings. (dual stack, IPv4 only, IPv6 only) | ||
* Filter terminating IPPools. | ||
* Check `IPPool.Spec.NodeName` and `IPPool.Spec.NodeAffinity` properties whether match the scheduled node of the pod or not. If not match, this IPPool would be filtered. (`NodeName` has higher priority than `NodeAffinity`) | ||
* Check `IPPool.Spec.NamespaceName` and `IPPool.Spec.NamespaceAffinity` properties whether match the namespace of the pod or not. If not match, this IPPool would be filtered. (`NamespaceName` has higher priority than `NamespaceAffinity`) | ||
* The "PodAffinity" field of the IPPool must meet the pod | ||
* Check `IPPool.Spec.MultusName` properties whether match the pod current NIC Multus configuration or not. If not match, this IPPool would be filtered. | ||
* The available IP resource of the IPPool is not exhausted | ||
|
||
* The "disable" field of the ippool is "false" | ||
* The "ipversion" field of the ippool must meet the claim | ||
* The "namespaceSelector" field of the ippool must meet the namespace of the pod | ||
* The "podSelector" field of the ippool must meet the pod | ||
* The "nodeSelector" field of the ippool must meet the scheduled node of the pod | ||
* The available IP resource of the ippool is not exhausted | ||
3. Assign IP from valid IPPool candidates. | ||
|
||
3. Assign IP from valid ippool candidates. | ||
When trying to assign IP from the IPPool candidates, it follows rules as below. | ||
|
||
When trying to assign IP from the ippool candidates, it follows rules as below. | ||
* The IP is not reserved by the "exclude_ips" field of the IPPool and all ReservedIP instances | ||
|
||
* The IP is not reserved by the "exclude_ips" field of the ippool and all ReservedIP instances | ||
* When the pod controller is a StatefulSet, the pod will get an IP in sequence | ||
> Notice: If the pod belongs to StatefulSet, it would be assigned IP addresses with the upper rules firstly. And it will try to reuse the last allocated IP addresses once the pod 'restarts'. |