
Cilium 应用 CiliumBGPClusterConfig 后 BGP peering 未建立怎么排查【免费下载链接】ciliumeBPF-based Networking, Security, and Observability项目地址: https://gitcode.com/GitHub_Trending/ci/cilium你已经在集群中启用了 Cilium BGP Control Plane并应用了CiliumBGPClusterConfig资源但 Cilium 节点与对端路由器之间的 BGP 会话一直没有进入established状态。本文基于 Cilium 官方文档Documentation/network/bgp-control-plane/目录梳理出一条完整的排查路径先确认 peering 的实时状态再分两个方向定位——节点根本没被nodeSelector选中或CiliumBGPNodeConfig未生成节点已被选中但 BGP 会话本身建不起来。排查依据是文档明确给出的两类证据CRD 的.status.conditions和带subsysbgp-control-plane/subsysbgp-cp-operator标签的日志。前置条件集群中 Cilium 已通过 Helm 值bgpControlPlane.enabledtrue启用了 BGP Control PlaneCilium operator 和 Cilium agent 正在运行CiliumBGPClusterConfig以及它引用的CiliumBGPPeerConfig已应用。BGP Control Plane 的资源关系如下图所示相关文档BGP 控制面总览、配置文档、操作指南、排查指南。第一步确认当前 peering 状态排查前先拿到两份实时状态它们决定后面走哪个分支。用 Cilium CLI 的cilium bgp子命令查看集群内所有节点的 peering 状态cilium bgp peers下面是文档给出的示例输出文档示例节点名和数值以你集群实际为准Node Local AS Peer AS Peer Address Session State Uptime Family Received Advertised bgp-cplane-dev-service-control-plane 65001 65000 fd00:10::1 established 33m26s ipv4/unicast 2 2 ipv6/unicast 2 2 bgp-cplane-dev-service-worker 65001 65000 fd00:10::1 established 33m25s ipv4/unicast 2 2 ipv6/unicast 2 2判断依据Session State列应为established同时Received/Advertised列显示期望数量的路由。如果某行状态不是established或节点根本不出现在列表里继续下面的分支排查。再看目标节点对应的CiliumBGPNodeConfig。这个资源由 Cilium operator 根据CiliumBGPClusterConfig自动生成是每个节点 BGP 配置的唯一来源其status字段维护实时的 BGP 运行状态文档称之为可用于自动化或监控。# node-name 替换为目标节点名例如文档示例中的 bgp-cplane-dev-service-worker kubectl describe ciliumbgpnodeconfigs node-name文档示例输出文档示例中Status部分会显示Peering State: established、Established Time、各地址族的Route Count以及Timers如Applied Hold Time Seconds: 90、Applied Keepalive Seconds: 30。由此分出两个分支CiliumBGPNodeConfig资源不存在说明 operator 没有为该节点生成配置走“分支一”资源存在但Peering State不是established节点已被选中问题出在会话本身走“分支二”。分支一CiliumBGPNodeConfig 未生成或节点未被选中检查 CiliumBGPClusterConfig 的 status conditionsCiliumBGPClusterConfig会在.status.conditions中上报运行时捕获的配置错误。文档定义了三种条件Condition Name含义cilium.io/NoMatchingNode.spec.nodeSelector没有选中任何节点cilium.io/MissingPeerConfigsspec.bgpInstances[].peers[].peerConfigRef引用的CiliumBGPPeerConfig不存在cilium.io/ConflictingClusterConfig存在另一个CiliumBGPClusterConfig选中了相同的节点查看方式# cluster-config-name 替换为你的 CiliumBGPClusterConfig 名称 kubectl get ciliumbgpclusterconfigs cluster-config-name -o yaml文档给出了NoMatchingNode的示例 status 片段文档示例status: conditions: - lastTransitionTime: 2026-06-16T12:54:24Z message: No node matches spec.nodeSelector observedGeneration: 2 reason: MatchingNodeUnavailable status: True type: cilium.io/NoMatchingNode出现该条件时排查spec.nodeSelector与节点实际 label 是否一致——文档指出的原因是节点缺少相应 label或 selector 本身配错。ConflictingClusterConfig的示例片段文档示例status: conditions: - lastTransitionTime: 2026-06-16T12:55:24Z message: Selecting the same node(s) with ClusterConfig(s): [tor-control-plane] observedGeneration: 1 reason: ClusterConfigConflict status: True type: cilium.io/ConflictingClusterConfig这条条件意味着多个CiliumBGPClusterConfig通过nodeSelector选中了同一批节点Cilium operator 会拒绝后续资源创建CiliumBGPNodeConfig。CiliumBGPPeerConfig引用的peerConfigRef写错如 typo时则会出现MissingPeerConfigs其 message 类似文档示例中的Referenced CiliumBGPPeerConfig(s) are missing: [peer-config-1]。另外CiliumBGPPeerConfig还有自己的条件cilium.io/MissingAuthSecret.spec.authSecretRef引用的 Secret 不存在。检查 Cilium operator 日志operator 负责把CiliumBGPClusterConfig翻译成每节点的CiliumBGPNodeConfig。如果CiliumBGPNodeConfig缺失文档要求检查 Cilium operator 日志中的错误。operator 的 BGP 日志带subsysbgp-cp-operator标签# cilium operator pod name 替换为实际的 operator pod 名namespace 以你的安装为准文档示例为 kube-system kubectl -n kube-system logs cilium operator pod name | grep subsysbgp-cp-operator另一个需要排除的运行前提operator 本身宕机时BGP 控制面的 provisioning 会停止同时 PodCIDR 分配和 LB-IPAM 的 LoadBalancer IP 分配也会停止新路由不会再生成。文档给出的缓解方式是以高可用方式部署 Cilium operator。分支二节点已被选中但 BGP 会话未建立过滤 Cilium agent 的 BGP 控制面日志BGP Control Plane 的错误日志带subsysbgp-control-plane字段可以用它过滤出与 BGP 控制面相关的错误# cilium agent pod name 替换为目标节点上运行的 cilium agent pod 名 kubectl -n kube-system logs cilium agent pod name | grep subsysbgp-control-plane文档给出的一个典型告警示例文档示例levelwarning msgsent notification Dataas number mismatch expected 65003, received 65000 Key10.0.1.1 TopicPeer asn65001 componentgobgp.BgpServerInstance subsysbgp-control-plane该示例说明会话未建立的原因是对端实际 ASN 与CiliumBGPClusterConfig中配置的peerASN不一致。对照你的配置检查peerASN与peerAddress字段文档列出的会话建立失败原因包括 BGP capability 不匹配、Peer IP 地址错误等BGP 层的错误通常会出现在日志里。日志里没有错误时低层连通性问题文档明确提示有些低层错误不会反映在日志中例如到 Peer IP 的连通性缺失或 eBGP 对端距离超过 1 跳。文档建议此时用tcpdump或WireShark抓包分析。与“超过 1 跳”直接相关的配置项是CiliumBGPPeerConfig的ebgpMultihopeBGP 默认 BGP 报文 IP TTL 为 1当对端如 Route Server在不同子网时需要将其设为大于 1 的值apiVersion: cilium.io/v2 kind: CiliumBGPPeerConfig metadata: name: cilium-peer spec: ebgpMultihop: 4 # 指定 TTL 值MD5 密码错误会伪装成 i/o timeout如果CiliumBGPPeerConfig配置了authSecretRefRFC-2385 TCP MD5 密码密码错误时并不会给出明确的认证错误而是表现为 Cilium Agent 日志中的dial: i/o timeout。另外若引用的 Secret 根本不存在agent 会以空密码继续并记录类似文档示例的错误日志levelerror msgFailed to fetch secret \secretname\: not found (will continue with empty password) componentmanager.fetchPeerPassword subsysbgp-control-plane注意文档给出的限制TCP MD5 密码对包头签名因此不能用于 Cilium 做了地址转换的会话BGP 对端看到的地址必须是 Cilium Agent 的 Pod IP 地址。其他会话参数核对点监听端口默认情况下 BGP router 不监听端口只能主动发起连接这是设计上的默认行为适用于同节点还有 Bird 等其他 BGP router 的场景。如果要求对端入站连接需要在CiliumBGPClusterConfig中配置localPort监听 179 端口需要通过 Helm 值securityContext.capabilities.ciliumAgent授予CAP_NET_BIND_SERVICE。定时器connectRetryTimeSeconds默认 120、holdTimeSeconds默认 90、keepAliveTimeSeconds默认 30可在CiliumBGPPeerConfig的timers中调整。文档建议数据中心场景调低holdTimeSeconds/keepAliveTimeSeconds最小值分别为 3 和 1以加快故障检测并调低connectRetryTimeSeconds例如 5 或更小以加快断连后重连。调低后若仍长时间停在非 established 状态日志中应能看到重试相关的 BGP 层错误。成功判定与已知限制会话恢复正常的判定标准回到第一步的两处输出cilium bgp peers中该节点Session State为established且Received/Advertised路由数符合预期kubectl describe ciliumbgpnodeconfigs node-name中Peering State为establishedEstablished Time与Route Count正常更新。与 peering 建立相关的已知限制均来自文档Cilium 目前不支持 BFD双向转发检测文档指出这是加快链路故障检测的一般手段但当前不实现定时器下限为holdTimeSeconds3、keepAliveTimeSeconds1不配置localPort时 router 只发起连接不接受入站连接监听 179 端口需要CAP_NET_BIND_SERVICE。如果你的CiliumBGPClusterConfig里使用了autoDiscoveryDefaultGateway 模式而不是显式peerAddress验证方式同样是cilium bgp peers该模式下 ToR 交换机侧需要配置bgp listen range以接受动态邻居link-local 地址作为默认网关不受支持。排查到这一步仍未建立时按文档指出的优先级依次确认nodeSelector/label、peerConfigRef与peerASN/peerAddress、agent 日志中的 BGP 层错误、以及日志之外的低层连通性抓包。每一步的证据都来自 CRD status 或带subsys标签的日志无需依赖猜测。【免费下载链接】ciliumeBPF-based Networking, Security, and Observability项目地址: https://gitcode.com/GitHub_Trending/ci/cilium创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考