Skip to content

Commit

Permalink
feat: support allocating IP with index from node chunk
Browse files Browse the repository at this point in the history
This feature enables us to allocate the IP that is offset by index from
the start of the range allocated for a particular node using CNI args.
It is useful when a particular workload that runs as DaemonSet wants to
allocate always the same IP, even if it's recreated.

Signed-off-by: Vasilis Remmas <[email protected]>
  • Loading branch information
vasrem committed Oct 10, 2024
1 parent 6649bfc commit 9d75e01
Show file tree
Hide file tree
Showing 8 changed files with 273 additions and 105 deletions.
136 changes: 76 additions & 60 deletions api/grpc/nvidia/ipam/node/v1/node.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/grpc/proto/nvidia/ipam/node/v1/node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ message IPAMMetadata {
message IPAMFeatures {
// optional, request IP of the default gateway from the pool be allocated for container
bool allocate_default_gateway = 1;
// optional, request IP with the given index in the chunk allocated for the particular node to be allocated for the container
optional int32 allocate_ip_with_index = 2;
}

// IsAllocatedRequest contains parameters for IsAllocated rpc call
Expand Down
13 changes: 7 additions & 6 deletions docs/extra-cni-args.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

The NV-IPAM plugin supports the following [args in network config](https://www.cni.dev/docs/conventions/#args-in-network-config):

| Argument | Type | Description |
|------------------------|--------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ips | `[]string` | Request static IPs from the pool |
| poolNames | `[]string,` max len is 2 | Name of the pools to be used for IP allocation. _The field has higher priority than `ipam.poolName` |
| poolType | `string` | Type (`ippool`, `cidrpool`) of the pool which is referred by the `poolNames`. _The field has higher priority than_ `ipam.poolType` |
| allocateDefaultGateway | `bool` | Request to allocate pool's default gateway as interface IP address for the container. Pool must have the gateway when this argument is used. The argument can't be used together with static IP request. |
| Argument | Type | Description |
|------------------------|--------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ips | `[]string` | Request static IPs from the pool |
| poolNames | `[]string,` max len is 2 | Name of the pools to be used for IP allocation. _The field has higher priority than `ipam.poolName` |
| poolType | `string` | Type (`ippool`, `cidrpool`) of the pool which is referred by the `poolNames`. _The field has higher priority than_ `ipam.poolType` |
| allocateDefaultGateway | `bool` | Request to allocate pool's default gateway as interface IP address for the container. Pool must have the gateway when this argument is used. The argument can't be used together with static IP request or with allocating IP of specific index. |
| allocateIPWithIndex | `int` | Request to allocate pool's IP with the given index as interface IP address for the container. The argument can't be used together with static IP request or with allocating the gateway IP. |



Expand Down
1 change: 1 addition & 0 deletions pkg/cni/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ func cniConfToGRPCReq(conf *types.NetConf, args *skel.CmdArgs) *nodev1.IPAMParam
RequestedIps: requestedIPs,
Features: &nodev1.IPAMFeatures{
AllocateDefaultGateway: conf.IPAM.Features.AllocateDefaultGateway,
AllocateIpWithIndex: conf.IPAM.Features.AllocateIPWithIndex,
},
}
if req.Metadata.K8SPodUid == "" {
Expand Down
Loading

0 comments on commit 9d75e01

Please sign in to comment.