Skip to content

Commit e81092c

Browse files
committed
test(e2e): add cilium IPAM pool coverage and runbook docs
1 parent 372021f commit e81092c

3 files changed

Lines changed: 143 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ Imp provides first-class integration with **Cilium**. When Cilium is detected:
200200

201201
For non-Cilium CNIs (Flannel/Calico/Weave/etc.), Imp uses a VXLAN fallback for cross-node VM connectivity.
202202

203+
Cilium IPAM runbook: `docs/networking/cilium-ipam.md`
204+
203205
## Metrics & Observability
204206

205207
Imp exposes operator and agent metrics so you can monitor VM lifecycle and platform health:
@@ -237,6 +239,8 @@ sequenceDiagram
237239
`kubectl -n imp-system logs ds/imp-agent`
238240
- Cilium features not active: verify Cilium CRDs exist and cni detection events.
239241
`kubectl get crd | grep cilium`
242+
- Cilium IPAM/pool issues: verify `CiliumPodIPPool` exists and `ImpNetwork.spec.ipam.cilium.poolRef` matches.
243+
`kubectl get ciliumpodippool`
240244
- Webhook admission failures: check cert-manager/webhook pods and certificates.
241245
`kubectl -n imp-system get pods,certificates,issuers`
242246
- Snapshot or migration stalls: inspect related CR conditions.

docs/networking/cilium-ipam.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Cilium IPAM Runbook
2+
3+
This runbook covers Imp networks that delegate IP allocation to Cilium.
4+
5+
## Scope
6+
7+
- Decision: use per-network pools.
8+
- Source of truth: `ImpNetwork.spec.ipam.cilium.poolRef`.
9+
- Allocation flow: agent resolves CIDR from `CiliumPodIPPool`, then allocates VM IPs from that CIDR.
10+
11+
## Prerequisites
12+
13+
- Cilium installed in the cluster.
14+
- `CiliumPodIPPool` CRD present:
15+
- `kubectl get crd ciliumpodippools.cilium.io`
16+
- A pool created for the target network.
17+
18+
## Minimal Example
19+
20+
```yaml
21+
apiVersion: cilium.io/v2alpha1
22+
kind: CiliumPodIPPool
23+
metadata:
24+
name: vm-net-a
25+
spec:
26+
ipv4:
27+
cidrs:
28+
- 10.77.0.0/24
29+
maskSize: 30
30+
---
31+
apiVersion: imp.dev/v1alpha1
32+
kind: ImpNetwork
33+
metadata:
34+
name: vm-net-a
35+
namespace: default
36+
spec:
37+
subnet: 10.44.0.0/24
38+
ipam:
39+
provider: cilium
40+
cilium:
41+
poolRef: vm-net-a
42+
```
43+
44+
Note: `spec.subnet` remains required for API compatibility, but VM allocation CIDR comes from the referenced Cilium pool when `provider=cilium`.
45+
46+
## Verification
47+
48+
1. Confirm pool exists:
49+
- `kubectl get ciliumpodippool vm-net-a -o yaml`
50+
2. Confirm network references pool:
51+
- `kubectl get impnetwork vm-net-a -n default -o jsonpath='{.spec.ipam.cilium.poolRef}'`
52+
3. Confirm agent logs are clean:
53+
- `kubectl -n imp-system logs ds/imp-agent`
54+
55+
## Failure Modes
56+
57+
- `CiliumPodIPPool` missing:
58+
- Symptom: VM start fails; agent logs include pool lookup failure.
59+
- Fix: create pool or correct `poolRef`.
60+
- Pool has no `spec.cidrs`:
61+
- Symptom: allocation subnet resolution error.
62+
- Fix: configure at least one CIDR in the pool spec.
63+
- Cilium CRD not installed:
64+
- Symptom: pool lookup fails with resource mismatch/not found.
65+
- Fix: install Cilium (or switch network IPAM provider to `internal`).
66+
67+
## Rollback
68+
69+
To stop using Cilium pool delegation for a network:
70+
71+
1. Patch network provider:
72+
- `kubectl patch impnetwork vm-net-a -n default --type merge -p '{"spec":{"ipam":{"provider":"internal"}}}'`
73+
2. Keep or remove pool resources based on cluster policy.

test/e2e/e2e_test.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,72 @@ spec:
193193
})
194194
})
195195

196+
Context("Cilium IPAM", func() {
197+
const (
198+
poolName = "e2e-imp-pool"
199+
networkName = "e2e-cilium-ipam-net"
200+
)
201+
202+
AfterEach(func() {
203+
_, _ = utils.Run(exec.Command("kubectl", "delete", "impnetwork", networkName,
204+
"-n", "default", "--ignore-not-found"))
205+
_, _ = utils.Run(exec.Command("kubectl", "delete", "ciliumpodippool", poolName,
206+
"--ignore-not-found"))
207+
})
208+
209+
It("accepts ImpNetwork with ipam.provider=cilium and existing CiliumPodIPPool", func() {
210+
By("ensuring CiliumPodIPPool CRD exists")
211+
if _, err := utils.Run(exec.Command("kubectl", "get", "crd", "ciliumpodippools.cilium.io")); err != nil {
212+
Skip("CiliumPodIPPool CRD not installed in this cluster")
213+
}
214+
215+
By("creating CiliumPodIPPool")
216+
poolManifest := fmt.Sprintf(`
217+
apiVersion: cilium.io/v2alpha1
218+
kind: CiliumPodIPPool
219+
metadata:
220+
name: %s
221+
spec:
222+
ipv4:
223+
cidrs:
224+
- 10.123.0.0/24
225+
maskSize: 30
226+
`, poolName)
227+
applyPool := exec.Command("kubectl", "apply", "-f", "-")
228+
applyPool.Stdin = strings.NewReader(poolManifest)
229+
_, err := utils.Run(applyPool)
230+
Expect(err).NotTo(HaveOccurred())
231+
232+
By("creating ImpNetwork that delegates IPAM to Cilium pool")
233+
netManifest := fmt.Sprintf(`
234+
apiVersion: imp.dev/v1alpha1
235+
kind: ImpNetwork
236+
metadata:
237+
name: %s
238+
namespace: default
239+
spec:
240+
subnet: 10.44.0.0/24
241+
ipam:
242+
provider: cilium
243+
cilium:
244+
poolRef: %s
245+
`, networkName, poolName)
246+
applyNet := exec.Command("kubectl", "apply", "-f", "-")
247+
applyNet.Stdin = strings.NewReader(netManifest)
248+
_, err = utils.Run(applyNet)
249+
Expect(err).NotTo(HaveOccurred())
250+
251+
By("verifying poolRef is persisted")
252+
Eventually(func(g Gomega) {
253+
getCmd := exec.Command("kubectl", "get", "impnetwork", networkName, "-n", "default",
254+
"-o", "jsonpath={.spec.ipam.cilium.poolRef}")
255+
out, getErr := utils.Run(getCmd)
256+
g.Expect(getErr).NotTo(HaveOccurred())
257+
g.Expect(strings.TrimSpace(out)).To(Equal(poolName))
258+
}).Should(Succeed())
259+
})
260+
})
261+
196262
Context("Metrics", func() {
197263
It("operator /metrics endpoint responds 200", func() {
198264
pf := exec.Command("kubectl", "port-forward",

0 commit comments

Comments
 (0)