Skip to content

Commit 6ccf19a

Browse files
committed
Add support from BBR in cilium
Signed-off-by: Nimanou <support@nimanou.com>
1 parent b587387 commit 6ccf19a

12 files changed

Lines changed: 144 additions & 0 deletions

File tree

docs/networking/cilium.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,52 @@ kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/downloa
277277

278278
For more information about using the Gateway API with Cilium, see the [Cilium Gateway API documentation](https://docs.cilium.io/en/stable/network/servicemesh/gateway-api/).
279279

280+
## Bandwidth Manager and BBR
281+
282+
Cilium can enforce per-Pod egress bandwidth limits (via the `kubernetes.io/egress-bandwidth` annotation) using its eBPF-based [Bandwidth Manager](https://docs.cilium.io/en/stable/network/kubernetes/bandwidth-manager/), and optionally use [BBR](https://docs.cilium.io/en/stable/network/kubernetes/bandwidth-manager/#bbr-tcp-congestion-control) as the TCP congestion control algorithm for Pod traffic.
283+
284+
You can enable the Bandwidth Manager on its own:
285+
286+
```yaml
287+
spec:
288+
networking:
289+
cilium:
290+
enableBandwidthManager: true
291+
```
292+
293+
Or enable Bandwidth Manager **and** BBR together:
294+
295+
```yaml
296+
spec:
297+
networking:
298+
cilium:
299+
enableBandwidthManager: true
300+
enableBBR: true
301+
```
302+
303+
`enableBBR` requires `enableBandwidthManager` — Cilium's BBR path plugs into the Bandwidth Manager's eBPF EDT scheduler, so without Bandwidth Manager there is nothing for it to attach to. When `enableBBR` is set, kOps also writes the node sysctls `net.core.default_qdisc=fq` and `net.ipv4.tcp_congestion_control=bbr` so the host kernel TCP stack uses BBR as well.
304+
305+
**Requirements**
306+
307+
- Linux kernel **>= 5.18** on every node when `enableBBR` is set (the eBPF BBR pacing path needs a recent kernel). The Bandwidth Manager on its own works on older 5.x kernels.
308+
- Direct routing or BPF host routing. The default kOps + Cilium setup satisfies this.
309+
310+
**Notes on AWS + Ubuntu**
311+
312+
- Ubuntu 22.04 (kernel 5.15) does not include the BBR pacing path Cilium uses; prefer Ubuntu 24.04 (kernel 6.8) or a newer HWE kernel.
313+
- The kOps default AWS AMI (Ubuntu) ships with the `tcp_bbr` module; no extra image customization is required.
314+
315+
**When BBR helps in AWS**
316+
317+
BBR's advantage scales with the bandwidth-delay product (BDP). Modern AWS instances have ENA NICs in the 10–100 Gbps range, so even at sub-millisecond intra-AZ RTT — and especially at 1–2 ms cross-AZ — the BDP is large enough that a single CUBIC flow needs seconds to ramp up to line rate and backs off hard on any random loss. BBR converges to the bottleneck bandwidth much faster and is far more resilient to spurious loss. Workloads that typically benefit:
318+
319+
- Large pod-to-pod or pod-to-service transfers (model checkpoints, dataset shuffles, backups, log shipping).
320+
- Cross-AZ replication and database streaming.
321+
- Egress to S3 / other AWS services over VPC endpoints, and any egress to the internet.
322+
- Workloads on instances with 25 Gbps+ networking where a single flow is expected to fill the pipe.
323+
324+
For workloads dominated by very short, low-volume RPCs on the same AZ, the practical difference is smaller — but BBR is generally safe to enable cluster-wide.
325+
280326
## Getting help
281327

282328
For problems with deploying Cilium please post an issue to Github:

nodeup/pkg/model/sysctls.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,16 @@ func (b *SysctlBuilder) Build(c *fi.NodeupModelBuilderContext) error {
170170
"net.ipv4.conf.lxc*.rp_filter=0",
171171
"net.ipv4.conf.cilium_*.rp_filter=0",
172172
"")
173+
174+
if fi.ValueOf(b.NodeupConfig.Networking.Cilium.EnableBBR) {
175+
sysctls = append(sysctls,
176+
"# BBR congestion control for Cilium Bandwidth Manager.",
177+
"# Requires Linux kernel >= 5.18 on the node.",
178+
"# See https://docs.cilium.io/en/stable/network/kubernetes/bandwidth-manager/",
179+
"net.core.default_qdisc=fq",
180+
"net.ipv4.tcp_congestion_control=bbr",
181+
"")
182+
}
173183
}
174184

175185
sysctls = append(sysctls, b.NodeupConfig.SysctlParameters...)

pkg/apis/kops/networking.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,19 @@ type CiliumNetworkingSpec struct {
407407
// EnableHostFirewall enables the host firewall in the Cilium agent.
408408
// Default: false
409409
EnableHostFirewall *bool `json:"enableHostFirewall,omitempty"`
410+
// EnableBandwidthManager enables Cilium's eBPF-based Bandwidth Manager, which
411+
// honors the kubernetes.io/egress-bandwidth Pod annotation and provides EDT-based
412+
// rate-limiting on egress traffic.
413+
// See https://docs.cilium.io/en/stable/network/kubernetes/bandwidth-manager/
414+
// Default: false
415+
EnableBandwidthManager *bool `json:"enableBandwidthManager,omitempty"`
416+
// EnableBBR enables BBR (Bottleneck Bandwidth and Round-trip propagation time)
417+
// as the TCP congestion control algorithm for pod traffic. Requires
418+
// EnableBandwidthManager and a Linux kernel >= 5.18 on nodes.
419+
// kOps will also configure the node sysctls (net.core.default_qdisc=fq,
420+
// net.ipv4.tcp_congestion_control=bbr).
421+
// Default: false
422+
EnableBBR *bool `json:"enableBBR,omitempty"`
410423
// EnablePrometheusMetrics enables the Cilium "/metrics" endpoint for both the agent and the operator.
411424
EnablePrometheusMetrics bool `json:"enablePrometheusMetrics,omitempty"`
412425
// EnableEncryption enables Cilium Encryption.

pkg/apis/kops/v1alpha2/networking.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,19 @@ type CiliumNetworkingSpec struct {
405405
// EnableHostFirewall enables the host firewall in the Cilium agent.
406406
// Default: false
407407
EnableHostFirewall *bool `json:"enableHostFirewall,omitempty"`
408+
// EnableBandwidthManager enables Cilium's eBPF-based Bandwidth Manager, which
409+
// honors the kubernetes.io/egress-bandwidth Pod annotation and provides EDT-based
410+
// rate-limiting on egress traffic.
411+
// See https://docs.cilium.io/en/stable/network/kubernetes/bandwidth-manager/
412+
// Default: false
413+
EnableBandwidthManager *bool `json:"enableBandwidthManager,omitempty"`
414+
// EnableBBR enables BBR (Bottleneck Bandwidth and Round-trip propagation time)
415+
// as the TCP congestion control algorithm for pod traffic. Requires
416+
// EnableBandwidthManager and a Linux kernel >= 5.18 on nodes.
417+
// kOps will also configure the node sysctls (net.core.default_qdisc=fq,
418+
// net.ipv4.tcp_congestion_control=bbr).
419+
// Default: false
420+
EnableBBR *bool `json:"enableBBR,omitempty"`
408421
// EnableTracing is unused.
409422
// +k8s:conversion-gen=false
410423
EnableTracing bool `json:"enableTracing,omitempty"`

pkg/apis/kops/v1alpha2/zz_generated.conversion.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kops/v1alpha3/networking.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,19 @@ type CiliumNetworkingSpec struct {
355355
// EnableHostFirewall enables the host firewall in the Cilium agent.
356356
// Default: false
357357
EnableHostFirewall *bool `json:"enableHostFirewall,omitempty"`
358+
// EnableBandwidthManager enables Cilium's eBPF-based Bandwidth Manager, which
359+
// honors the kubernetes.io/egress-bandwidth Pod annotation and provides EDT-based
360+
// rate-limiting on egress traffic.
361+
// See https://docs.cilium.io/en/stable/network/kubernetes/bandwidth-manager/
362+
// Default: false
363+
EnableBandwidthManager *bool `json:"enableBandwidthManager,omitempty"`
364+
// EnableBBR enables BBR (Bottleneck Bandwidth and Round-trip propagation time)
365+
// as the TCP congestion control algorithm for pod traffic. Requires
366+
// EnableBandwidthManager and a Linux kernel >= 5.18 on nodes.
367+
// kOps will also configure the node sysctls (net.core.default_qdisc=fq,
368+
// net.ipv4.tcp_congestion_control=bbr).
369+
// Default: false
370+
EnableBBR *bool `json:"enableBBR,omitempty"`
358371
// EnablePrometheusMetrics enables the Cilium "/metrics" endpoint for both the agent and the operator.
359372
EnablePrometheusMetrics bool `json:"enablePrometheusMetrics,omitempty"`
360373
// EnableEncryption enables Cilium Encryption.

pkg/apis/kops/v1alpha3/zz_generated.conversion.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kops/v1alpha3/zz_generated.deepcopy.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kops/validation/validation.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,10 @@ func validateNetworkingCilium(cluster *kops.Cluster, v *kops.CiliumNetworkingSpe
14021402
allErrs = append(allErrs, field.Forbidden(fldPath.Child("enableL7Proxy"), "Cilium L7 Proxy requires installIptablesRules."))
14031403
}
14041404

1405+
if fi.ValueOf(v.EnableBBR) && !fi.ValueOf(v.EnableBandwidthManager) {
1406+
allErrs = append(allErrs, field.Forbidden(fldPath.Child("enableBBR"), "enableBBR requires enableBandwidthManager"))
1407+
}
1408+
14051409
if v.IPAM != "" {
14061410
// "azure" not supported by kops
14071411
allErrs = append(allErrs, IsValidValue(fldPath.Child("ipam"), &v.IPAM, []string{"hostscope", "kubernetes", "crd", "eni"})...)

0 commit comments

Comments
 (0)