Enable OVS
Setting up OVS network with Pf9 DHCP Server on a PMK cluster
Create a PMK Cluster with the configured worker nodes in the previous section.
PMK cluster should have the following add-ons enabled:
- KubeVirt Add-on
- Advanced Networking Operator (Luigi) Add-on
1. Create Network Plugins Custom Resource
Network Plugin customer resource used to install advanced networking plugins such as ovs, sriov, dpdk, etc. and their configuration.
$cat <<EOF | kubectl apply -f -
apiVersion plumber.k8s.pf9.io/v1
kind NetworkPlugins
metadata
name networkplugins-ovs
namespace luigi-system
spec
plugins
hostPlumber #Enabled
multus #Enabled
ovs #Enabled
dhcpController #Enabled
EOF
DHCP controller plugin
DHCP controller plugin enables running PF9 DHCP server inside pod/virtual machine to cater to the DHCP requests from virtual machine instance(not pod in case of Kubevirt). Multus network-attachment-definitions will use DHCP server to assign IPs. Pf9 DHCP server serves as an alternate to the IPAM CNIs (whereabouts, host-local), which are used as delegate from backend CNI, which gets managed/triggered at pod creation and pod deletion.
Refer for more information: https://platform9.com/docs/kubernetes/enable-p9-dhcp
2. Create Host Network Template
Host Network Template is used to define configuration such as ovs-config etc. on the PMK cluster.
$cat <<EOF | kubectl apply -f -
apiVersion plumber.k8s.pf9.io/v1
kind HostNetworkTemplate
metadata
name host-network-template-ovs
namespace luigi-system
spec
ovsConfig
bridgeName"br01"
nodeInterface"bond0.2"
EOF
ovsCofig parameters:
- bridgeName : User Defined name of the OVS bridge
- nodeInterface : Physical Network interface to be used to create ovs-bridge with.
3. Create Network Attachment Definition
Network Attachment Definition is a Multus CRD used to configure additional NIC on pods and virtual machines.
$cat <<EOF | kubectl apply -f -
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
name: nad-ovs-dhcp
annotations:
k8s.v1.cni.cncf.io/resourceName: ovs-cni.network.kubevirt.io/br01
spec:
config: '{
"cniVersion": "0.3.1",
"type": "userspace",
"name": "nad-ovs-dhcp",
"bridge": "br01"
}'
EOF
4. Create Pf9 DHCP server
$cat <<EOF | kubectl apply -f -
apiVersion: dhcp.plumber.k8s.pf9.io/v1alpha1
kind: DHCPServer
metadata:
name: dhcpserver-pf9-ovs
spec:
networks:
- networkName: nad-ovs-dhcp
interfaceIp: 192.168.15.14/24
leaseDuration: 10m
cidr:
range: 192.168.15.0/24
range_start: 192.168.15.30
range_end: 192.168.15.100
gateway: 192.168.15.1
EOF
About the fields:
- Name: Name of the DHCPServer. Configurations of dnsmasq will be generated in a Configmap with the same name
- networks: list of all networks that this pod will serve:
- networkName: Name of NetworkAttachmentDefinition to provide IPs for. NAD should not have dhcp plugin enabled.
- interfaceIp: IP address that the pod will be allocated. Must have prefix to ensure proper routes are added.
- leaseDuration: Duration the leases offered should be valid for. Provide in valid formats for dnsmasq (eg: 10m, 5h, etc). Defaults to 1h
- vlanId: Dnsmasq network identifier. Used as an identifier while restoring IPs. Optional.
- cidr: range_start, range_end, gateway are optional. range is compulsory. If range start and end are provided, they will be used in place of the default start and end.
At this point the PMK cluster is ready to be used for workloads such as Pods and Virtual Machines.
Create a sample Virtual Machines to use the nad-ovs-dhcp
network.
Let’s validate your work by creating a Virtual Machine to consume the nad-ovs-dhcp network.
$cat <<EOF | kubectl apply -f -
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: vm-test-ovs
namespace: default
spec:
running: true
template:
metadata:
labels:
debugLogs: "true"
kubevirt.io/size: small
annotations:
kubevirt.io/memfd: "false"
spec:
terminationGracePeriodSeconds: 30
domain:
resources:
requests:
memory: 2Gi
cpu: 1
memory:
hugepages:
pageSize: "1Gi"
devices:
disks:
- name: containerdisk
disk:
bus: virtio
- name: cloudinitdisk
disk:
bus: virtio
interfaces:
- name: default
masquerade: {}
- name: vhost-user-net-1
vhostuser: {}
networks:
- name: default
pod: {}
- name: vhost-user-net-1
multus:
networkName: nad-ovs-dhcp
volumes:
- name: containerdisk
containerDisk:
image: quay.io/kubevirt/fedora-cloud-container-disk-demo
- name: cloudinitdisk
cloudInitNoCloud:
userData: |-
#cloud-config
password: fedora
chpasswd: { expire: False }
EOF
Variations of OVS networks
OVS Bonded network
$cat <<EOF | kubectl apply -f -
apiVersion plumber.k8s.pf9.io/v1
kind HostNetworkTemplate
metadata
name host-network-template-ovs-bonded
namespace luigi-system
spec
ovsConfig
bridgeName"br01"
nodeInterface"bond0.2,bond0.5"
#optional paramters
params
mtuRequest9192
lacp"active" # create ovs bond with lacp enabled
EOF