Skip to content

Feat: add Cilium LB IP Pool configuration to support ranges #12140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/CNI/cilium.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ cilium_loadbalancer_ip_pools:
- name: "blue-pool"
cidrs:
- "10.0.10.0/24"
ranges:
- start: "20.0.20.100"
stop: "20.0.20.200"
- start: "1.2.3.4"
```

For further information, check [LB IPAM documentation](https://docs.cilium.io/en/stable/network/lb-ipam/)
Expand Down
4 changes: 4 additions & 0 deletions inventory/sample/group_vars/k8s_cluster/k8s-net-cilium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ cilium_l2announcements: false
# - name: "blue-pool"
# cidrs:
# - "10.0.10.0/24"
# ranges:
# - start: "20.0.20.100"
# stop: "20.0.20.200"
# - start: "1.2.3.4"

# -- Configure BGP Instances (New bgpv2 API v1.16+)
# cilium_bgp_cluster_configs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ metadata:
name: "{{ cilium_loadbalancer_ip_pool.name }}"
spec:
blocks:
{% for cblock in cilium_loadbalancer_ip_pool.cidrs %}
{% for cblock in cilium_loadbalancer_ip_pool.cidrs | default([]) %}
- cidr: "{{ cblock }}"
{% endfor %}
{% for rblock in cilium_loadbalancer_ip_pool.ranges | default([]) %}
- start: "{{ rblock.start }}"
stop: "{{ rblock.stop | default(rblock.start) }}"
{% endfor %}
{% endfor %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be simplified to a | to_yaml filter ? Or is there something I'm missing ?

Copy link
Contributor Author

@Kimcheolhui Kimcheolhui Apr 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! @VannTen

Using | to_yaml is possible, but then k8s-net-cilium.yml must be slightly modified.

The current k8s-net-cilium.yml looks like this:

# k8s-net-cilium.yml
...
cilium_loadbalancer_ip_pools:
  - name: "blue-pool"
    cidrs:              
      - "10.0.10.0/24"
    ranges:             
      - start: "20.0.20.100"
        stop:  "20.0.20.200"
      - start: "1.2.3.4"
...

If we choose to use | to_yaml, it's need to be modified like this:

# k8s-net-cilium.yml
...
cilium_loadbalancer_ip_pools:
  - name: "blue-pool"
    cidrs:              
      - cidr: "10.0.10.0/24" # changed
    ranges:             
      - start: "20.0.20.100"
        stop:  "20.0.20.200"
      - start: "1.2.3.4"
...

Then the Jinja template(cilium-loadbalancer-ip-pool.yml.j2) can be simplified to:

# cilium-loadbalancer-ip-pool.yml.j2
...
blocks:
{{ cilium_loadbalancer_ip_pool.cidrs  | to_yaml | indent(2) }}
{{ cilium_loadbalancer_ip_pool.ranges | to_yaml | indent(2) }}
...

Both the current approach and this alternative work.
Let me know which one you think is better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, let's not break compat. This is fine as is.