Networking Plugin
...
- Figure out if the virtual network already exists. Use the ovn-nbctl call to figure that out. If already exist skip next step.
- Create Logical switch with name as provided in input and other-config:subnet=<Subnet-IP> set to the subnet required for the virtual network and external-ids:gateway_ip=<Gateway-IP> set to the gateway IP for the virtual network.
sudo ovn-nbctl --may-exist ls-add ovn-ls-24 -- set logical_switch ovn-ls-24 other-config:subnet=172.16.24.0/24 external-ids:gateway_ip=172.16.24.
...
1/24
- For East-West connectivity connect the switch to the distributed router if not attach virtual network :
- Add switch port to the distributed router. Mac address needs to be generated. In the example below "k8smaster" is the name of the distributed router created for the cluster based on the name of the master node.
sudo ovn-nbctl --may-exist lrp-add k8smaster rtos-ovn-ls-24 00:00:00:A0:96:B9 172.16.24.1/24 - Connect distributed router port to the switch
sudo ovn-nbctl -- --may-exist lsp-add ovn-ls-24 stor-ovn-ls-24 -- set logical_switch_port stor-ovn-ls-24 type=router options:router-port=rtos-ovn-ls-24 addresses=\"00:00:00:A0:96:B9\"
- Add switch port to the distributed router. Mac address needs to be generated. In the example below "k8smaster" is the name of the distributed router created for the cluster based on the name of the master node.
- For North-South connectivity update the gateway router with route and SNAT rules for the new switch. The example below is based on the assumption that there is only one Gateway Router created for the cluster. The name of the Gateway Router in the example is GR_k8smaster.
- For external connectivity add route to the gateway router: (The "join" is allocated IP addresses in the range 100.64.1.0/24)
ovn-nbctl --may-exist lr-route-add GR_k8smaster 172.16.24.0/24 100.64.1.1
- For external connectivity add route to the gateway router: (The "join" is allocated IP addresses in the range 100.64.1.0/24)
- Add SNAT rules to the gateway router. "192.168.121.19" is the external_IP
ovn-nbctl --may-exist lr-nat-add GR_k8smaster snat 192.168.121.19 172.16.24.0/24
- Return success if initialization is successful
...
One of the requirements for VNF's is to support multiple virtual network interfaces and multiple IP addresses. Multus acts as a Multi plugin in Kubernetes and provides the multiple network interface support in a pod. https://github.com/intel/multus-cni. It'll be used in this project to provide a default management port based on Flannel to all VNF's. The other interfaces will all be based on ovn-kubernetes as discussed in the next section.
...
Create following network resource for OVN.
OVN network resources in Kubernetes:
apiVersion: "kubernetes.cni.cncf.io/v1"
kind: Network
metadata:
name: ovn-network
spec:
config: '{
"name": "ovn-kubernetes",
"type": "ovn-k8s-cni-overlay"
}'
...