@@ -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