OVN 北向数据库(OVN Northbound DB) 是 OVN 和 CMS 之间的接口,Northbound DB 的数据几乎都是由 CMS 产生的,ovn-northd 监听这个数据库的内容,然后翻译并保存到 Southbound DB 里面。
1 Northbound DB table
Northbound DB 主要有如下表:
Table | Purpose |
NB_Global | Northbound configuration |
Logical_Switch | L2 logical switch |
Logical_Switch_port | L2 logical switch port |
Forwarding_Group | forwarding group |
Address_Set | Address Sets |
Port_Group | Port Groups |
Load_Balancer | load balancer |
Load_Balancer_Health_Check | load balancer |
ACL | Access Control List (ACL) rule |
Logical_Router | L3 logical router |
Qos | QoS rule |
Meter | Meter entry |
Meter_Band | Band for meter entries |
Logical_Router_Port | L3 logical router port |
Logical_Router_Static_Route | Logical router static routes |
Logical_Router_Policy | Logical router policies |
NAT | NAT rules |
DHCP_Options | DHCP options |
Connection | OVSDB client connections. |
DNS | Native DNS resolution |
SSL | SSL configuration. |
Gateway_Chassis | Gateway_Chassis configuration. |
HA_Chassis_Group | HA_Chassis_Group configuration. |
HA_Chassis | HA_Chassis configuration. |
1.1 NB_Global
OVN 系统的北向数据配置,这个表必须只有一行
# ovn-nbctl list NB_Global
_uuid : 7121482c-296d-4b6d-a308-2f0534a240fa
connections : [914f8d62-1274-4b6c-ab89-ae470c5850f7]
external_ids : {}
hv_cfg : 109
hv_cfg_timestamp : 1627433467114
ipsec : false
name : ""
nb_cfg : 109
nb_cfg_timestamp : 1627433467107
options : {mac_prefix="c6:20:e4", max_tunid="16711680", northd_internal_version="20.12.1-20.12.0-51.0", svc_monitor_mac="5a:33:e0:76:bd:68", use_logical_dp_groups="true"}
sb_cfg : 109
sb_cfg_timestamp : 1627433467113
ssl : []
1.2 Logical_Switch
每一行代表一个 L2 逻辑交换机,逻辑交换机有两种,一种是全虚拟化网络( overlay logical switches 覆盖逻辑交换机),另一种到物理网络的简单连接(桥接逻辑网络)。
在相同的 chassis 上的逻辑端口之间提供连接时,他们的工作方式相同。但是在连接到远端逻辑端口时不容,Overlay 逻辑交换机通过隧道连接到远程逻辑端口,而 bridged 逻辑交换机在本地端口的帮助下通过将数据包桥接到直接连接的物理 L2 层来提供与远程端口的连接。
# ovn-nbctl list Logical_Switch
_uuid : 3e3d9065-34af-4996-af01-8b76a6c7385b
acls : []
dns_records : []
external_ids : {}
forwarding_groups : []
load_balancer : []
name : join
other_config : {exclude_ips="100.64.0.1", gateway="100.64.0.1", subnet="100.64.0.0/16"}
ports : [11595983-ff50-4de5-b4ff-7096e5146ade, 2e3a4223-2c56-446e-a351-2741329fdab6]
qos_rules : []
_uuid : 658a1f12-e95b-4503-87e8-df263c212c9e
acls : []
dns_records : []
external_ids : {}
forwarding_groups : []
load_balancer : [2489cc11-46cf-4cb6-87c2-e4520f82adf9, 4dea0f65-b894-4f55-b11b-43117c0748c1, 57cd5371-9384-49b3-81c3-3877a3252b6b, ffdee23a-66d1-46fc-9196-d542812dd6ba]
name : ovn-default
other_config : {exclude_ips="10.16.0.1", gateway="10.16.0.1", subnet="10.16.0.0/16"}
ports : [220d3518-c00d-411b-a1b2-419a55727728, 643846b5-a0cf-4e25-a48e-9cd76c659d1c, 698a6724-f80d-4d14-8f41-33285e424363, 8718d33b-29cc-4bbd-81b8-51ee193ca73e, 97191e3f-c9da-4f44-9e54-eb608565b1b6, bb75f9e9-15fc-4685-82ec-6a1c4cacfc96, ed345b86-de33-42e5-9a3f-cd5ec0986f47]
qos_rules : []
1.3 Logical_Switch_Port
L2 逻辑交换机上的端口
# ovn-nbctl list Logical_Switch_Port
_uuid : 220d3518-c00d-411b-a1b2-419a55727728
addresses : ["00:00:00:AE:DC:32"]
dhcpv4_options : []
dhcpv6_options : []
dynamic_addresses : []
enabled : []
external_ids : {}
ha_chassis_group : []
name : ovn-default-ovn-cluster
options : {router-port=ovn-cluster-ovn-default}
parent_name : []
port_security : []
tag : []
tag_request : []
type : router
up : true
_uuid : bb75f9e9-15fc-4685-82ec-6a1c4cacfc96
addresses : ["00:00:00:A9:87:3B 10.16.0.9"]
dhcpv4_options : []
dhcpv6_options : []
dynamic_addresses : []
enabled : []
external_ids : {pod="kube-system/kube-ovn-pinger-58272", vendor=kube-ovn}
ha_chassis_group : []
name : kube-ovn-pinger-58272.kube-system
options : {}
parent_name : []
port_security : []
tag : []
tag_request : []
type : ""
up : true
1.4 Load_Balancer
_uuid : ffdee23a-66d1-46fc-9196-d542812dd6ba
external_ids : {}
health_check : []
ip_port_mappings : {}
name : cluster-tcp-loadbalancer
protocol : tcp
selection_fields : []
vips : {"10.200.103.186:10660"="192.168.122.66:10660", "10.200.138.91:8080"="10.16.0.9:8080", "10.200.165.207:6641"="192.168.122.66:6641", "10.200.182.220:6642"="192.168.122.66:6642", "10.200.199.194:80"="10.16.0.4:80", "10.200.218.200:10665"="192.168.122.66:10665", "10.200.249.140:6643"="192.168.122.66:6643", "10.200.27.150:10661"="10.16.0.6:10661", "10.233.0.1:443"="192.168.122.66:6443", "10.233.0.3:53"="10.16.0.5:53", "10.233.0.3:9153"="10.16.0.5:9153"}
1.5 Logical_Router
每一行代表一个 L3 逻辑路由
# ovn-nbctl list Logical_Router
_uuid : fcd410f4-3304-416c-84f4-9a5ecefa1503
enabled : []
external_ids : {}
load_balancer : []
name : ovn-cluster
nat : []
options : {}
policies : []
ports : [0cc48914-712e-4c62-bbb0-b7caa152fcbe, e89b7d92-994c-4667-a33d-76d7c40422c3]
static_routes : [02dec743-e76b-4e11-80fc-1fb0675589e7, 13723d38-164d-48dd-856d-1cec6a33eb43, 1e8e72cd-30fe-4048-b7ee-90c038e7f71d, 1f181097-7ecd-4819-9d48-fffc71c7554d, 99cda30e-ae01-4e36-bb9e-c8d9e44e21cc, bf3207d7-f975-47d8-a48c-3fc9c32a9593, d2b6bc78-b64a-41c3-8a8d-dd48c9ca9563]
1.6 Logical_Router_Port
L3 逻辑路由器的端口
_uuid : e89b7d92-994c-4667-a33d-76d7c40422c3
enabled : []
external_ids : {}
gateway_chassis : []
ha_chassis_group : []
ipv6_prefix : []
ipv6_ra_configs : {}
mac : "00:00:00:D7:24:8A"
name : ovn-cluster-join
networks : ["100.64.0.1/16"]
options : {}
peer : []
1.7 ACL
用来设置访问控制列表,并且只能应用在逻辑交换机或者port group上,不能应用在逻辑路由器上。 参数包括优先级,方向,匹配域和动作。
_uuid : 4bff4d5b-9fb4-4e3e-9abb-f0b275f3d608
action : drop
direction : to-lport
external_ids : {}
log : true
match : "ip4.dst == $allow.all.ingress.default_ip4"
meter : []
name : "default/allow-all-ingress"
priority : 2000
severity : warning
- priority, 指定 acl 规则的优先级,值越大优先级越高。如果匹配到的多条规则优先级相同,最终哪条规则生效是不确定的。
- direction,指定报文的方向,只有两个值: from-lport 和 to-lport。逻辑交换机的角度入和出
- match, 用来指定报文匹配域,具体的表达式规则可参考sbdb中 logical_flow table 的 match 列。注意:类型为 localnet 和 router 的端口上不能应用 acl 规则。
- action, 对于匹配到规则的报文的处理,目前支持四个值:allow, allow-related, drop, or reject。
allow: 允许报文通过
allow-related:允许报文和其响应报文通过
drop:丢弃报文
reject:丢弃报文,并回复报文。对于tcp协议报文,回复rst,对于其他类型的报文,回复ICMPv4/ICMPv6 unreachable。
注意: 只在 acl table 添加规则是没用的,还需要将其应用到逻辑交换机或者 port group。
_uuid : d675ffcf-cb18-44e7-b036-7f73587da241
acls : [2381cf60-ce5d-4c75-b1e1-29aa49199ac7, 4bff4d5b-9fb4-4e3e-9abb-f0b275f3d608, 74b79bf5-3db7-45c5-9b60-738886ac47fd, 887d20f3-58d8-4d98-90b3-73169384d261]
external_ids : {np="default/allow-all-ingress"}
name : allow.all.ingress.default
ports : []
1.8 Port_Group
此表中的每一行代表一组已命名的逻辑交换机端口。
# ovn-nbctl list Port_Group
_uuid : ab6946ee-11ba-41e0-8729-65625a56dc1c
acls : [1df19ac5-2fe5-4e95-aa10-8977e720db3f, 82114193-435e-4223-9ef6-bcdb1aecb93a]
external_ids : {np="node/node1"}
name : node.node1
ports : [25a7d62e-c33a-4ae4-9407-d33ef779af1c, 768ac4de-b6ac-42bb-843d-15f1b155a822, 850ef2df-0c7e-4249-a1a7-52beb68b11ab, 8856795a-30c7-46ea-ae63-c5c857205e42, f987a00a-b3d7-4953-87e9-a2efb4e4dba1]
2. ovn-nbctl 命令
ovn-nbctl [options] command [arg...]
2.1 GENERAL COMMANDS
ovn-nbctl init
onv-nbctl show [switch | router]
2.2 LOGICAL SWITCH 逻辑交换机命令
ovn-nbctl ls-add, 创建一个新的没有名字的逻辑交换机也没有端口
ovn-nbctl [--may-exist | --add-duplicate] ls-add switch
ovn-nbctl [--if-exists] ls-del switch
ovn-nbctl ls-list
2.2.1 LOGICAL SWITCH PORT 命令
2.3 LOGICAL ROUTER 逻辑路由器命令
ovn-nbctl lr-add
ovn-nbctl [--may-exist | --add-duplicate] lr-add router
ovn-nbctl [--if-exists] lr-del router
ovn-nbctl lr-list
2.3.1 LOGICAL ROUTER PORT 命令
2.3.2 LOGICAL ROUTER STATIC ROUTE 命令
2.3.3 LOGICAL ROUTER POLICY 命令
2.4 LOAD BALANCER 命令
2.5 Port group 命令
pg-add PG [PORTS] Create port group PG with optional PORTS
pg-set-ports PG PORTS Set PORTS on port group PG
pg-del PG Delete port group PG
参考:
https://www.ovn.org/support/dist-docs/ovn-nb.5.txt
https://www.ovn.org/support/dist-docs/ovn-nbctl.8.txt
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)