1.12. 使用动态匹配和模板的策略配置示例


以下示例配置片段显示使用动态匹配和模板的节点网络策略。

重要

应用使用动态匹配和模板的节点网络配置策略只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。

有关红帽技术预览功能支持范围的更多信息,请参阅技术预览功能支持范围

在集群的节点上创建一个 Linux 网桥接口,并通过将单个 NodeNetworkConfigurationPolicy 清单应用到集群来将 NIC 的静态 IP 配置传输到桥接。

以下 YAML 文件是 Linux 网桥界面的清单示例。它包含了示例值,需要使用自己的信息替换。

apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: br1-eth1-copy-ipv4-policy 
1

spec:
  nodeSelector: 
2

    node-role.kubernetes.io/worker: ""
  capture:
    eth1-nic: interfaces.name=="eth1" 
3

    eth1-routes: routes.running.next-hop-interface=="eth1"
    br1-routes: capture.eth1-routes | routes.running.next-hop-interface := "br1"
  desiredState:
    interfaces:
      - name: br1
        description: Linux bridge with eth1 as a port
        type: linux-bridge 
4

        state: up
        ipv4: "{{ capture.eth1-nic.interfaces.0.ipv4 }}" 
5

        bridge:
          options:
            stp:
              enabled: false
          port:
            - name: eth1 
6

     routes:
        config: "{{ capture.br1-routes.routes.running }}"
Copy to Clipboard Toggle word wrap
1
策略的名称。
2
可选: 如果没有包括 nodeSelector 参数,策略会应用到集群中的所有节点。本例使用 node-role.kubernetes.io/worker:"" 节点选择器来选择集群中的所有 worker 节点。
3
对网桥附加的节点 NIC 的引用。
4
接口的类型。这个示例会创建一个桥接。
5
网桥接口的 IP 地址。这个值与 spec.capture.eth1-nic 条目引用的 NIC 的 IP 地址匹配。
6
网桥附加到的节点 NIC。

以下 YAML 文件是一个 NodeNetworkConfigurationPolicy 清单示例,它为 OpenShift Container Platform 集群中的所有以太网端口启用 Link Layer Discovery Protocol (LLDP)监听程序。本地区域网络上的设备可以使用 LLDP 来公告其身份、功能和邻居信息。

apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: enable-lldp-ethernets-up 
1

spec:
  capture:
    ethernets: interfaces.type=="ethernet"
    ethernets-up: capture.ethernets | interfaces.state=="up"
    ethernets-lldp: capture.ethernets-up | interfaces.lldp.enabled:=true 
2

  desiredState:
    interfaces: "{{ capture.ethernets-lldp.interfaces }}"
# ...
Copy to Clipboard Toggle word wrap
1
指定节点网络配置策略的名称。
2
指定为接口状态设置为 up 的所有以太网端口启用 LLDP。
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat