Skip to content

Commit

Permalink
Updated init script to allow metadata override (#82)
Browse files Browse the repository at this point in the history
* Updated init script to allow metadata override

* .

* rewording in README.md

* Restore sudo into gce_install_sandbox.sh script

* Add script to work around missing secret issue

* repalce crach check with a simple delay
  • Loading branch information
liamfallon authored Jun 13, 2023
1 parent 61a02a0 commit 5e0ca32
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 10 deletions.
17 changes: 17 additions & 0 deletions e2e/provision/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,20 @@ kubectl apply -f test-infra/e2e/tests/005-regional-free5gc-amf.yaml
kubectl apply -f test-infra/e2e/tests/005-regional-free5gc-smf.yaml
kubectl apply -f test-infra/e2e/tests/006-edge-free5gc-upf.yaml
```
# Quick Start for VM running on Openstack

## Step 1: Order or Create a VM using your local VM

Order or create a VM with the following specification:
- Linux Flavour: Ubuntu-22.04-jammy
- 16 cores
- 32 GB memory
- 200 GB disk size
- default user is "ubuntu" and "ubuntu" needs sudo passwordless permissions

## Step 2: Kick off the install
```
wget -O - https://raw.githubusercontent.com/nephio-project/test-infra/main/e2e/provision/gce_init.sh | \
sudo NEPHIO_DEBUG=false \
NEPHIO_USER=ubuntu \
bash
17 changes: 7 additions & 10 deletions e2e/provision/gce_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,23 @@ function get_metadata {
echo $(curl -sf "http://metadata.google.internal/computeMetadata/v1/instance/attributes/$md" -H "Metadata-Flavor: Google" || echo "$df")
}

DEBUG=$(get_metadata nephio-setup-debug "false")
DEBUG=${NEPHIO_DEBUG:-$(get_metadata nephio-setup-debug "false")}

[[ "$DEBUG" != "true" ]] || set -o xtrace

DEPLOYMENT_TYPE=$(get_metadata nephio-setup-type "r1")
RUN_E2E=$(get_metadata nephio-run-e2e "false")
REPO=$(get_metadata nephio-test-infra-repo "https://github.com/nephio-project/test-infra.git")
BRANCH=$(get_metadata nephio-test-infra-branch "main")
NEPHIO_USER=${USER:-ubuntu}
DEPLOYMENT_TYPE=${NEPHIO_DEPLOYMENT_TYPE:-$(get_metadata nephio-setup-type "r1")}
RUN_E2E=${NEPHIO_RUN_E2E:-$(get_metadata nephio-run-e2e "false")}
REPO=${NEPHIO_REPO:-$(get_metadata nephio-test-infra-repo "https://github.com/nephio-project/test-infra.git")}
BRANCH=${NEPHIO_BRANCH:-$(get_metadata nephio-test-infra-branch "main")}
NEPHIO_USER=${NEPHIO_USER:-ubuntu}

echo "$DEBUG, $DEPLOYMENT_TYPE, $RUN_E2E, $REPO, $BRANCH"
echo "$DEBUG, $DEPLOYMENT_TYPE, $RUN_E2E, $REPO, $BRANCH, $NEPHIO_USER"

apt-get update
apt-get install -y git


cd /home/$NEPHIO_USER


runuser -u $NEPHIO_USER git clone "$REPO" test-infra
if [[ "$BRANCH" != "main" ]]; then
cd test-infra && runuser -u $NEPHIO_USER -- git checkout -b "$BRANCH" --track "origin/$BRANCH" && cd ..
Expand All @@ -54,7 +52,6 @@ runuser -u $NEPHIO_USER ./gce_install_sandbox.sh
# Grant Docker permissions to current user
if ! getent group docker | grep -q "$NEPHIO_USER"; then
sudo usermod -aG docker "$NEPHIO_USER"
newgrp docker
fi

if [[ "$RUN_E2E" == "true" ]]; then
Expand Down
63 changes: 63 additions & 0 deletions e2e/provision/hacks/resolve_secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2023 The Nephio Authors.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

set -o pipefail
set -o errexit
set -o nounset

function destroy_kpt_pkg {
local temp_dir=$1
local name=$2

echo "destroying $name kpt package in $temp_dir . . ."
pushd "$temp_dir" > /dev/null
kpt live --kubeconfig "$HOME/.kube/config" destroy "$temp_dir/$name"
popd > /dev/null
echo "destroyed $name kpt package in $temp_dir"
}

function apply_kpt_pkg {
local temp_dir=$1
local name=$2

echo "applying $name kpt package in $temp_dir . . ."
pushd "$temp_dir" > /dev/null
kpt live --kubeconfig "$HOME/.kube/config" apply "$temp_dir/$name"
popd > /dev/null
echo "applied $name kpt package in $temp_dir"
}

kpt_package_count=$(find /tmp -mindepth 1 -maxdepth 1 -type d -name 'kpt*' | wc -l)

if (( kpt_package_count != 3 ))
then
echo "there must be three and only three kpt temporary directories in /tmp"
exit 1
fi

mgmt_temp_dir=$(find /tmp/kpt* | grep 'mgmt\/token-configsync.yaml$' | sed 's/\/mgmt\/token-configsync.yaml$//')
mgmt_rootsync_temp_dir=$(find /tmp/kpt* | grep 'rootsync.yaml$' | sed 's/\/mgmt\/rootsync.yaml$//')
mgmt_staging_temp_dir=$(find /tmp/kpt* | grep 'mgmt-staging$' | sed 's/\/mgmt-staging$//')

echo "found mgmt kpt package in $mgmt_temp_dir"
echo "found mgmt rootsync kpt package in $mgmt_rootsync_temp_dir"
echo "found mgmt-staging kpt package in $mgmt_staging_temp_dir"

destroy_kpt_pkg "$mgmt_staging_temp_dir" "mgmt-staging"
destroy_kpt_pkg "$mgmt_rootsync_temp_dir" "mgmt"
destroy_kpt_pkg "$mgmt_temp_dir" "mgmt"

echo "waiting 60 seconds for package deletions to propogate . . ."
sleep 60
echo "continuing . . ."

apply_kpt_pkg "$mgmt_temp_dir" "mgmt"
apply_kpt_pkg "$mgmt_rootsync_temp_dir" "mgmt"
apply_kpt_pkg "$mgmt_staging_temp_dir" "mgmt-staging"

0 comments on commit 5e0ca32

Please sign in to comment.