github.com/Mirantis/virtlet@v1.5.2-0.20191204181327-1659b8a48e9b/images/image_skel/prepare-node.sh (about) 1 #!/bin/bash 2 set -o errexit 3 set -o nounset 4 set -o pipefail 5 set -o errtrace 6 7 # make debugging this script easier 8 if [[ -f /dind/prepare-node.sh && ! ( ${0} =~ /dind/ ) ]]; then 9 exec /dind/prepare-node.sh "$@" 10 fi 11 12 verbose= 13 if [[ ${VIRTLET_LOGLEVEL:-} ]]; then 14 verbose="--v ${VIRTLET_LOGLEVEL}" 15 fi 16 /usr/local/bin/virtlet --dump-config ${verbose} >/var/lib/virtlet/config.sh 17 . /var/lib/virtlet/config.sh 18 19 PLUGIN_DIR=/kubelet-volume-plugins/virtlet~flexvolume_driver 20 21 if [[ ! -d ${PLUGIN_DIR} ]]; then 22 mkdir "${PLUGIN_DIR}" 23 if [[ -f /dind/flexvolume_driver ]]; then 24 cp /dind/flexvolume_driver "${PLUGIN_DIR}/flexvolume_driver" 25 else 26 cp /flexvolume_driver "${PLUGIN_DIR}/flexvolume_driver" 27 fi 28 # XXX: rm redir 29 nsenter -t 1 -m -u -i -n /bin/sh -c "systemctl restart kubelet" >& /hostlog/xxx || true 30 fi 31 32 # Ensure that the dirs required by virtlet exist on the node 33 mkdir -p /host-var-lib/virtlet/images /hostlog/virtlet/vms /host-var-lib/virtlet/volumes 34 35 # set up KVM 36 if [[ ! ${VIRTLET_DISABLE_KVM:-} ]]; then 37 if ! kvm-ok &>/dev/null; then 38 # try to fix the environment by loading appropriate modules 39 modprobe kvm || (echo "Missing kvm module on the host" >&2 && exit 1) 40 if grep vmx /proc/cpuinfo &>/dev/null; then 41 modprobe kvm_intel || (echo "Missing kvm_intel module on the host" >&2 && exit 1) 42 elif grep svm /proc/cpuinfo &>/dev/null; then 43 modprobe kvm_amd || (echo "Missing kvm_amd module on the host" >&2 && exit 1) 44 fi 45 fi 46 if [[ ! -e /dev/kvm ]] && ! mknod /dev/kvm c 10 $(grep '\<kvm\>' /proc/misc | cut -d" " -f1); then 47 echo "Can't create /dev/kvm" >&2 48 fi 49 if ! kvm-ok; then 50 echo "*** VIRTLET_DISABLE_KVM is not set but KVM extensions are not available ***" >&2 51 echo "*** Virtlet startup failed ***" >&2 52 exit 1 53 fi 54 chown libvirt-qemu.kvm /dev/kvm 55 fi