Neutron和SDN集成現(xiàn)狀分析
一.Neutron概要
總所周知,Neutron是OpenStack眾多項目中的核心項目之一,代表其網(wǎng)絡(luò)服務(wù)。
Neutron的發(fā)展自誕生到現(xiàn)在,可謂是一波三折,其命名先是由nova-network,改為quantum,因其與一家公司名沖突,隧又改為Neutron。表面上的命名變化,又何嘗不蘊含著其深層次的發(fā)展和演進,以Plugin、高級網(wǎng)絡(luò)服務(wù)功能等突出應(yīng)用,充分顯示著它不斷的豐富,就像其命名“中子”一樣,彰顯著它在浩瀚宇宙中,熠熠生輝的光芒。
下面,借用“北京-小武”一文《Neutron的SDN化》中,Neutron是什么和Neutron的主要功能為線索,來添加自己的認識。
1.Neutron是什么
Openstack核心項目中的網(wǎng)絡(luò)配置管理組件
Neutron的網(wǎng)絡(luò)服務(wù)功能包括L2-L7層
Neutron用于管理配置VM所用的網(wǎng)絡(luò)
Neutron有很多SDN控制器作為ML2 Plugin和ML3 Plugin(注:ONOS在計劃中)
2.Neutron的主要功能
1)ML2功能
ML2功能包括Port、Subnet、Network、Qos、安全組等,Linux 網(wǎng)橋是虛擬交換機的一種實現(xiàn),ML2 層使用 VLAN 和VXLAN(利用 L3 層擴展ML2 層的遂道技術(shù))來實現(xiàn)物理隔離。
在ML2 層,由虛擬交換機來實現(xiàn)。虛擬交換機有下列這些:
l Linux 網(wǎng)橋,基于 Linux 內(nèi)核的網(wǎng)橋。網(wǎng)橋就是交換機的具體體現(xiàn),比如OpenStack中常見的br-int。
l OpenvSwitch(OVS):OVS 有兩種模式,一種是當普通的虛擬交換機來使用,另一個是和 OpenFlow 控制器協(xié)作當作SDN交換機來使用。
l 一些基于 Overlay 技術(shù)的 SDN 實現(xiàn),如VXLAN等。
l 一些非開源的商業(yè)交換機。
目前,Neutron 已經(jīng)實現(xiàn)的 ML2 層Drivers如下圖所示(Liberty版代碼)。
linuxbridge 實現(xiàn)了 Linux 的內(nèi)核網(wǎng)橋,openvswitch driver實現(xiàn)了 openvswitch 網(wǎng)橋,hyperv driver用于實現(xiàn)和微軟的Hyper-V虛擬化產(chǎn)品進行交互,brocade的driver用于和博科的SDN產(chǎn)品進行交互,其他類似。ml2 是一種通用、核心且基礎(chǔ)的插件,這些 L2 層的插件主要分寫數(shù)據(jù)庫的plugin 部分和運行在計算節(jié)點的 agent 部分。在Neutron中,ML2是其Core Plugin。詳情,請參見Neutron代碼的入口配置文件neutron/setup.cfg,其代碼如下:
neutron.core_plugins =
bigswitch = neutron.plugins.bigswitch.plugin:NeutronRestProxyV2
brocade = neutron.plugins.brocade.NeutronPlugin:BrocadePluginV2
ml2 = neutron.plugins.ml2.plugin:Ml2Plugin
nuage = neutron.plugins.nuage.plugin:NuagePlugin
ML2 plugin的代碼因為有很多相同,便使用了復(fù)用和模塊間的導(dǎo)入、裝飾器等語法,ml2 可以理解為一個公共的 plugin。且每種插件基本上實現(xiàn)了 FLAT、local 、VLAN、VXLAN、GRE 等幾種拓撲。詳情,請參見Neutron代碼的入口配置文件neutron/setup.cfg(neutron.ml2.type_drivers部分),其代碼如下:
neutron.ml2.type_drivers =
flat = neutron.plugins.ml2.drivers.type_flat:FlatTypeDriver
local = neutron.plugins.ml2.drivers.type_local:LocalTypeDriver
vlan = neutron.plugins.ml2.drivers.type_vlan:VlanTypeDriver
geneve = neutron.plugins.ml2.drivers.type_geneve:GeneveTypeDriver
gre = neutron.plugins.ml2.drivers.type_gre:GreTypeDriver
vxlan = neutron.plugins.ml2.drivers.type_vxlan:VxlanTypeDriver
2)L3功能
L3功能,包括Router/DVR、DCHP等服務(wù),L3層通過 ipv4 forward 功能進行靜態(tài)路由轉(zhuǎn)發(fā),使用iptables的SNAT和DNAT規(guī)則實現(xiàn)內(nèi)網(wǎng)中的虛機訪問外網(wǎng)和外網(wǎng)訪問內(nèi)網(wǎng)上的虛機(也就是所謂的Floating IP)。和利用 L2 層擴展 L3 層的標簽技術(shù)MPLS(一般用在WAN的路由器上)。
3)L4-L7功能
L4-L7功能,包括FWaas、LBaas、VPNaas、DNSaas-Designate等服務(wù)。
從網(wǎng)絡(luò)功能和對應(yīng)的底層網(wǎng)絡(luò)設(shè)備實現(xiàn)來看,Port對應(yīng)VM掛載的VNIC相應(yīng)TAP/TUN設(shè)備,Subnet只是一個IP地址 Pool的數(shù)據(jù)集合,Network則要對應(yīng)分配的網(wǎng)絡(luò)類型和相應(yīng)隔離域ID,Qos功能可以基于OVS來實現(xiàn),安全組則基于linux bridge上的iptables實現(xiàn)。
L3上Router通過linux的Namespace實現(xiàn),Dragonflow則是通過OpenvSwitch的流表實現(xiàn),DHCP和DNS服務(wù)通過Dnsmasq實現(xiàn);L4-L7的服務(wù)開源實現(xiàn)方案里,F(xiàn)Waas是通過Router里的Iptables,LBaas是通過Haproxy,VPNaas則是Openswan,當然現(xiàn)在很多設(shè)備廠商比如Juniper、思科、華為、博科和F5等對L2-L7的服務(wù)實現(xiàn)都提供了自己的設(shè)備和driver。
Neutron的機制是通過plugin/driver/agent(server用于和其他組件服務(wù)的api進行交互)等方式實現(xiàn)和不同網(wǎng)絡(luò)設(shè)備的集成,plugin里L2-L3稱之為core plugin,L4-L7成為service plugin。
driver是plugin下具體集成不同插件的方式,而agent則是部署在另一側(cè)的相應(yīng)Driver代理,來管控計算節(jié)點上的虛擬機。
Neutron中的各種plugin紛繁復(fù)雜,諸如Dragonflow、OVN等此類不斷涌現(xiàn)。Neutron的未來是想將service plugin統(tǒng)一起來,只剩下Neutron的北向API及Neutron server。
二.Neutron和SDN Controller的集成
在整個SDN(這里僅指Controller)和OpenStack集成的大框架中,個人傾向于通過分層來理解。即Neutron和SDN Controller集成,理解為“應(yīng)用層(的北向)”;SDN Controller和軟硬件網(wǎng)絡(luò)設(shè)備集成,理解為“管理層(南向)”。這里,我們討論的是應(yīng)用層(北向)。
在Neutron中,采用SDN 控制器(采用了OpenFlow協(xié)議),可以控制流量轉(zhuǎn)發(fā)以實現(xiàn)不同虛擬路由器(DVR)的流量負載,通過匹配流表項(Match Flow Table)的方式來實現(xiàn)數(shù)據(jù)包按照自定義的OpenFlow規(guī)則實現(xiàn)Qos功能,不同的應(yīng)用業(yè)務(wù),使用不同的流轉(zhuǎn)發(fā)方式,Normal或Flow。
目前,已知的Neutron和SDN控制器集成現(xiàn)狀(網(wǎng)絡(luò)虛擬化NFV方面不在此表),如下所示:
這里,我以Networking-ofagent(ryu)和neutron集成為例做講解,其他控制器與之類似。
首先,我們需要知道SDN controller是以mechanism_drivers的方式與Neutron ML2 Plugin做集成,這些代碼,均統(tǒng)一存放于neutron/plugins/ml2/drivers目錄下,其實現(xiàn)集成的核心是driver.py模塊。
參見Neutron代碼的入口配置文件neutron/setup.cfg(neutron.ml2.mechanism_drivers部分),格式為key=value,value為代碼目錄,其代碼如下:
neutron.ml2.mechanism_drivers =
logger = neutron.tests.unit.plugins.ml2.drivers.mechanism_logger:LoggerMechanismDriver
test = neutron.tests.unit.plugins.ml2.drivers.mechanism_test:TestMechanismDriver
linuxbridge = neutron.plugins.ml2.drivers.linuxbridge.mech_driver.mech_linuxbridge:LinuxbridgeMechanismDriver
openvswitch = neutron.plugins.ml2.drivers.openvswitch.mech_driver.mech_openvswitch:OpenvswitchMechanismDriver
hyperv = neutron.plugins.ml2.drivers.hyperv.mech_hyperv:HypervMechanismDriver
l2population = neutron.plugins.ml2.drivers.l2pop.mech_driver:L2populationMechanismDriver
ofagent = neutron.plugins.ml2.drivers.ofagent.driver:OfagentMechanismDriver
brocade = networking_brocade.vdx.ml2driver.mechanism_brocade:BrocadeMechanism
brocade_fi_ni = neutron.plugins.ml2.drivers.brocade.fi_ni.mechanism_brocade_fi_ni:BrocadeFiNiMechanism
fslSDN = neutron.plugins.ml2.drivers.freescale.mechanism_fslSDN:FslSDNMechanismDriver
sriovnicswitch = neutron.plugins.ml2.drivers.mech_sriov.mech_driver.mech_driver:SriovNicSwitchMechanismDriver
fake_agent = neutron.tests.unit.plugins.ml2.drivers.mech_fake_agent:FakeAgentMechanismDriver
ryu中的driver.py模塊代碼,代碼僅2行,如下所示
from networking_ofagent.plugins.ml2.drivers import mech_ofagent
OfagentMechanismDriver = mech_ofagent.OfagentMechanismDriver
代碼的含義是指,首先從networking_ofagent項目安裝包的源碼目錄中(若集成,需要自行安裝、配置),導(dǎo)入一個mech_ofagent的模塊,用于和Neutron集成,該模塊中,有一個OfagentMechanismDriver的基類,用于完成Neutron ML2中諸如port、subnet、network等資源的create、delete、add等操作,或者是使用ofagent L2代理連接到網(wǎng)絡(luò)。其代碼如下所示:
class OfagentMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
"""Attach to networks using ofagent L2 agent.
The OfagentMechanismDriver integrates the ml2 plugin with the
ofagent L2 agent. Port binding with this driver requires the
ofagent agent to be running on the port's host, and that agent
to have connectivity to at least one segment of the port's
network.
"""
def __init__(self):
sg_enabled = securitygroups_rpc.is_firewall_enabled()
vif_details = {portbindings.CAP_PORT_FILTER: sg_enabled,
portbindings.OVS_HYBRID_PLUG: sg_enabled}
super(OfagentMechanismDriver, self).__init__(
constants.AGENT_TYPE_OFA,
portbindings.VIF_TYPE_OVS,
vif_details)
def get_allowed_network_types(self, agent):
return (agent['configurations'].get('tunnel_types', []) +
[p_constants.TYPE_LOCAL, p_constants.TYPE_FLAT,
p_constants.TYPE_VLAN])
def get_mappings(self, agent):
return dict(agent['configurations'].get('interface_mappings', {}))
最后。這里,奉上一份目前已知的Neutron項目中各種關(guān)于SDN和NFV的Plugin列表(數(shù)據(jù)來源于文件:neutron/doc/source/stadium/sub_projects.rst)
小結(jié)
從最新的Neutron代碼中,已經(jīng)發(fā)現(xiàn)了諸如原來的opendaylight和其他一些SDN Plugin,已經(jīng)開始從項目中移除,統(tǒng)一命名為諸如networking-xxxx之類的獨立項目。
Neutron和SDN Controller集成應(yīng)用的顯著意義和作用,個人仍不是太深刻體會。用Controller來控制虛擬機VM的流量和提供全局的網(wǎng)路視圖嗎——實現(xiàn)網(wǎng)絡(luò)智能化。截止目前,筆者尚未接觸過這方面的環(huán)境或看見相關(guān)資料,歡迎交流!
是的,Neutron更像是一種架構(gòu),需要眾多的開發(fā)者和用戶去參與其中,同時,還需要注意去其糟粕,取其精華。