Skip to content

ipam: Switch ENI IPAM from CRD to multi-pool allocator#45154

Draft
HadrienPatte wants to merge 3 commits intomainfrom
pr/HadrienPatte/eni-multipool
Draft

ipam: Switch ENI IPAM from CRD to multi-pool allocator#45154
HadrienPatte wants to merge 3 commits intomainfrom
pr/HadrienPatte/eni-multipool

Conversation

@HadrienPatte
Copy link
Copy Markdown
Member

@HadrienPatte HadrienPatte commented Apr 3, 2026

Replace the CRD allocator with the multi-pool allocator for ENI IPAM mode on the agent side. Previous PR #45124 ensures the operator already supports this new agent setup.

The new eniMultiPoolAllocator is a light wrapper on the standard multiPoolAllocator that enriches AllocationResult with ENI-specific required metadata via buildENIAllocationResult (see #45089).

Key differences from the standard multi-pool allocator:

The agents now read CIDRs from Status.ENI.ENIs, allocate IPs locally, and write aggregate demand to Spec.IPAM.Pools.Requested. They no longer writes per-IP usage to Status.IPAM.Used, achieving a reduction of kubernetes API pressure.

Relates to cilium/design-cfps#87

ipam: Switch ENI IPAM from CRD to multi-pool allocator

Testing

There's a matrix of scenarios depending on the relative versions of the agents and the operator:

Operator 1.19 Operator 1.20
Agent 1.19 Case A Case C
Agent 1.20 Case B Case D

Case A

This case is both agent and operator on 1.19, we didn't touch anything there, nothing to say.

Case B

This case has agents updated to 1.20 before the operator. This case is not expected to be supported. The operator should be updated to 1.20 before the agents. Updating both together with a single helm upgrade is fine as the new operator deployment should be ready before most 1.20 agents become ready themselves.
In this situation, a 1.20 agent will be able to start with the new ENI multi-pool allocator as all it needs from the operator is Status.ENI.ENIs which the 1.19 operator already maintains. The only issue is that the agents won't be able to request more IPs as the 1.19 operator doesn't know where to look for the new demand signal.

Case C

This case has 1.19 agents with a 1.20 operator, since the operator still maintains and updates spec.ipam.pool (see #45110) which is the only field 1.19 agents read, they continue to work with the CRD allocator without any issue, expressing their demand via status.ipam.used, which the operator still watches (see #45124).

Case D

This is the case where both agents and operator are running with the new 1.20 logic: the operator maintains Status.ENI.ENIs, agents watch that and construct spec.ipam.pools.allocated from it, using the new ENI multipool allocator, they express their needs through spec.ipam.pools.requested and zero out status.ipam.used to clearly indicate to the operator that they're using multipool.

Here's what a ciliumnode looks like in this case:

kubectl get ciliumnode $node -ojson | jq '.spec.ipam'
{
  "min-allocate": 3,
  "pool": {
    "100.120.116.112": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.116.113": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.116.114": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.116.115": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.116.116": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.116.117": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.116.118": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.116.119": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.116.120": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.116.121": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.116.122": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.116.123": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.116.124": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.116.125": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.116.126": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.116.127": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.26.176": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.26.177": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.26.178": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.26.179": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.26.180": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.26.181": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.26.182": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.26.183": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.26.184": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.26.185": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.26.186": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.26.187": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.26.188": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.26.189": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.26.190": {
      "resource": "eni-024ee4a1e521cda8c"
    },
    "100.120.26.191": {
      "resource": "eni-024ee4a1e521cda8c"
    }
  },
  "pools": {
    "allocated": [
      {
        "cidrs": [
          "100.120.116.112/28",
          "100.120.26.176/28"
        ],
        "pool": "default"
      }
    ],
    "requested": [
      {
        "needed": {
          "ipv4-addrs": 20
        },
        "pool": "default"
      }
    ]
  },
  "pre-allocate": 1
}
kubectl get ciliumnode $node -ojson | jq '.status.eni.enis["eni-024ee4a1e521cda8c"]'
{
  "addresses": [
    "100.120.26.176",
    "100.120.26.177",
    "100.120.26.178",
    "100.120.26.179",
    "100.120.26.180",
    "100.120.26.181",
    "100.120.26.182",
    "100.120.26.183",
    "100.120.26.184",
    "100.120.26.185",
    "100.120.26.186",
    "100.120.26.187",
    "100.120.26.188",
    "100.120.26.189",
    "100.120.26.190",
    "100.120.26.191",
    "100.120.116.112",
    "100.120.116.113",
    "100.120.116.114",
    "100.120.116.115",
    "100.120.116.116",
    "100.120.116.117",
    "100.120.116.118",
    "100.120.116.119",
    "100.120.116.120",
    "100.120.116.121",
    "100.120.116.122",
    "100.120.116.123",
    "100.120.116.124",
    "100.120.116.125",
    "100.120.116.126",
    "100.120.116.127"
  ],
  "description": "Cilium-CNI (i-XXXX)",
  "id": "eni-024ee4a1e521cda8c",
  "ip": "100.120.117.66",
  "mac": "0e:d5:7d:00:64:d5",
  "number": 1,
  "prefixes": [
    "100.120.26.176/28",
    "100.120.116.112/28"
  ],
  "security-groups": [
    "sg-XXXX",
    "sg-YYYY"
  ],
  "subnet": {
    "cidr": "100.120.0.0/17",
    "id": "subnet-XXXX"
  },
  "tags": {
    "io.cilium/cilium-managed": "true",
    "io.cilium/cluster-name": "redacted"
  },
  "vpc": {
    "cidrs": [
      "100.120.0.0/16"
    ],
    "id": "vpc-XXXX",
    "primary-cidr": "10.0.0.0/19"
  }
}
kubectl get ciliumnode $node -ojson | jq '.status.ipam'
{
  "operator-status": {}
}

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Apr 3, 2026
@HadrienPatte HadrienPatte added release-note/minor This PR changes functionality that users may find relevant to operating Cilium. area/eni Impacts ENI based IPAM. area/ipam IP address management, including cloud IPAM labels Apr 3, 2026
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Apr 3, 2026
@HadrienPatte HadrienPatte force-pushed the pr/HadrienPatte/eni-multipool branch from e392e3d to d0fe107 Compare April 3, 2026 20:40
@HadrienPatte
Copy link
Copy Markdown
Member Author

/test

@HadrienPatte HadrienPatte force-pushed the pr/HadrienPatte/eni-multipool branch from d0fe107 to f10aaae Compare April 4, 2026 00:19
@cilium-ariane
Copy link
Copy Markdown

cilium-ariane bot commented Apr 4, 2026

/test

1 similar comment
@HadrienPatte
Copy link
Copy Markdown
Member Author

/test

@HadrienPatte HadrienPatte force-pushed the pr/HadrienPatte/eni-multipool branch from f10aaae to 9464536 Compare April 4, 2026 20:05
@HadrienPatte
Copy link
Copy Markdown
Member Author

/test

@HadrienPatte HadrienPatte force-pushed the pr/HadrienPatte/eni-multipool branch from 9464536 to 76ae495 Compare April 4, 2026 21:36
@cilium-ariane
Copy link
Copy Markdown

cilium-ariane bot commented Apr 4, 2026

/test

1 similar comment
@HadrienPatte
Copy link
Copy Markdown
Member Author

/test

In #45110 I added logic to have the operator write
`Spec.IPAM.Pools.Allocated` alongside `Spec.IPAM.Pool`, but this is
actually not correct as this `Allocated` field is supposed to be written
to by the agent.

This commit removes the logic writing `Allocated` from the operator and
moves and adapt the supporting functions so they can be used by the agent
in a following commit.

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
Replace the CRD allocator with the multi-pool allocator for ENI IPAM mode
on the agent side. Previous PR #45124 ensures the operator already
supports this new agent setup.

The new `eniMultiPoolAllocator` is a light wrapper on the standard
`multiPoolAllocator` that enriches `AllocationResult` with ENI-specific
required metadata via `buildENIAllocationResult` (see #45089).

Key differences from the standard multi-pool allocator:
* `AllowFirstLastIPs` is enabled so /28 prefix delegation ranges are
  fully allocatable (see #45025 and #45082).
* `LinearPreAlloc` uses a simple `inUse + preAlloc` formula for demand
  computation instead of `neededIPCeil` rounding. This matches the CRD
  allocator's `calculateNeededIPs` semantics and is necessary to ensure
  the operator can recover the exact IP usage from the demand signal
  (requested - preAllocate) (see #45124).
* No dependency on `CiliumPodIPPool` CRDs, pools are instead populated
  by the agent from `Status.ENI.ENIs` which is maintained by the
  operator.

The agents now read CIDRs from `Status.ENI.ENIs`, allocate IPs locally,
and write aggregate demand to `Spec.IPAM.Pools.Requested`. They
no longer writes per-IP usage to `Status.IPAM.Used`, achieving a
reduction of kubernetes API pressure.

Relates to cilium/design-cfps#87

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
Now that ENI IPAM is using the multi-pool allocator, this is deadcode.

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
@HadrienPatte HadrienPatte force-pushed the pr/HadrienPatte/eni-multipool branch from 76ae495 to 78edb9f Compare April 5, 2026 12:18
@HadrienPatte
Copy link
Copy Markdown
Member Author

/test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/eni Impacts ENI based IPAM. area/ipam IP address management, including cloud IPAM release-note/minor This PR changes functionality that users may find relevant to operating Cilium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant