|
| 1 | +#!/bin/bash -e |
| 2 | + |
| 3 | +PV='pv -qL' |
| 4 | + |
| 5 | +command() |
| 6 | +{ |
| 7 | + speed=$2 |
| 8 | + [ -z "$speed" ] && speed=10 |
| 9 | + |
| 10 | + echo "> $1" | $PV $speed |
| 11 | + sh -c "$1" |
| 12 | + echo | $PV $speed |
| 13 | +} |
| 14 | + |
| 15 | +out() |
| 16 | +{ |
| 17 | + speed=$2 |
| 18 | + [ -z "$speed" ] && speed=10 |
| 19 | + |
| 20 | + echo "$1" | $PV $speed |
| 21 | + echo | $PV $speed |
| 22 | +} |
| 23 | + |
| 24 | +cleanup() |
| 25 | +{ |
| 26 | + clear |
| 27 | + out 'Cleanup demo artifacts' 20 |
| 28 | + out 'delete node-feature-discovery deployment:' 20 |
| 29 | + command 'kubectl delete -k https://github.com/intel/intel-device-plugins-for-kubernetes/deployments/sgx_nfd?ref=master || true' 20 |
| 30 | + out 'delete SGX Device Plugin deployment:' 20 |
| 31 | + command 'kubectl delete sgxdeviceplugin sgxdeviceplugin-sample -n sgx-ecdsa-quote || true' 20 |
| 32 | + out 'delete Intel Device Plugin Operator deployment:' 20 |
| 33 | + command 'kubectl delete -k https://github.com/intel/intel-device-plugins-for-kubernetes/deployments/operator/default?ref=master || true' 20 |
| 34 | + out "delete the demo namespace" |
| 35 | + command "kubectl delete ns sgx-ecdsa-quote" |
| 36 | +} |
| 37 | + |
| 38 | +record() |
| 39 | +{ |
| 40 | + clear |
| 41 | + out 'Record this screencast' |
| 42 | + command 'asciinema rec -t "Intel SGX Device Plugin for Kubernetes - Intel(R) SGX DCAP ECDSA Quote Generation Demo" Intel-SGX-Device-Plugin-for-Kubernetes-SGX-DCAP-ECDSA-Quote-Generation-Demo.cast -c "./screencast-sgx.sh play"' |
| 43 | +} |
| 44 | + |
| 45 | +screen1() |
| 46 | +{ |
| 47 | + clear |
| 48 | + out "This video demonstrates the Intel(R) Software Guard Extensions ECDSA Quote Generation in Kubernetes*" |
| 49 | + out "The key building blocks are:" |
| 50 | + out "* Intel(R) Software Guard Extensions (SGX) Flexible Launch Control capable system (registered)" |
| 51 | + out "* Intel(R) SGX driver (RFC v41) for the host kernel" |
| 52 | + out "* Intel(R) SGX PCKID Certificate Caching Service configured" |
| 53 | + out "Let's get started!" |
| 54 | +} |
| 55 | + |
| 56 | +screen2() |
| 57 | +{ |
| 58 | + clear |
| 59 | + out "1. Check the Kubernetes cluster is in good shape" |
| 60 | + command "kubectl get nodes" |
| 61 | + command "kubectl get pods --all-namespaces" |
| 62 | + out "Create the demo namespace" |
| 63 | + command "kubectl create ns sgx-ecdsa-quote" |
| 64 | + out "Pull :devel images and tag them as :0.19.0 (temporary until the release is out)" |
| 65 | + command "sudo ctr -n k8s.io i pull docker.io/intel/intel-sgx-plugin:devel" |
| 66 | + command "sudo ctr -n k8s.io i pull docker.io/intel/intel-sgx-initcontainer:devel" |
| 67 | + command "sudo ctr -n k8s.io i tag docker.io/intel/intel-sgx-plugin:devel docker.io/intel/intel-sgx-plugin:0.19.0" |
| 68 | + command "sudo ctr -n k8s.io i tag docker.io/intel/intel-sgx-initcontainer:devel docker.io/intel/intel-sgx-initcontainer:0.19.0" |
| 69 | +} |
| 70 | + |
| 71 | +screen3() |
| 72 | +{ |
| 73 | + clear |
| 74 | + out "2. Deploy node-feature-discovery for Kubernetes" |
| 75 | + out "It's used to label SGX capable nodes and register SGX EPC as an extended resource" |
| 76 | + command "kubectl apply -k https://github.com/intel/intel-device-plugins-for-kubernetes/deployments/sgx_nfd?ref=master" |
| 77 | + out "Check its pod is running" |
| 78 | + command "kubectl wait --for=condition=Ready pod/$(kubectl get --no-headers -l app=nfd-worker -o=jsonpath='{.items[0].metadata.name}' pods -n node-feature-discovery) -n node-feature-discovery" |
| 79 | +} |
| 80 | + |
| 81 | +screen4() |
| 82 | +{ |
| 83 | + clear |
| 84 | + out "3. Deploy Intel Device Plugin Operator" |
| 85 | + command "kubectl apply -k https://github.com/intel/intel-device-plugins-for-kubernetes/deployments/operator/default?ref=master" |
| 86 | + out "Create SgxDevicePlugin custom resource managed by the Operator" |
| 87 | + command "kubectl apply -f https://raw.githubusercontent.com/intel/intel-device-plugins-for-kubernetes/master/deployments/operator/samples/deviceplugin_v1_sgxdeviceplugin.yaml -n sgx-ecdsa-quote" |
| 88 | + out "Check the SGX Device Plugin is running" |
| 89 | + command "kubectl get pods -n sgx-ecdsa-quote" |
| 90 | +} |
| 91 | + |
| 92 | +screen5() |
| 93 | +{ |
| 94 | + clear |
| 95 | + out "4. Verify node resources" |
| 96 | + command "kubectl get nodes -o json | jq .items[].status.allocatable | grep -i sgx" |
| 97 | + command "kubectl get nodes -o json | jq .items[].metadata.labels | grep SGX" |
| 98 | + out "Both node labels and resources for SGX are in place" |
| 99 | +} |
| 100 | + |
| 101 | +screen6() |
| 102 | +{ |
| 103 | + clear |
| 104 | + out "5. Run Intel(R) SGX DCAP ECDSA Quote Generation (out-of-proc)" |
| 105 | + out "Make the pre-built images available (from docker save)" |
| 106 | + command "sudo ctr -n k8s.io i import sgx-aesmd.tar" |
| 107 | + command "sudo ctr -n k8s.io i import sgx-demo.tar" |
| 108 | + out "Deploy Intel(R) AESMD" |
| 109 | + command "kubectl apply -k https://github.com/intel/intel-device-plugins-for-kubernetes/deployments/sgx_aesmd?ref=master -n sgx-ecdsa-quote" |
| 110 | + out "Deploy Intel(R) SGX DCAP ECDSA Quote Generation" |
| 111 | + command "kubectl apply -k https://github.com/intel/intel-device-plugins-for-kubernetes/deployments/sgx_enclave_apps/overlays/sgx_ecdsa_aesmd_quote?ref=master -n sgx-ecdsa-quote" |
| 112 | + command "kubectl logs $(kubectl get --no-headers -l job-name=ecdsa-quote-intelsgx-demo-job -o=jsonpath='{.items[0].metadata.name}' pods -n sgx-ecdsa-quote) -n sgx-ecdsa-quote" |
| 113 | + out "Intel(R) SGX DCAP QuoteGenerationSample successfully requested a quote from Intel(R) AESMD" |
| 114 | + out "Delete the deployment" |
| 115 | + command "kubectl delete -k https://github.com/intel/intel-device-plugins-for-kubernetes/deployments/sgx_aesmd?ref=master -n sgx-ecdsa-quote" |
| 116 | + command "kubectl delete -k https://github.com/intel/intel-device-plugins-for-kubernetes/deployments/sgx_enclave_apps/overlays/sgx_ecdsa_aesmd_quote?ref=master -n sgx-ecdsa-quote" |
| 117 | +} |
| 118 | + |
| 119 | +screen7() |
| 120 | +{ |
| 121 | + clear |
| 122 | + out "6. Run Intel(R) SGX DCAP ECDSA Quote Generation (in-proc)" |
| 123 | + out "Deploy Intel(R) SGX DCAP ECDSA Quote Generation" |
| 124 | + command "kubectl apply -k https://github.com/intel/intel-device-plugins-for-kubernetes/deployments/sgx_enclave_apps/overlays/sgx_ecdsa_inproc_quote?ref=master -n sgx-ecdsa-quote" |
| 125 | + command "kubectl logs $(kubectl get --no-headers -l job-name=inproc-ecdsa-quote-intelsgx-demo-job -o=jsonpath='{.items[0].metadata.name}' pods -n sgx-ecdsa-quote) -n sgx-ecdsa-quote" |
| 126 | + out "Intel(R) SGX DCAP QuoteGenerationSample successfully generated a quote using DCAP Quote Provider Library" |
| 127 | + out "Delete the deployment" |
| 128 | + command "kubectl delete -k https://github.com/intel/intel-device-plugins-for-kubernetes/deployments/sgx_enclave_apps/overlays/sgx_ecdsa_inproc_quote?ref=master -n sgx-ecdsa-quote" |
| 129 | +} |
| 130 | + |
| 131 | +screen8() |
| 132 | +{ |
| 133 | + clear |
| 134 | + out "This video demonstrated the Intel(R) Software Guard Extensions in Kubernetes*" |
| 135 | + out "The following topics were covered:" |
| 136 | + out "* SGX Kubernetes* Device Plugin deployment with an Operator" |
| 137 | + out "* Intel(R) SGX node resource and feature label registration to Kubernetes*" |
| 138 | + out "* Intel(R) SGX DCAP ECDSA Quote Generation (out-of-proc and in-proc)" |
| 139 | +} |
| 140 | + |
| 141 | +if [ "$1" == 'play' ] ; then |
| 142 | + if [ -n "$2" ] ; then |
| 143 | + screen$2 |
| 144 | + else |
| 145 | + for n in $(seq 8) ; do screen$n ; sleep 3; done |
| 146 | + fi |
| 147 | +elif [ "$1" == 'cleanup' ] ; then |
| 148 | + cleanup |
| 149 | +elif [ "$1" == 'record' ] ; then |
| 150 | + record |
| 151 | +else |
| 152 | + echo 'Usage: screencast-sgx.sh [--help|help|-h] | [play [<screen number>]] | [cleanup] | [record]' |
| 153 | +fi |
0 commit comments