DEV Community

IPYE
IPYE

Posted on

Cilium BGP Control Plane: Advertise Pod CIDRs from Your Free /48

Disclosure up front: I run IPYE, a company that leases IP space. Most of this article is practical how-to; IPYE appears where a free /48, LOA, or ROA helps you try the work, with a short call to action at the end.

In a dual-stack or IPv6-only Kubernetes cluster, pods can have globally routable addresses. That removes NAT from the picture, but the network outside the cluster still has to learn where each node's pod range lives. Cilium's BGP Control Plane does this: each node peers with your router and advertises its own pod CIDR. This guide numbers pods from a free IPv6 /48 from IPYE and advertises them to an FRR edge router. The cluster uses AS64520, the edge AS64496, and pods come from 2001:db8:100:4000::/52.

Plan the ranges

  • 2001:db8:100:4000::/52 for pod CIDRs, split by Cilium into one /64 per node
  • 2001:db8:100:40::/64 for the node network itself, with the edge at 2001:db8:100:40::1
  • 2001:db8:100:4f00::/56 reserved for LoadBalancer addresses

Keeping the pod range in its own /52 means the edge can accept exactly that block from the cluster and nothing else.

Install Cilium with BGP enabled

With Helm, the relevant values are:

ipv6:
  enabled: true
ipam:
  mode: cluster-pool
  operator:
    clusterPoolIPv6PodCIDRList:
      - 2001:db8:100:4000::/52
    clusterPoolIPv6MaskSize: 64
bgpControlPlane:
  enabled: true
enableIPv6Masquerade: false
Enter fullscreen mode Exit fullscreen mode

enableIPv6Masquerade: false is important. With masquerading on, pod traffic leaves with the node's address, which hides the pod addresses you are about to make routable. Turn it off so pods use their own addresses end to end.

BGP resources

Cilium's BGP configuration has changed across releases. The resources below follow the v2 model introduced in recent versions; check the documentation for your installed version, since field names and API versions may differ.

apiVersion: cilium.io/v2alpha1
kind: CiliumBGPClusterConfig
metadata:
  name: edge
spec:
  nodeSelector:
    matchLabels:
      bgp: enabled
  bgpInstances:
    - name: cluster
      localASN: 64520
      peers:
        - name: edge1
          peerASN: 64496
          peerAddress: 2001:db8:100:40::1
          peerConfigRef:
            name: edge-peer
---
apiVersion: cilium.io/v2alpha1
kind: CiliumBGPPeerConfig
metadata:
  name: edge-peer
spec:
  families:
    - afi: ipv6
      safi: unicast
      advertisements:
        matchLabels:
          advertise: bgp
---
apiVersion: cilium.io/v2alpha1
kind: CiliumBGPAdvertisement
metadata:
  name: pod-cidrs
  labels:
    advertise: bgp
spec:
  advertisements:
    - advertisementType: PodCIDR
Enter fullscreen mode Exit fullscreen mode

Label the nodes that should peer with kubectl label node <name> bgp=enabled. Each one then opens a session to the edge and advertises its pod /64.

The edge router

The edge accepts the cluster's prefixes, installs them, and keeps them away from the upstream:

ipv6 prefix-list K8S-PODS seq 5 permit 2001:db8:100:4000::/52 ge 64 le 64
!
route-map FROM-K8S permit 10
 match ipv6 address prefix-list K8S-PODS
exit
!
router bgp 64496
 neighbor K8S peer-group
 neighbor K8S remote-as 64520
 bgp listen range 2001:db8:100:40::/64 peer-group K8S
 address-family ipv6 unicast
  neighbor K8S activate
  neighbor K8S route-map FROM-K8S in
 exit-address-family
exit
Enter fullscreen mode Exit fullscreen mode

bgp listen range accepts sessions from any node address on the node network, so new nodes peer automatically. The inbound route map accepts only /64s inside the pod block.

The same edge can accept LoadBalancer addresses from the reserved /56 by adding a second prefix-list entry and a Service advertisement in Cilium. Keep the two ranges separate in the filters, so a mistake in one advertisement cannot inject routes into the other range. Your existing outbound policy toward the upstream, which permits only the /48, keeps the pod routes internal.

Verify

cilium bgp peers
cilium bgp routes advertised ipv6 unicast
Enter fullscreen mode Exit fullscreen mode

On the edge:

show bgp ipv6 unicast summary
show bgp ipv6 unicast 2001:db8:100:4000::/52 longer-prefixes
Enter fullscreen mode Exit fullscreen mode

You should see one /64 per labelled node, each with that node as next hop. A ping from outside the cluster to a pod address should now succeed, subject to network policies. If it fails, check that masquerading is really off by looking at the source address the edge sees in tcpdump.

Security changes when pods are routable

Routable pods are reachable pods. Apply Kubernetes network policies before you advertise the routes, and filter at the edge as well: allow only the ports you intend to publish. Pod addresses change as pods are rescheduled, so publish services through stable addresses, such as LoadBalancer IPs advertised from the reserved /56, rather than through pod addresses.

The aggregate outside

Upstreams see only the /48. The LOA from the IPYE portal covers the announcement, and the ROA IPYE creates validates it, while the per-node /64s stay inside your network.

Next step

Claim a free /48 and give your cluster's pods real addresses, disable IPv6 masquerading, and advertise the pod CIDRs to your edge with BGP. Questions: ipye@turnel.com.

About IPYE

IPYE (https://ipye.com) leases IPv4, IPv6 and ASN space with instant setup. Your first IPv6 /48 is free for the first year, a real allocation you can announce on your own ASN, with a LOA from the portal and the ROA created automatically. ASN and region changes apply automatically. IPv4 /24 to /22 leases include LOA, ROA and per-/24 rDNS; WHOIS is editable on IPv6 /44 and larger. Locations: Los Angeles, New York, Ashburn, Salt Lake City, London, Amsterdam, Frankfurt. Claim your free /48: https://my.ipye.com/products/ipv6-rental. Questions: ipye@turnel.com.

Disclosure: I run IPYE

Top comments (0)