IPPool is a more granular IPAM management unit than Subnet.
You can subdivide the subnet segment into multiple units through IPPool, and each unit is bound to one or more namespaces.
TOC
Instructions
Create IPPool
Below is an example:
apiVersion: kubeovn.io/v1
kind: IPPool
metadata:
name: pool-1
spec:
subnet: ovn-default
ips:
- "10.16.0.201"
- "10.16.0.210/30"
- "10.16.0.220..10.16.0.230"
namespaces:
- ns-1
- Subnet to which the IP pool belongs.
- IP ranges. Supported formats: <IP>, <CIDR> and <IP1>..<IP2>. Both IPv4 and IPv6 are supported.
- Optional namespaces the IP pool is bound to. Pods in a bound namespace will only get IPs from the bound pool(s), not other ranges in the subnet(s).
Use IPPool
To assign IPs randomly from the IP pool, simply bind the IP pool to the desired namespace(s).
When Pods in the bound namespace are created, their IPs will be allocated from the corresponding IP pool(s).
You can also assign an IP pool to Pods through annotation:
apiVersion: v1
kind: Pod
metadata:
name: pod-1
annotations:
ovn.kubernetes.io/ip_pool: pool-1
spec:
containers:
- name: web
image: nginx:latest
For workloads, use annotation in the Pod template of the Deployment, StatefulSet, etc.:
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-1
spec:
replicas: 1
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
annotations:
ovn.kubernetes.io/ip_pool: pool-1
spec:
containers:
- name: web
image: nginx:latest
Precautions
- To ensure compatibility with function Fixed Addresses, name of the IP pool cannot be an IP address.
- IP addresses out of the subnet range are allowed, while these IPs will not be effective.
- Different IP pools belonging to the same subnet cannot have overlapping IP ranges.
- The
.spec.ips field can be updated whenever necessary. Any changes will take effect immediately.
- An IP pool will inherit the reserved IP of the subnet. When randomly assigning an IP address from an IP pool, the reserved IP within the IP pool range will be skipped.
- When randomly assigning an IP address from a subnet, IP ranges of all IP pools in the subnet will be excluded.
- Multiple IP pools can be bound to the same namespace.