1.12. 使用动态匹配和模板的策略配置示例
以下示例配置片段显示使用动态匹配和模板的节点网络策略。
重要
应用使用动态匹配和模板的节点网络配置策略只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。
有关红帽技术预览功能支持范围的更多信息,请参阅以下链接:
1.12.1. 示例:Linux 网桥接口节点网络配置策略,用于从附加到网桥的 NIC 中继承静态 IP 地址 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
在集群的节点上创建一个 Linux 网桥接口,并通过将单个 NodeNetworkConfigurationPolicy 清单应用到集群来将 NIC 的静态 IP 配置传输到桥接。
以下 YAML 文件是 Linux 网桥界面的清单示例。它包含了示例值,需要使用自己的信息替换。
apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
name: br1-eth1-copy-ipv4-policy
spec:
nodeSelector:
node-role.kubernetes.io/worker: ""
capture:
eth1-nic: interfaces.name=="eth1"
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
state: up
ipv4: "{{ capture.eth1-nic.interfaces.0.ipv4 }}"
bridge:
options:
stp:
enabled: false
port:
- name: eth1
routes:
config: "{{ capture.br1-routes.routes.running }}"
1.12.2. 示例:启用 LLDP 报告的节点网络配置策略 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
以下 YAML 文件是一个 NodeNetworkConfigurationPolicy 清单示例,它为 OpenShift Container Platform 集群中的所有以太网端口启用 Link Layer Discovery Protocol (LLDP)监听程序。本地区域网络上的设备可以使用 LLDP 来公告其身份、功能和邻居信息。
apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
name: enable-lldp-ethernets-up
spec:
capture:
ethernets: interfaces.type=="ethernet"
ethernets-up: capture.ethernets | interfaces.state=="up"
ethernets-lldp: capture.ethernets-up | interfaces.lldp.enabled:=true
desiredState:
interfaces: "{{ capture.ethernets-lldp.interfaces }}"
# ...