From c9f425f269fd2b102f327cba8128657a08994165 Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Mon, 25 Mar 2019 17:32:08 -0500 Subject: [PATCH] Gate/Dev: enable compute kit to be deployed from outwidth the cluster This PS updates the deplyment script for the compute-kit to allow use from outside the k8s cluster. Change-Id: Ie758b3c3c6b36c1882030c9a1be1b2ba6cc13ed4 Signed-off-by: Pete Birley --- tools/deployment/multinode/140-compute-kit.sh | 69 +++++++++++++++++-- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/tools/deployment/multinode/140-compute-kit.sh b/tools/deployment/multinode/140-compute-kit.sh index 43059f925e..065de2b00d 100755 --- a/tools/deployment/multinode/140-compute-kit.sh +++ b/tools/deployment/multinode/140-compute-kit.sh @@ -31,7 +31,39 @@ pod: scheduler: 1 novncproxy: 1 EOF -if [ "x$(systemd-detect-virt)" == "xnone" ]; then + +function kvm_check () { + POD_NAME="tmp-$(cat /dev/urandom | env LC_CTYPE=C tr -dc a-z | head -c 5; echo)" + cat <&2; +apiVersion: v1 +kind: Pod +metadata: + name: ${POD_NAME} +spec: + hostPID: true + restartPolicy: Never + containers: + - name: util + securityContext: + privileged: true + image: docker.io/busybox:latest + command: + - sh + - -c + - | + nsenter -t1 -m -u -n -i -- sh -c "kvm-ok >/dev/null && echo yes || echo no" +EOF + end=$(($(date +%s) + 900)) + until kubectl get pod/${POD_NAME} -o go-template='{{.status.phase}}' | grep -q Succeeded; do + now=$(date +%s) + [ $now -gt $end ] && echo containers failed to start. && \ + kubectl get pod/${POD_NAME} -o wide && exit 1 + done + kubectl logs pod/${POD_NAME} + kubectl delete pod/${POD_NAME} 1>&2; +} + +if [ "x$(kvm_check)" == "xyes" ]; then echo 'OSH is not being deployed in virtualized environment' helm upgrade --install nova ./nova \ --namespace=openstack \ @@ -49,10 +81,39 @@ else ${OSH_EXTRA_HELM_ARGS_NOVA} fi -#NOTE: Deploy neutron -#NOTE(portdirect): for simplicity we will assume the default route device +#NOTE: Deploy neutron, for simplicity we will assume the default route device # should be used for tunnels -NETWORK_TUNNEL_DEV="$(sudo ip -4 route list 0/0 | awk '{ print $5; exit }')" +function network_tunnel_dev () { + POD_NAME="tmp-$(cat /dev/urandom | env LC_CTYPE=C tr -dc a-z | head -c 5; echo)" + cat <&2; +apiVersion: v1 +kind: Pod +metadata: + name: ${POD_NAME} +spec: + hostNetwork: true + restartPolicy: Never + containers: + - name: util + image: docker.io/busybox:latest + command: + - 'ip' + - '-4' + - 'route' + - 'list' + - '0/0' +EOF + end=$(($(date +%s) + 900)) + until kubectl get pod/${POD_NAME} -o go-template='{{.status.phase}}' | grep -q Succeeded; do + now=$(date +%s) + [ $now -gt $end ] && echo containers failed to start. && \ + kubectl get pod/${POD_NAME} -o wide && exit 1 + done + kubectl logs pod/${POD_NAME} | awk '{ print $5; exit }' + kubectl delete pod/${POD_NAME} 1>&2; +} + +NETWORK_TUNNEL_DEV="$(network_tunnel_dev)" tee /tmp/neutron.yaml << EOF network: interface: