diff --git a/bin/setup-infrastructure.sh b/bin/setup-infrastructure.sh new file mode 100755 index 000000000..de237b1d2 --- /dev/null +++ b/bin/setup-infrastructure.sh @@ -0,0 +1,177 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2124,SC2145,SC2294,SC2086,SC2087,SC2155 +set -e + +set -o pipefail + +if [ -z "${ACME_EMAIL}" ]; then + read -rp "Enter a valid email address for use with ACME, press enter to skip: " ACME_EMAIL + export ACME_EMAIL="${ACME_EMAIL:-}" +fi + +if [ -z "${GATEWAY_DOMAIN}" ]; then + echo "The domain name for the gateway is required, if you do not have a domain name press enter to use the default" + read -rp "Enter the domain name for the gateway [cluster.local]: " GATEWAY_DOMAIN + export GATEWAY_DOMAIN="${GATEWAY_DOMAIN:-cluster.local}" +fi + +if [ "${HYPERCONVERGED:-false}" = "true" ]; then + kubectl label node --all openstack-control-plane=enabled \ + openstack-compute-node=enabled \ + openstack-network-node=enabled \ + openstack-storage-node=enabled \ + node-role.kubernetes.io/worker=worker +else + LABEL_FAIL=0 + for label in openstack-control-plane=enabled \ + openstack-compute-node=enabled \ + openstack-network-node=enabled \ + openstack-storage-node=enabled \ + node-role.kubernetes.io/worker=worker; do + if [ -z "$(kubectl get nodes -l "${label}" -o name)" ]; then + echo "[FAILURE] No nodes with the label ${label} found, please label the nodes you want to use for the OpenStack deployment" + LABEL_FAIL=1 + fi + done + if [ "${LABEL_FAIL}" -eq 1 ]; then + exit 1 + fi +fi + +kubectl label node -l beta.kubernetes.io/os=linux kubernetes.io/os=linux +kubectl label node -l node-role.kubernetes.io/control-plane kube-ovn/role=master +kubectl label node -l ovn.kubernetes.io/ovs_dp_type!=userspace ovn.kubernetes.io/ovs_dp_type=kernel +kubectl label node -l node-role.kubernetes.io/control-plane longhorn.io/storage-node=enabled + +if ! kubectl taint nodes -l node-role.kubernetes.io/control-plane node-role.kubernetes.io/control-plane:NoSchedule-; then + echo "Taint already removed" +fi + +if [ -z "${CONTAINER_INTERFACE}" ]; then + export CONTAINER_INTERFACE=$(ip -details -json link show | \ + jq -r '[.[] | if .linkinfo.info_kind // .link_type == "loopback" or + (.ifname | test("idrac+")) then empty else .ifname end ] | .[0]') + echo "[WARNING] The interface for the OVN network is required." + echo " The script will use the default route interface ${CONTAINER_INTERFACE}" +fi + +if [ -z "${CONTAINER_VLAN_INTERFACE}" ]; then + echo "[WARNING] The vlan interface for the OVN network is required." + echo " The script will use the default route interface ${CONTAINER_INTERFACE}" + export CONTAINER_VLAN_INTERFACE="${CONTAINER_INTERFACE}" +fi + +if [ -z "${COMPUTE_INTERFACE}" ]; then + export COMPUTE_INTERFACE=$(ip -details -json link show | \ + jq -r '[.[] | if .linkinfo.info_kind // .link_type == "loopback" or + (.ifname | test("idrac+")) then empty else .ifname end ] | .[-1]') + echo "[WARNING] The interface for the compute network is required." + echo " The script will use the last interface found ${COMPUTE_INTERFACE}" +fi + +if [ "${COMPUTE_INTERFACE}" = "${CONTAINER_INTERFACE}" ]; then + echo "[ERROR] The compute interface cannot be the same as the container interface" + exit 1 +fi + +kubectl annotate \ + nodes \ + -l openstack-compute-node=enabled -l openstack-network-node=enabled \ + ovn.openstack.org/int_bridge='br-int' +kubectl annotate \ + nodes \ + -l openstack-compute-node=enabled -l openstack-network-node=enabled \ + ovn.openstack.org/bridges='br-ex' +kubectl annotate \ + nodes \ + -l openstack-compute-node=enabled -l openstack-network-node=enabled \ + ovn.openstack.org/ports="br-ex:${COMPUTE_INTERFACE}" +kubectl annotate \ + nodes \ + -l openstack-compute-node=enabled -l openstack-network-node=enabled \ + ovn.openstack.org/mappings='physnet1:br-ex' +kubectl annotate \ + nodes \ + -l openstack-compute-node=enabled -l openstack-network-node=enabled \ + ovn.openstack.org/availability_zones='az1' +kubectl annotate \ + nodes \ + -l openstack-network-node=enabled \ + ovn.openstack.org/gateway='enabled' + +# Deploy kube-ovn +if [ ! -f /etc/genestack/helm-configs/kube-ovn/kube-ovn-helm-overrides.yaml ]; then +cat > /etc/genestack/helm-configs/kube-ovn/kube-ovn-helm-overrides.yaml < /dev/null; then + echo "yq is not installed. Attempting to install yq" + installYq +fi USER_NAME="$(who am i | awk '{print $1}')" USER_PATH="$(getent passwd ${USER_NAME} | awk -F':' '{print $6}')" diff --git a/docs/build-test-envs.md b/docs/build-test-envs.md index 6a5e4701e..8df0e1f7b 100644 --- a/docs/build-test-envs.md +++ b/docs/build-test-envs.md @@ -15,6 +15,31 @@ The following script will deploy a hyperconverged lab environment on an OpenStac --8<-- "scripts/hyperconverged-lab.sh" ``` +The build script is interactive and will prompt you for the following information + +|
Variable
| Description |
Default
| +|----------|-------------|---------| +| `ACME_EMAIL` | Email address for Let's Encrypt. If an email address is defined and a real domain is used, the deployment will attempt to pull production certificates. | "" | +| `GATEWAY_DOMAIN` | Domain name used for routes within the gateway API. If a valid domain is used, it will be associated with the gateway routes. | "cluster.local" | +| `OS_CLOUD` | OpenStack cloud name. | "default" | +| `OS_FLAVOR` | OpenStack instance flavor, this will automatically select a flavor with < 24GiB of RAM. | "gp.X.8.16" | +| `OS_IMAGE` | OpenStack image name. | "Ubuntu 20.04" | +| `HYPERCONVERGED_DEV` | enable hyperconverged development mode. This will attempt to sync a local copy of Genestack to the development environment. | `false` | + +All of the variables can be defined on the command line using environment variables. + +!!! example "Deploying a Hyper-converged Lab Environment with Environment Variables" + + ``` shell + export ACME_EMAIL="user@domain.com" + export GATEWAY_DOMAIN="cluster.local" + export OS_CLOUD="default" + export OS_FLAVOR="gp.0.8.16" + export OS_IMAGE="Ubuntu 20.04" + export HYPERCONVERGED_DEV="false" + /opt/genestack/scripts/hyperconverged-lab.sh + ``` + ## Overview A simple reference architecture for a hyper-converged lab environment is shown below. This environment consists of three nodes diff --git a/scripts/hyperconverged-lab-uninstall.sh b/scripts/hyperconverged-lab-uninstall.sh new file mode 100755 index 000000000..108319db0 --- /dev/null +++ b/scripts/hyperconverged-lab-uninstall.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2124,SC2145,SC2294,SC2086,SC2087,SC2155 + +set -o pipefail +set -e +SECONDS=0 + +if [ -z "${OS_CLOUD}" ]; then + read -rp "Enter name of the cloud configuration used for this build [default]: " OS_CLOUD + export OS_CLOUD="${OS_CLOUD:-default}" +fi + +function serverDelete() { + if ! openstack server delete "${1}" 2> /dev/null; then + echo "Failed to delete server ${1}" + fi +} + +function portDelete() { + if ! openstack port delete "${1}" 2> /dev/null; then + echo "Failed to delete port ${1}" + fi +} + +function securityGroupDelete() { + if ! openstack security group delete "${1}" 2> /dev/null; then + echo "Failed to delete security group ${1}" + fi +} + +function networkDelete() { + if ! openstack network delete "${1}" 2> /dev/null; then + echo "Failed to delete network ${1}" + fi +} + +function subnetDelete() { + if ! openstack subnet delete "${1}" 2> /dev/null; then + echo "Failed to delete subnet ${1}" + fi +} + +for i in $(openstack floating ip list --router hyperconverged-router -f value -c "Floating IP Address"); do + if ! openstack floating ip unset "${i}" 2> /dev/null; then + echo "Failed to unset floating ip ${i}" + fi + if ! openstack floating ip delete "${i}" 2> /dev/null; then + echo "Failed to delete floating ip ${i}" + fi +done + +serverDelete hyperconverged-2 +serverDelete hyperconverged-1 +serverDelete hyperconverged-0 + +if ! openstack keypair delete hyperconverged-key 2> /dev/null; then + echo "Failed to delete keypair hyperconverged-key" +fi + +portDelete hyperconverged-2-compute-port +portDelete hyperconverged-1-compute-port +portDelete hyperconverged-0-compute-port +for i in {100..109}; do + portDelete "hyperconverged-0-compute-float-${i}-port" +done +portDelete hyperconverged-2-mgmt-port +portDelete hyperconverged-1-mgmt-port +portDelete hyperconverged-0-mgmt-port +portDelete metallb-vip-0-port + +securityGroupDelete hyperconverged-jump-secgroup +securityGroupDelete hyperconverged-http-secgroup +securityGroupDelete hyperconverged-secgroup + +if ! openstack router remove subnet hyperconverged-router hyperconverged-subnet 2> /dev/null; then + echo "Failed to remove hyperconverged-subnet from router hyperconverged-router" +fi +if ! openstack router remove subnet hyperconverged-router hyperconverged-compute-subnet 2> /dev/null; then + echo "Failed to remove hyperconverged-compute-subnet from router hyperconverged-router" +fi +if ! openstack router remove gateway hyperconverged-router PUBLICNET 2> /dev/null; then + echo "Failed to remove gateway from router hyperconverged-router" +fi +if ! openstack router delete hyperconverged-router 2> /dev/null; then + echo "Failed to delete router hyperconverged-router" +fi + +subnetDelete hyperconverged-compute-subnet +subnetDelete hyperconverged-subnet + +networkDelete hyperconverged-compute-net +networkDelete hyperconverged-net + +echo "Cleanup complete" +echo "The lab uninstall took ${SECONDS} seconds to complete." diff --git a/scripts/hyperconverged-lab.sh b/scripts/hyperconverged-lab.sh index aa4b4fd3c..01d48d006 100755 --- a/scripts/hyperconverged-lab.sh +++ b/scripts/hyperconverged-lab.sh @@ -1,9 +1,9 @@ -#!/bin/bash +#!/usr/bin/env bash # shellcheck disable=SC2124,SC2145,SC2294,SC2086,SC2087,SC2155 set -o pipefail set -e - +SECONDS=0 if [ -z "${ACME_EMAIL}" ]; then read -rp "Enter a valid email address for use with ACME, press enter to skip: " ACME_EMAIL export ACME_EMAIL="${ACME_EMAIL:-}" @@ -20,28 +20,44 @@ if [ -z "${OS_CLOUD}" ]; then export OS_CLOUD="${OS_CLOUD:-default}" fi -# SJC3 is special... -OS_REGION=$(openstack config show -f json | jq -r '.region_name') -if [ "${OS_REGION}" = "SJC3" ]; then - DEFAULT_OS_FLAVOR="gp.0.8.16" -else - DEFAULT_OS_FLAVOR="gp.5.8.16" -fi - if [ -z "${OS_FLAVOR}" ]; then + # List compatible flavors + FLAVORS=$(openstack flavor list --min-ram 16000 --min-disk 100 --sort-column Name -c Name -c RAM -c Disk -c VCPUs -f json) + DEFAULT_OS_FLAVOR=$(echo "${FLAVORS}" | jq -r '[.[] | select( all(.RAM; . < 24576) )] | .[0].Name') + echo "The following flavors are available for use with this build" + echo "${FLAVORS}" | jq -r '["Name", "RAM", "Disk", "VCPUs"], (.[] | [.Name, .RAM, .Disk, .VCPUs]) | @tsv' | column -t read -rp "Enter name of the flavor to use for the instances [${DEFAULT_OS_FLAVOR}]: " OS_FLAVOR export OS_FLAVOR=${OS_FLAVOR:-${DEFAULT_OS_FLAVOR}} fi -if ! openstack router show hyperconverged-router; then +# Set the default image and ssh username +export OS_IMAGE="${OS_IMAGE:-Ubuntu 24.04}" +if [ -z "${SSH_USERNAME}" ]; then + if ! IMAGE_DEFAULT_PROPERTY=$(openstack image show "${OS_IMAGE}" -f json -c properties); then + read -rp "Image not found. Enter the image name: " OS_IMAGE + IMAGE_DEFAULT_PROPERTY=$(openstack image show "${OS_IMAGE}" -f json -c properties) + fi + if [ "${IMAGE_DEFAULT_PROPERTY}" ]; then + if SSH_USERNAME=$(echo "${IMAGE_DEFAULT_PROPERTY}" | jq -r '.properties.default_user'); then + echo "Discovered the default username for the image ${OS_IMAGE} as ${SSH_USERNAME}" + fi + fi + if [ -z "${SSH_USERNAME}" ] || [ "${SSH_USERNAME}" = "null" ]; then + echo "The image ${OS_IMAGE} does not have a default user property, please enter the default username" + read -rp "Enter the default username for the image: " SSH_USERNAME + fi +fi + +if ! openstack router show hyperconverged-router 2> /dev/null; then openstack router create hyperconverged-router --external-gateway PUBLICNET fi -if ! openstack network show hyperconverged-net; then +if ! openstack network show hyperconverged-net 2> /dev/null; then openstack network create hyperconverged-net fi -if ! TENANT_SUB_NETWORK_ID=$(openstack subnet show hyperconverged-subnet -f json | jq -r '.id'); then +if ! TENANT_SUB_NETWORK_ID=$(openstack subnet show hyperconverged-subnet -f json 2> /dev/null | jq -r '.id'); then + echo "Creating the hyperconverged-subnet" TENANT_SUB_NETWORK_ID=$( openstack subnet create hyperconverged-subnet \ --network hyperconverged-net \ @@ -52,16 +68,17 @@ if ! TENANT_SUB_NETWORK_ID=$(openstack subnet show hyperconverged-subnet -f json ) fi -if ! openstack router show hyperconverged-router -f json | jq -r '.interfaces_info.[].subnet_id' | grep -q ${TENANT_SUB_NETWORK_ID}; then +if ! openstack router show hyperconverged-router -f json 2> /dev/null | jq -r '.interfaces_info.[].subnet_id' | grep -q ${TENANT_SUB_NETWORK_ID}; then openstack router add subnet hyperconverged-router hyperconverged-subnet fi -if ! openstack network show hyperconverged-compute-net; then +if ! openstack network show hyperconverged-compute-net 2> /dev/null; then openstack network create hyperconverged-compute-net \ --disable-port-security fi -if ! TENANT_COMPUTE_SUB_NETWORK_ID=$(openstack subnet show hyperconverged-compute-subnet -f json | jq -r '.id'); then +if ! TENANT_COMPUTE_SUB_NETWORK_ID=$(openstack subnet show hyperconverged-compute-subnet -f json 2> /dev/null | jq -r '.id'); then + echo "Creating the hyperconverged-compute-subnet" TENANT_COMPUTE_SUB_NETWORK_ID=$( openstack subnet create hyperconverged-compute-subnet \ --network hyperconverged-compute-net \ @@ -70,15 +87,15 @@ if ! TENANT_COMPUTE_SUB_NETWORK_ID=$(openstack subnet show hyperconverged-comput ) fi -if ! openstack router show hyperconverged-router -f json | jq -r '.interfaces_info.[].subnet_id' | grep -q ${TENANT_COMPUTE_SUB_NETWORK_ID}; then +if ! openstack router show hyperconverged-router -f json | jq -r '.interfaces_info.[].subnet_id' | grep -q ${TENANT_COMPUTE_SUB_NETWORK_ID} 2> /dev/null; then openstack router add subnet hyperconverged-router hyperconverged-compute-subnet fi -if ! openstack security group show hyperconverged-http-secgroup; then +if ! openstack security group show hyperconverged-http-secgroup 2> /dev/null; then openstack security group create hyperconverged-http-secgroup fi -if ! openstack security group show hyperconverged-http-secgroup -f json | jq -r '.rules.[].port_range_max' | grep -q 443; then +if ! openstack security group show hyperconverged-http-secgroup -f json 2> /dev/null | jq -r '.rules.[].port_range_max' | grep -q 443; then openstack security group rule create hyperconverged-http-secgroup \ --protocol tcp \ --ingress \ @@ -86,7 +103,7 @@ if ! openstack security group show hyperconverged-http-secgroup -f json | jq -r --dst-port 443 \ --description "https" fi -if ! openstack security group show hyperconverged-http-secgroup -f json | jq -r '.rules.[].port_range_max' | grep -q 80; then +if ! openstack security group show hyperconverged-http-secgroup -f json 2> /dev/null | jq -r '.rules.[].port_range_max' | grep -q 80; then openstack security group rule create hyperconverged-http-secgroup \ --protocol tcp \ --ingress \ @@ -95,11 +112,11 @@ if ! openstack security group show hyperconverged-http-secgroup -f json | jq -r --description "http" fi -if ! openstack security group show hyperconverged-secgroup; then +if ! openstack security group show hyperconverged-secgroup 2> /dev/null; then openstack security group create hyperconverged-secgroup fi -if ! openstack security group show hyperconverged-secgroup -f json | jq -r '.rules.[].description' | grep -q "all internal traffic"; then +if ! openstack security group show hyperconverged-secgroup -f json 2> /dev/null | jq -r '.rules.[].description' | grep -q "all internal traffic"; then openstack security group rule create hyperconverged-secgroup \ --protocol any \ --ingress \ @@ -107,11 +124,11 @@ if ! openstack security group show hyperconverged-secgroup -f json | jq -r '.rul --description "all internal traffic" fi -if ! openstack security group show hyperconverged-jump-secgroup; then +if ! openstack security group show hyperconverged-jump-secgroup 2> /dev/null; then openstack security group create hyperconverged-jump-secgroup fi -if ! openstack security group show hyperconverged-jump-secgroup -f json | jq -r '.rules.[].port_range_max' | grep -q 22; then +if ! openstack security group show hyperconverged-jump-secgroup -f json 2> /dev/null | jq -r '.rules.[].port_range_max' | grep -q 22; then openstack security group rule create hyperconverged-jump-secgroup \ --protocol tcp \ --ingress \ @@ -119,7 +136,7 @@ if ! openstack security group show hyperconverged-jump-secgroup -f json | jq -r --dst-port 22 \ --description "ssh" fi -if ! openstack security group show hyperconverged-jump-secgroup -f json | jq -r '.rules.[].protocol' | grep -q icmp; then +if ! openstack security group show hyperconverged-jump-secgroup -f json 2> /dev/null | jq -r '.rules.[].protocol' | grep -q icmp; then openstack security group rule create hyperconverged-jump-secgroup \ --protocol icmp \ --ingress \ @@ -127,19 +144,21 @@ if ! openstack security group show hyperconverged-jump-secgroup -f json | jq -r --description "ping" fi -if ! METAL_LB_IP=$(openstack port show metallb-vip-0-port -f json | jq -r '.fixed_ips[0].ip_address'); then +if ! METAL_LB_IP=$(openstack port show metallb-vip-0-port -f json 2> /dev/null | jq -r '.fixed_ips[0].ip_address'); then + echo "Creating the MetalLB VIP port" METAL_LB_IP=$(openstack port create --security-group hyperconverged-http-secgroup --network hyperconverged-net metallb-vip-0-port -f json | jq -r '.fixed_ips[0].ip_address') fi METAL_LB_PORT_ID=$(openstack port show metallb-vip-0-port -f value -c id) -if ! METAL_LB_VIP=$(openstack floating ip list --port ${METAL_LB_PORT_ID} -f json | jq -r '.[]."Floating IP Address"'); then +if ! METAL_LB_VIP=$(openstack floating ip list --port ${METAL_LB_PORT_ID} -f json 2> /dev/null | jq -r '.[]."Floating IP Address"'); then + echo "Creating the MetalLB VIP floating IP" METAL_LB_VIP=$(openstack floating ip create PUBLICNET --port ${METAL_LB_PORT_ID} -f json | jq -r '.floating_ip_address') elif [ -z "${METAL_LB_VIP}" ]; then METAL_LB_VIP=$(openstack floating ip create PUBLICNET --port ${METAL_LB_PORT_ID} -f json | jq -r '.floating_ip_address') fi -if ! WORKER_0_PORT=$(openstack port show hyperconverged-0-mgmt-port -f value -c id); then +if ! WORKER_0_PORT=$(openstack port show hyperconverged-0-mgmt-port -f value -c id 2> /dev/null); then export WORKER_0_PORT=$( openstack port create --allowed-address ip-address=${METAL_LB_IP} \ --security-group hyperconverged-secgroup \ @@ -152,7 +171,7 @@ if ! WORKER_0_PORT=$(openstack port show hyperconverged-0-mgmt-port -f value -c ) fi -if ! WORKER_1_PORT=$(openstack port show hyperconverged-1-mgmt-port -f value -c id); then +if ! WORKER_1_PORT=$(openstack port show hyperconverged-1-mgmt-port -f value -c id 2> /dev/null); then export WORKER_1_PORT=$( openstack port create --allowed-address ip-address=${METAL_LB_IP} \ --security-group hyperconverged-secgroup \ @@ -164,7 +183,7 @@ if ! WORKER_1_PORT=$(openstack port show hyperconverged-1-mgmt-port -f value -c ) fi -if ! WORKER_2_PORT=$(openstack port show hyperconverged-2-mgmt-port -f value -c id); then +if ! WORKER_2_PORT=$(openstack port show hyperconverged-2-mgmt-port -f value -c id 2> /dev/null); then export WORKER_2_PORT=$( openstack port create --allowed-address ip-address=${METAL_LB_IP} \ --security-group hyperconverged-secgroup \ @@ -176,13 +195,23 @@ if ! WORKER_2_PORT=$(openstack port show hyperconverged-2-mgmt-port -f value -c ) fi -if ! JUMP_HOST_VIP=$(openstack floating ip list --port ${WORKER_0_PORT} -f json | jq -r '.[]."Floating IP Address"'); then +if ! JUMP_HOST_VIP=$(openstack floating ip list --port ${WORKER_0_PORT} -f json 2> /dev/null | jq -r '.[]."Floating IP Address"'); then JUMP_HOST_VIP=$(openstack floating ip create PUBLICNET --port ${WORKER_0_PORT} -f json | jq -r '.floating_ip_address') elif [ -z "${JUMP_HOST_VIP}" ]; then JUMP_HOST_VIP=$(openstack floating ip create PUBLICNET --port ${WORKER_0_PORT} -f json | jq -r '.floating_ip_address') fi -if ! COMPUTE_0_PORT=$(openstack port show hyperconverged-0-compute-port -f value -c id) 2> /dev/null; then +echo "Creating pre-defined compute ports for the flat test network" +for i in {100..109}; do + if ! openstack port show hyperconverged-0-compute-float-${i}-port 2> /dev/null; then + openstack port create --network hyperconverged-compute-net \ + --disable-port-security \ + --fixed-ip ip-address="192.168.102.${i}" \ + hyperconverged-0-compute-float-${i}-port + fi +done + +if ! COMPUTE_0_PORT=$(openstack port show hyperconverged-0-compute-port -f value -c id 2> /dev/null); then export COMPUTE_0_PORT=$( openstack port create --network hyperconverged-compute-net \ --no-fixed-ip \ @@ -193,7 +222,7 @@ if ! COMPUTE_0_PORT=$(openstack port show hyperconverged-0-compute-port -f value ) fi -if ! COMPUTE_1_PORT=$(openstack port show hyperconverged-1-compute-port -f value -c id) 2> /dev/null; then +if ! COMPUTE_1_PORT=$(openstack port show hyperconverged-1-compute-port -f value -c id 2> /dev/null); then export COMPUTE_1_PORT=$( openstack port create --network hyperconverged-compute-net \ --no-fixed-ip \ @@ -204,7 +233,7 @@ if ! COMPUTE_1_PORT=$(openstack port show hyperconverged-1-compute-port -f value ) fi -if ! COMPUTE_2_PORT=$(openstack port show hyperconverged-2-compute-port -f value -c id) 2> /dev/null; then +if ! COMPUTE_2_PORT=$(openstack port show hyperconverged-2-compute-port -f value -c id 2> /dev/null); then export COMPUTE_2_PORT=$( openstack port create --network hyperconverged-compute-net \ --no-fixed-ip \ @@ -215,7 +244,7 @@ if ! COMPUTE_2_PORT=$(openstack port show hyperconverged-2-compute-port -f value ) fi -if ! openstack keypair show hyperconverged-key; then +if ! openstack keypair show hyperconverged-key 2> /dev/null; then if [ ! -f ~/.ssh/hyperconverged-key.pem ]; then openstack keypair create hyperconverged-key > ~/.ssh/hyperconverged-key.pem chmod 600 ~/.ssh/hyperconverged-key.pem @@ -230,35 +259,36 @@ fi ssh-add ~/.ssh/hyperconverged-key.pem # Create the three lab instances -if ! openstack server show hyperconverged-0; then +if ! openstack server show hyperconverged-0 2> /dev/null; then openstack server create hyperconverged-0 \ --port ${WORKER_0_PORT} \ --port ${COMPUTE_0_PORT} \ - --image "Ubuntu 24.04" \ + --image "${OS_IMAGE}" \ --key-name hyperconverged-key \ --flavor ${OS_FLAVOR} fi -if ! openstack server show hyperconverged-1; then +if ! openstack server show hyperconverged-1 2> /dev/null; then openstack server create hyperconverged-1 \ --port ${WORKER_1_PORT} \ --port ${COMPUTE_1_PORT} \ - --image "Ubuntu 24.04" \ + --image "${OS_IMAGE}" \ --key-name hyperconverged-key \ --flavor ${OS_FLAVOR} fi -if ! openstack server show hyperconverged-2; then +if ! openstack server show hyperconverged-2 2> /dev/null; then openstack server create hyperconverged-2 \ --port ${WORKER_2_PORT} \ --port ${COMPUTE_2_PORT} \ - --image "Ubuntu 24.04" \ + --image "${OS_IMAGE}" \ --key-name hyperconverged-key \ --flavor ${OS_FLAVOR} fi +echo "Waiting for the jump host to be ready" COUNT=0 -while ! ssh -o UserKnownHostsFile=/dev/null -q ubuntu@${JUMP_HOST_VIP} exit; do +while ! ssh -o ConnectTimeout=2 -o ConnectionAttempts=3 -o UserKnownHostsFile=/dev/null -q ${SSH_USERNAME}@${JUMP_HOST_VIP} exit; do sleep 2 echo "SSH is not ready, Trying again..." COUNT=$((COUNT+1)) @@ -269,16 +299,38 @@ while ! ssh -o UserKnownHostsFile=/dev/null -q ubuntu@${JUMP_HOST_VIP} exit; do done # Run bootstrap -ssh -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -t ubuntu@${JUMP_HOST_VIP} < /dev/null && pwd ) + if [ ! -d "${SCRIPT_DIR}" ]; then + echo "HYPERCONVERGED_DEV is true, but we've failed to determine the base genestack directory" + exit 1 + fi + ssh -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -t ${SSH_USERNAME}@${JUMP_HOST_VIP} \ + "sudo apt update && sudo apt install -y rsync git; sudo chown \${USER}:\${USER} /opt" + echo "Copying the development source code to the jump host" + rsync -az \ + -e "ssh -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null" \ + --rsync-path="sudo rsync" \ + $(readlink -fn ${SCRIPT_DIR}/../) ${SSH_USERNAME}@${JUMP_HOST_VIP}:/opt/ +fi + +ssh -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -t ${SSH_USERNAME}@${JUMP_HOST_VIP} < /etc/genestack/manifests/metallb/metallb-openstack-service-lb.yml < /etc/genestack/inventory/inventory.yaml < /etc/genestack/helm-configs/barbican/barbican-helm-overrides.yaml < /etc/genestack/helm-configs/kube-ovn/kube-ovn-helm-overrides.yaml <