Skip to content

Commit 86a5f1c

Browse files
committed
BGP cilium post
1 parent 0b5def7 commit 86a5f1c

File tree

5 files changed

+160
-1
lines changed

5 files changed

+160
-1
lines changed

assets/icons/brand-linkedin.svg

Lines changed: 7 additions & 0 deletions
Loading

config/_default/menu.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ url = "https://twitter.com/rajsinghtech"
2222

2323
[social.params]
2424
icon = "brand-twitter"
25+
26+
[[social]]
27+
identifier = "linkedin"
28+
name = "linkedin"
29+
url = "https://www.linkedin.com/in/rajsingh360/"
30+
31+
[social.params]
32+
icon = "brand-linkedin"

config/_default/params.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ enabled = true
7676

7777
## Comments
7878
[comments]
79-
enabled = true
79+
enabled = false
8080
provider = "disqus"
8181

8282
[comments.disqusjs]

content/post/unifi-cilium/index.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
---
2+
title: Advertise Routes from Kubernetes Running Cilium to a Unifi Router over BGP
3+
description:
4+
slug: cilium-unifi
5+
date: 2024-11-19 00:00:00+0000
6+
image: unifi-cilium.png
7+
categories:
8+
- Kubernetes
9+
tags:
10+
- cilium
11+
- unifi
12+
- bgp
13+
- frr
14+
weight: 1
15+
---
16+
17+
In this post, I will walk you through the process of advertising routes from a Kubernetes cluster running Cilium to a Unifi router using BGP. This setup allows for dynamic routing between your Kubernetes cluster and your Unifi network, ensuring seamless connectivity and efficient routing. Blending Layer 3/4 Loadbalancing Protocols with Kubernetes.
18+
19+
## Prerequisites
20+
Before we begin, ensure you have the following:
21+
- A Kubernetes cluster with Cilium installed. see
22+
- A Unifi router.
23+
- FRR installed on your Unifi router.
24+
25+
## Configuration Files
26+
### Cilium BGP Configuration
27+
First, we need to configure Cilium to advertise routes using BGP. In this case we have defined The unifi routers as a BGP peer at `10.0.0.1` using an ASN of `64513`. We have also configure Cilium to advertise all Pod, Service, and Loadbalancer IP's. Create a file named bgp.yaml with the following customer resource definitions:
28+
``` yaml
29+
---
30+
apiVersion: cilium.io/v2alpha1
31+
kind: CiliumBGPClusterConfig
32+
metadata:
33+
name: unifi
34+
spec:
35+
nodeSelector:
36+
matchLabels:
37+
kubernetes.io/os: linux
38+
bgpInstances:
39+
- name: "unifi"
40+
localASN: 64512
41+
peers:
42+
- name: "udm-1"
43+
peerASN: 64513
44+
peerAddress: 10.0.0.1
45+
peerConfigRef:
46+
name: "cilium-peer"
47+
---
48+
apiVersion: cilium.io/v2alpha1
49+
kind: CiliumBGPPeerConfig
50+
metadata:
51+
name: cilium-peer
52+
spec:
53+
timers:
54+
holdTimeSeconds: 9
55+
keepAliveTimeSeconds: 3
56+
ebgpMultihop: 4
57+
gracefulRestart:
58+
enabled: true
59+
restartTimeSeconds: 15
60+
families:
61+
- afi: ipv4
62+
safi: unicast
63+
advertisements:
64+
matchLabels:
65+
advertise: "bgp"
66+
---
67+
apiVersion: cilium.io/v2alpha1
68+
kind: CiliumBGPAdvertisement
69+
metadata:
70+
name: bgp-advertisements
71+
labels:
72+
advertise: bgp
73+
spec:
74+
advertisements:
75+
- advertisementType: "Service"
76+
service:
77+
addresses:
78+
- ClusterIP
79+
- ExternalIP
80+
- LoadBalancerIP
81+
selector:
82+
matchExpressions:
83+
- {key: somekey, operator: NotIn, values: ['never-used-value']}
84+
- advertisementType: "PodCIDR"
85+
selector:
86+
matchExpressions:
87+
- {key: somekey, operator: NotIn, values: ['never-used-value']}
88+
```
89+
90+
### FRR Configuration
91+
Next, configure FRR on your Unifi router to establish a BGP session with Cilium. Notice the IP's in the Peer-Group they should match the nodes IP's you want to advertise from at the ASN of `64512`. Create a file named `frr.conf` with the following content:
92+
``` bash
93+
! -*- bgp -*-
94+
!
95+
hostname $UDMP_HOSTNAME
96+
password zebra
97+
frr defaults traditional
98+
log file stdout
99+
!
100+
router bgp 64513
101+
bgp ebgp-requires-policy
102+
bgp router-id 10.0.0.1
103+
maximum-paths 4
104+
!
105+
neighbor cilium peer-group
106+
neighbor cilium remote-as 64512
107+
neighbor cilium activate
108+
neighbor cilium soft-reconfiguration inbound
109+
neighbor 192.168.50.40 peer-group cilium
110+
neighbor 192.168.50.112 peer-group cilium
111+
neighbor 192.168.50.56 peer-group cilium
112+
neighbor 192.168.50.104 peer-group cilium
113+
address-family ipv4 unicast
114+
redistribute connected
115+
neighbor cilium activate
116+
neighbor cilium route-map ALLOW-ALL in
117+
neighbor cilium route-map ALLOW-ALL out
118+
neighbor cilium next-hop-self
119+
exit-address-family
120+
!
121+
route-map ALLOW-ALL permit 10
122+
!
123+
line vty
124+
!
125+
```
126+
127+
## Applying the Configuration
128+
Apply the Cilium BGP Configuration:
129+
1. Apply the bgp.yaml configuration to your Kubernetes cluster using the following command:
130+
```kubectl apply -f bgp.yaml```
131+
2. Configure FRR on Unifi Router: Upload the `frr.conf` file to your Unifi router and restart the FRR service to apply the changes.
132+
133+
## Verifying the Setup
134+
To verify that the routes are being advertised correctly, you can use the following commands:
135+
136+
On the Unifi router, check the BGP neighbors and advertised routes:
137+
```bash
138+
vtysh -c "show ip bgp summary"
139+
vtysh -c "show ip bgp"
140+
```
141+
On the Kubernetes cluster, check the Cilium BGP status:
142+
``` bash
143+
cilium bgp peers
144+
```
File renamed without changes.

0 commit comments

Comments
 (0)