From afcaf3cd0b5249c08e35d2c4fe418bb5f85ac23a Mon Sep 17 00:00:00 2001 From: Zvi Cahana Date: Thu, 11 Nov 2021 17:42:02 +0200 Subject: [PATCH] kubevirt addon: inline KubeVirt CR definition --- deploy/addons/kubevirt/pod.yaml.tmpl | 36 +++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/deploy/addons/kubevirt/pod.yaml.tmpl b/deploy/addons/kubevirt/pod.yaml.tmpl index e3706830f1..e36be749af 100644 --- a/deploy/addons/kubevirt/pod.yaml.tmpl +++ b/deploy/addons/kubevirt/pod.yaml.tmpl @@ -10,7 +10,7 @@ data: uninstall.sh: | #!/bin/bash - kubectl delete -f /manifests/kubevirt-cr.yaml + kubectl delete kubevirt kubevirt -n kubevirt kubectl delete -f /manifests/kubevirt-operator.yaml @@ -18,18 +18,38 @@ data: #!/bin/bash export KUBEVIRT_VERSION=$(curl -s https://api.github.com/repos/kubevirt/kubevirt/releases | grep tag_name | grep -v -- - | sort -V | tail -1 | awk -F':' '{print $2}' | sed 's/,//' | xargs) - echo $KUBEVIRT_VERSION + echo "Installing KubeVirt version: $KUBEVIRT_VERSION" curl -Ls "https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/kubevirt-operator.yaml" -o /manifests/kubevirt-operator.yaml kubectl create -f /manifests/kubevirt-operator.yaml - curl -sL "https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/kubevirt-cr.yaml" -o /manifests/kubevirt-cr.yaml - kubectl create -f /manifests/kubevirt-cr.yaml + HARDWARE_EMULATION=$(egrep 'svm|vmx' /proc/cpuinfo) + if [ -z "$HARDWARE_EMULATION" ]; then + echo "Using software emulation" + + echo " + apiVersion: kubevirt.io/v1 + kind: KubeVirt + metadata: + name: kubevirt + namespace: kubevirt + spec: + configuration: + developerConfiguration: + useEmulation: true + " | kubectl apply -f - + + else + + echo " + apiVersion: kubevirt.io/v1 + kind: KubeVirt + metadata: + name: kubevirt + namespace: kubevirt + spec: {} + " | kubectl apply -f - - EMULATION=$(egrep 'svm|vmx' /proc/cpuinfo) - if [ -z "$EMULATION" ]; then - echo "use emulation" - kubectl patch kubevirt kubevirt -n kubevirt --type merge --patch '{"spec": {"configuration": {"developerConfiguration": {"useEmulation": true}}}}' fi sleep infinity