Translated message

A translation of this page exists in English.

在 OpenShift 上使用辅助接口的 MetalLB LoadBalancer IP 的对称路由配置

Solution In Progress - Updated -

Issue

  • MetalLB 从辅助接口通告 LB 类型 IP,要求配置 OCP 节点通过辅助接口接收 MetalLB 提供的 LB IP 上的应用流量,并通过辅助接口发送响应。

  • 当用严格模式在系统上启用RP_filter 时(net.ipv4.conf.default.rp_filter = 1net.ipv4.conf.all.rp_filter = 1 ),它会验证接收数据包的来源是否可通过到达的同一接口进行访问。如果不能,则丢弃数据包。如果它被禁用或启用为宽松模式(net.ipv4.conf.all.rp_filter = 2net.ipv4.conf.default.rp_filter = 2),系统将尝试通过默认网关使用默认路由或通过其他网关/路由根据路由配置通过不同的接口将响应发送回源地址。在 OCP 节点上,默认情况下 rp_filter 是禁用的。

示例实验环境/要求

  • MetalLB 为 test-vlan-mb 命名空间提供来自 ip-addresspool-90 的 IP 地址。

    $ oc get ipaddresspools.metallb.io ip-addresspool-90 -o yaml
    
    apiVersion: metallb.io/v1beta1
    kind: IPAddressPool
    metadata:
      name: ip-addresspool-90
      namespace: metallb-system
      resourceVersion: "265512386"
      uid: a146b8be-70ae-41de-a7d0-f876ad4dc67c
    spec:
      addresses:
      - 192.168.90.60-192.168.90.70
      autoAssign: true
      avoidBuggyIPs: true
      serviceAllocation:
        namespaces:
        - test-vlan-mb
    
  • MetalLB从 worker-1 节点的 bond0.3208 vlan 接口通告 LB IP。

    $ oc get l2advertisements.metallb.io l2-adv-90 -o yaml
    
    apiVersion: metallb.io/v1beta1
    kind: L2Advertisement
    metadata:
      name: l2-adv-90
      namespace: metallb-system
    spec:
      interfaces:
      - bond0.3208
      ipAddressPools:
      - ip-addresspool-90
      nodeSelectors:
      - matchLabels:
          kubernetes.io/hostname: worker-1
    
  • 要求将 OCP 节点 worker-1 配置为通过 bond0.3208 vlan 接口接收应用流量并通过同一接口发送响应。

其他实验环境详细信息
MetalLB  IP: 192.168.90.60
SVC IP of MetalLB IP : 172.30.114.10 (externalTrafficPolicy: Cluster)
Primary Interface: enp1s0(br-ex replicates from enp1s0 during boot)
Secondary VLAN Interface: bond0.3208
SVC subnet: 172.30.0.0/16 
SVC Masquerade GW: 169.254.169.4

$ oc get svc -n test-vlan-mb 
NAME   TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)          AGE
web1   LoadBalancer   172.30.114.10   192.168.90.60   8080:30102/TCP   17d

worker-1 上的 MetalLB IP 的 DNAT 表。MetalLB 会为每个 LB IP 自动添加此表项。

[root@worker-1 ~]# iptables -L -n -t nat | grep 192.168.90.60
DNAT       6    --  0.0.0.0/0            192.168.90.60        tcp dpt:8080 to:172.30.114.10:8080

先决条件

Environment

  • Red Hat OpenShift Container Platform (RHOCP)
    • 4

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content