From 39f3e063d33467df81b7724fce77884f74d4d034 Mon Sep 17 00:00:00 2001 From: Saikrishna Date: Tue, 1 Jan 2019 08:56:44 -0800 Subject: [PATCH] Example systemd scripts to setup SR-IOV on nodes Signed-off-by Saikrishna Edupuganti --- clr-k8s-examples/9-multi-network/README.md | 8 ++++++-- clr-k8s-examples/9-multi-network/sriov-conf.yaml | 2 +- .../9-multi-network/systemd/sriov.service | 9 +++++++++ clr-k8s-examples/9-multi-network/systemd/sriov.sh | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 clr-k8s-examples/9-multi-network/systemd/sriov.service create mode 100755 clr-k8s-examples/9-multi-network/systemd/sriov.sh diff --git a/clr-k8s-examples/9-multi-network/README.md b/clr-k8s-examples/9-multi-network/README.md index 8477cb5..6402ac3 100644 --- a/clr-k8s-examples/9-multi-network/README.md +++ b/clr-k8s-examples/9-multi-network/README.md @@ -9,8 +9,12 @@ directories on the host with the necessary binaries and configuration files. Replace `flannel` configuration in the delegates section with contents of your default network's cni configuration in [multus-conf.yaml](clr-k8s-examples/9-multi-network/multus-conf.yaml). -The device plugin, will discover any SR-IOV enabled devices on the host as per the -configuration in [sriov-conf.yaml](clr-k8s-examples/9-multi-network/sriov-conf.yaml). + +The device plugin will register the SR-IOV enabled devices on the host, specified +as `rootDevices` in [sriov-conf.yaml](clr-k8s-examples/9-multi-network/sriov-conf.yaml). + +> Helper [systemd](clr-k8s-examples/9-multi-network/systemd/sriov.service) example config +is provided, which enables SR-IOV for the above `rootDevices` > NOTE: This assumes homogenous nodes in the cluster diff --git a/clr-k8s-examples/9-multi-network/sriov-conf.yaml b/clr-k8s-examples/9-multi-network/sriov-conf.yaml index b5e48b5..68b853d 100644 --- a/clr-k8s-examples/9-multi-network/sriov-conf.yaml +++ b/clr-k8s-examples/9-multi-network/sriov-conf.yaml @@ -11,7 +11,7 @@ data: [ { "resourceName": "sriov", - "rootDevices": ["0000:07:00.0"], + "rootDevices": ["07:00.0", "07:00.1"], "sriovMode": true, "deviceType": "netdevice" } diff --git a/clr-k8s-examples/9-multi-network/systemd/sriov.service b/clr-k8s-examples/9-multi-network/systemd/sriov.service new file mode 100644 index 0000000..97ad684 --- /dev/null +++ b/clr-k8s-examples/9-multi-network/systemd/sriov.service @@ -0,0 +1,9 @@ +[Unit] +Description=Create VFs on ens785f0 ens785f1 interfaces + +[Service] +Type=oneshot +ExecStart=/usr/bin/sriov.sh ens785f0 ens785f1 + +[Install] +WantedBy=default.target diff --git a/clr-k8s-examples/9-multi-network/systemd/sriov.sh b/clr-k8s-examples/9-multi-network/systemd/sriov.sh new file mode 100755 index 0000000..708747d --- /dev/null +++ b/clr-k8s-examples/9-multi-network/systemd/sriov.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Usage: sriov.sh ens785f0 ens785f1 ... + +for pf in "$@"; do + echo "Resetting $pf" + echo 0 | tee /sys/class/net/$pf/device/sriov_numvfs + + NUM_VFS=$(cat /sys/class/net/$pf/device/sriov_totalvfs) + echo "Enabling $NUM_VFS for $pf" + echo $NUM_VFS | tee /sys/class/net/$pf/device/sriov_numvfs + ip link set $pf up + #for ((i = 0 ; i < ${NUM_VFS} ; i++ )); do ip link set $pf vf $i spoofchk off; done + for ((i = 0; i < ${NUM_VFS}; i++)); do ip link set dev $pf vf $i state enable; done +done