CRD-backed IPAM

This is a quick tutorial walking through how to enable CRD-backed IPAM. The purpose of this tutorial is to show how components are configured and resources interact with each other to enable users to automate or extend on their own.

For more details, see the section CRD-Backed

Enable CRD IPAM mode

  1. Setup Cilium for Kubernetes using any of the available guides.

  2. Run Cilium with the --ipam=crd option or set ipam: crd in the cilium-config ConfigMap.

  3. Restart Cilium. Cilium will automatically register the CRD if not available already

    1. msg="Waiting for initial IP to become available in 'k8s1' custom resource" subsys=ipam
  4. Validate that the CRD has been registered:

    1. $ kubectl get crds
    2. NAME CREATED AT
    3. [...]
    4. ciliumnodes.cilium.io 2019-06-08T12:26:41Z

Create a CiliumNode CR

  1. Import the following custom resource to make IPs available in the Cilium agent.

    1. apiVersion: "cilium.io/v2"
    2. kind: CiliumNode
    3. metadata:
    4. name: "k8s1"
    5. spec:
    6. ipam:
    7. pool:
    8. 192.168.1.1: {}
    9. 192.168.1.2: {}
    10. 192.168.1.3: {}
    11. 192.168.1.4: {}
  2. Validate that Cilium has started up correctly

    1. $ cilium status --all-addresses
    2. KVStore: Ok etcd: 1/1 connected, has-quorum=true: https://192.168.60.11:2379 - 3.3.12 (Leader)
    3. [...]
    4. IPAM: IPv4: 2/4 allocated,
    5. Allocated addresses:
    6. 192.168.1.1 (router)
    7. 192.168.1.3 (health)
  3. Validate the status.IPAM.used section:

    1. $ kubectl get cn k8s1 -o yaml
    2. apiVersion: cilium.io/v2
    3. kind: CiliumNode
    4. metadata:
    5. name: k8s1
    6. [...]
    7. spec:
    8. ipam:
    9. pool:
    10. 192.168.1.1: {}
    11. 192.168.1.2: {}
    12. 192.168.1.3: {}
    13. 192.168.1.4: {}
    14. status:
    15. ipam:
    16. used:
    17. 192.168.1.1:
    18. owner: router
    19. 192.168.1.3:
    20. owner: health

Note

At the moment only single IP addresses are allowed. CIDR’s are not supported.