Openshift的网络之二:SDN master代码分析

一、前言

Openshift基于OVS SDN的CNI网络方案具有一个以etcd key-value store为中心master节点和若干worker节点,Openshift SDN master在etcd维护一个worker节点和SDN网络相关的数据库。

master主要的责任如下:

  1. 当Openshift加入或者删除一个worker节点,master会监听到这个事件,为这个节点分配或者收回子网段,将子网信息存储到etcd该node对应的entry下面。
  2. ovs-multitenant模式下,master还会监听project的建立和删除事件,为project分配VxLAN VNID,并且存储到etcd里面。

载自https://blog.csdn.net/cloudvtech

二、代码分析(Openshift origin v1.5)

1. Openshift master启动SDN master

  1. Start() @ origin/pkg/cmd/server/start/start_master.go
  2. startControllers() @ origin/pkg/cmd/server/start/start_master.go
  3. oc.RunSDNController() @ origin/pkg/cmd/server/start/start_master.go
  4. RunSDNController @ origin/pkg/cmd/server/origin/run_components.go
  5. StartMaster @ /Users/hairchen/Desktop/origin/pkg/sdn/plugin/master.go 

2.SDN master启动流程

2.1 parse network info to get clusterNetwork and serviceNetwork

2.2 create clusterNetwork

cn, err := master.osClient.ClusterNetwork().Create(cn)

2.3 start subnet manager
    2.3.1 get host subnet from Openshift
    2.3.2 initialize a SubnetAllocator
    2.3.3 start node change handling loop 
        2.3.3.1 
        2.3.3.2 handling node add event from K8S
            2.3.3.2.1 Validate node IP before proceeding
            2.3.3.2.2 Check if subnet needs to be created or updated
            2.3.3.2.3 Create new subnet in K8S
Openshift的网络之二:SDN master代码分析_第1张图片
        2.3.3.3 handling node delete event from K8S
    2.3.4 start subnet change handling loop

        2.3.4.1
 
        2.3.4.2 handling host subnet add event from K8S
            2.3.4.2.1 delete old subnet first
            2.3.4.2.2 go through add node action as (3.3.2.1~3.3.2.3)
        2.3.4.2 handling host subnet delete event from K8S 
载自https://blog.csdn.net/cloudvtech







你可能感兴趣的:(容器网络,kubernetes,CNI,Openshift,OVS,SDN)