|
| 1 | +#!/bin/bash -e |
| 2 | + |
| 3 | +PV='pv -qL' |
| 4 | + |
| 5 | +# check if FPGA devices exist |
| 6 | +if [ -d /sys/class/fpga ] ; then |
| 7 | + DRIVER=OPAE |
| 8 | + DEVICE_PREFIX=/dev/intel-fpga-port |
| 9 | +elif [ -d /sys/class/fpga_region ] ; then |
| 10 | + DRIVER=DFL |
| 11 | + DEVICE_PREFIX=/dev/dfl-port |
| 12 | +else |
| 13 | + >&2 echo 'ERROR: FPGA devices not found or kernel drivers not loaded' |
| 14 | + exit 1 |
| 15 | +fi |
| 16 | + |
| 17 | +command() |
| 18 | +{ |
| 19 | + speed=$2 |
| 20 | + [ -z "$speed" ] && speed=10 |
| 21 | + |
| 22 | + echo "> $1" | $PV $speed |
| 23 | + sh -c "$1" |
| 24 | + echo | $PV $speed |
| 25 | +} |
| 26 | + |
| 27 | +out() |
| 28 | +{ |
| 29 | + speed=$2 |
| 30 | + [ -z "$speed" ] && speed=10 |
| 31 | + |
| 32 | + echo "$1" | $PV $speed |
| 33 | + echo | $PV $speed |
| 34 | +} |
| 35 | + |
| 36 | +cleanup() |
| 37 | +{ |
| 38 | + clear |
| 39 | + out 'Cleanup demo artifacts' 200 |
| 40 | + command 'kubectl delete pod test-fpga-preprogrammed || true' 200 |
| 41 | + command 'kubectl delete -f plugins/deployments/fpga_admissionwebhook/mappings-collection.yaml || true' 200 |
| 42 | + command 'kubectl delete -k plugins/deployments/fpga_admissionwebhook/default || true' 200 |
| 43 | + command './plugins/scripts/deploy-fpgaplugin.sh cleanup' 200 |
| 44 | + command 'kubectl annotate node --all fpga.intel.com/device-plugin-mode-' 200 |
| 45 | + command 'rm -rf plugins' 200 |
| 46 | +} |
| 47 | + |
| 48 | +record() |
| 49 | +{ |
| 50 | + clear |
| 51 | + out 'Record this screencast' |
| 52 | + command "asciinema rec -t 'Intel FPGA Device Plugin for Kubernetes in preprogrammed mode with $DRIVER kernel driver.' Intel-FPGA-Device-Plugin-for-Kubernetes-preprogrammed-$DRIVER-Demo.cast -c 'sh ./screencast-fpga-preprogrammed.sh play'" 300 |
| 53 | +} |
| 54 | + |
| 55 | +screen1() |
| 56 | +{ |
| 57 | + clear |
| 58 | + out "This screencast demonstrates deployment of the Intel FPGA Plugin for Kubernetes in preprogrammed mode with $DRIVER kernel driver" |
| 59 | + out "Let's get started!" |
| 60 | + out '1. Check if Kubernetes node is in good shape:' |
| 61 | + command 'kubectl get nodes' |
| 62 | + command 'kubectl get pods -n kube-system' |
| 63 | + sleep 2 |
| 64 | + out 'Check if cert-manager is running:' |
| 65 | + command 'kubectl get pods -n cert-manager' |
| 66 | + sleep 2 |
| 67 | + out 'Check if docker is running k8s pods:' |
| 68 | + command 'docker ps --format "table {{.Names}}"' |
| 69 | + sleep 2 |
| 70 | +} |
| 71 | + |
| 72 | +screen2() |
| 73 | +{ |
| 74 | + clear |
| 75 | + rm -rf plugins |
| 76 | + out '2. Clone Intel Device Plugins for Kubernetes repository' |
| 77 | + command "git clone https://github.com/intel/intel-device-plugins-for-kubernetes plugins" 15 |
| 78 | +} |
| 79 | + |
| 80 | +screen3() |
| 81 | +{ |
| 82 | + clear |
| 83 | + out '3. Deploy admission controller webhook' |
| 84 | + command 'kubectl apply -k plugins/deployments/fpga_admissionwebhook/default' |
| 85 | + sleep 3 |
| 86 | + out 'Deploy example mappings:' |
| 87 | + command 'kubectl apply -f plugins/deployments/fpga_admissionwebhook/mappings-collection.yaml' |
| 88 | + sleep 3 |
| 89 | + out 'Check if webhook pod is running:' |
| 90 | + command 'kubectl get pods -n intelfpgawebhook-system' |
| 91 | + sleep 2 |
| 92 | + out 'Check its logs:' |
| 93 | + command "kubectl logs $(kubectl get pods -n intelfpgawebhook-system| grep intelfpgawebhook-controller-manager | awk '{print $1}') -n intelfpgawebhook-system" |
| 94 | + sleep 2 |
| 95 | +} |
| 96 | + |
| 97 | +screen4() |
| 98 | +{ |
| 99 | + clear |
| 100 | + out '5. Deploy FPGA plugin' |
| 101 | + command './plugins/scripts/deploy-fpgaplugin.sh' |
| 102 | + sleep 4 |
| 103 | + out 'Check if its pod is runnning:' |
| 104 | + command 'kubectl get pod | grep intel-fpga-plugin' |
| 105 | + sleep 2 |
| 106 | + out 'Check if resource fpga.intel.com/af-<af id> is allocatable:' |
| 107 | + command 'kubectl describe node |grep -A4 Allocatable' |
| 108 | + sleep 2 |
| 109 | +} |
| 110 | + |
| 111 | +screen5() |
| 112 | +{ |
| 113 | + clear |
| 114 | + out '6. Run OPAE workload that uses NLB3 bitstream' |
| 115 | + out 'Check if devices are programmed with NLB3:' |
| 116 | + command 'cat /sys/class/*/*/*/afu_id' |
| 117 | + out 'Run workload:' |
| 118 | + command 'cat plugins/demo/test-fpga-preprogrammed.yaml' |
| 119 | + command 'kubectl create -f plugins/demo/test-fpga-preprogrammed.yaml' |
| 120 | + sleep 5 |
| 121 | + out 'Look at the test output' |
| 122 | + command 'kubectl logs test-fpga-preprogrammed' |
| 123 | +} |
| 124 | + |
| 125 | +screen6() |
| 126 | +{ |
| 127 | + clear |
| 128 | + out 'Summary:' 15 |
| 129 | + out "This screencast demonstrated 'Preprogrammed' use case for FPGA:" 15 |
| 130 | + out ' - FPGA device was already programmed with NLB3 bitstream' 15 |
| 131 | + out ' - desired bitstream resource was specified in the pod spec as fpga.intel.com/arria10.dcp1.2-nlb3-preprogrammed' 15 |
| 132 | + out ' - the machinery mapped fpga.intel.com/arria10.dcp1.2-nlb3-preprogrammed into the pair of region id/AFU id using admission controller webhook' 15 |
| 133 | + out |
| 134 | + out 'More detailed information about Intel Device Plugins can be found at https://github.com/intel/intel-device-plugins-for-kubernetes' 15 |
| 135 | +} |
| 136 | + |
| 137 | +if [ "$1" == 'play' ] ; then |
| 138 | + if [ -n "$2" ] ; then |
| 139 | + screen$2 |
| 140 | + else |
| 141 | + for n in $(seq 6) ; do screen$n ; sleep 3; done |
| 142 | + fi |
| 143 | +elif [ "$1" == 'cleanup' ] ; then |
| 144 | + cleanup |
| 145 | +elif [ "$1" == 'record' ] ; then |
| 146 | + record |
| 147 | +else |
| 148 | + echo 'Usage: screencast-fpga-preprogrammed.sh [--help|help|-h] | [play [<screen number>]] | [cleanup] | [record]' |
| 149 | +fi |
0 commit comments