Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add rendezvous command examples #8518

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -ex

export SET_AWS_REGION="us-west-2"
source ../../common/aws.sh

run() {
common_create "$1" "../../common/admin.sh" "0"
}

cleanup() {
common_cleanup
}

export AWS_PAGER="";
export AWS_DEFAULT_OUTPUT="text";

user=""
command -v sha256sum &>/dev/null && user=$(aws sts get-caller-identity | sha256sum | cut -c 1-20)
command -v shasum &>/dev/null && user=$(aws sts get-caller-identity | shasum -a 256 | cut -c 1-20)
export name="ockam-ex-rendezvous-aws-aws-different-regions-bob-$user"

# Check if the first argument is "cleanup"
# If it is, call the cleanup function. If not, call the run function.
if [ "$1" = "cleanup" ]; then cleanup; else run "$1"; fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
set -ex

# PROD RENDEZVOUS
export OCKAM_RENDEZVOUS_SERVER="rendezvous.orchestrator.ockam.io:4000"

run() {
ockam enroll

bob_ticket=$(ockam project ticket --usage-count 1 --expires-in 100h --relay bob)
alice_ticket=$(ockam project ticket --usage-count 1 --expires-in 100h)

if [[ -n "$OCKAM_VERSION" ]]; then
export OCKAM_VERSION="v${OCKAM_VERSION}";
fi

echo; pushd administrator_bob; ./run.sh "$bob_ticket"; popd
echo; pushd user_alice; ./run.sh "$alice_ticket"; popd
}


# Cleanup after the example - `./run.sh cleanup`
# Remove all resources that were created in AWS.
cleanup() {
pushd administrator_bob; ./run.sh cleanup; popd
pushd user_alice; ./run.sh cleanup; popd
}

# Check if Ockam Command is already installed and available in path.
# If it's not, then install it.
if ! type ockam &>/dev/null; then
curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash
source "$HOME/.ockam/env"
fi

# Check that tools we we need installed.
for c in curl aws; do
if ! type "$c" &>/dev/null; then echo "ERROR: Please install: $c" && exit 1; fi
done

# Check if the first argument is "cleanup"
# If it is, call the cleanup function. If not, call the run function.
if [ "$1" = "cleanup" ]; then
cleanup;
else
run;
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -ex

# Create AWS environment
export SET_AWS_REGION="us-east-2"
export ENABLE_SSH="1"
source ../../common/aws.sh

run() {
ip=$(common_create "$1" "../../common/user.sh" "0")

echo "IP address is $ip"
until nc -z -v -w5 $ip 22; do sleep 5; done

ssh -o StrictHostKeyChecking=no -i ./key.pem "ec2-user@$ip" \
'bash -s' << 'EOS'
sleep 8s
curl --silent --show-error --fail 127.0.0.1:4000
EOS
}

cleanup() {
common_cleanup
}

export AWS_PAGER="";
export AWS_DEFAULT_OUTPUT="text";

user=""
command -v sha256sum &>/dev/null && user=$(aws sts get-caller-identity | sha256sum | cut -c 1-20)
command -v shasum &>/dev/null && user=$(aws sts get-caller-identity | shasum -a 256 | cut -c 1-20)
export name="ockam-ex-rendezvous-aws-aws-different-regions-alice-$user"

# Check if the first argument is "cleanup"
# If it is, call the cleanup function. If not, call the run function.
if [ "$1" = "cleanup" ]; then cleanup; else run "$1"; fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -ex

source ../../common/aws.sh

run() {
common_create "$1" "../../common/admin.sh" "0"
}

cleanup() {
common_cleanup
}

export AWS_PAGER="";
export AWS_DEFAULT_OUTPUT="text";

user=""
command -v sha256sum &>/dev/null && user=$(aws sts get-caller-identity | sha256sum | cut -c 1-20)
command -v shasum &>/dev/null && user=$(aws sts get-caller-identity | shasum -a 256 | cut -c 1-20)
export name="ockam-ex-rendezvous-aws-aws-same-region-different-zone-bob-$user"

# Check if the first argument is "cleanup"
# If it is, call the cleanup function. If not, call the run function.
if [ "$1" = "cleanup" ]; then cleanup; else run "$1"; fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
set -ex

# PROD RENDEZVOUS
export OCKAM_RENDEZVOUS_SERVER="rendezvous.orchestrator.ockam.io:4000"

run() {
ockam enroll

bob_ticket=$(ockam project ticket --usage-count 1 --expires-in 100h --relay bob)
alice_ticket=$(ockam project ticket --usage-count 1 --expires-in 100h)

if [[ -n "$OCKAM_VERSION" ]]; then
export OCKAM_VERSION="v${OCKAM_VERSION}";
fi

echo; pushd administrator_bob; ./run.sh "$bob_ticket"; popd
echo; pushd user_alice; ./run.sh "$alice_ticket"; popd
}


# Cleanup after the example - `./run.sh cleanup`
# Remove all resources that were created in AWS.
cleanup() {
pushd administrator_bob; ./run.sh cleanup; popd
pushd user_alice; ./run.sh cleanup; popd
}

# Check if Ockam Command is already installed and available in path.
# If it's not, then install it.
if ! type ockam &>/dev/null; then
curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash
source "$HOME/.ockam/env"
fi

# Check that tools we we need installed.
for c in curl aws; do
if ! type "$c" &>/dev/null; then echo "ERROR: Please install: $c" && exit 1; fi
done

# Check if the first argument is "cleanup"
# If it is, call the cleanup function. If not, call the run function.
if [ "$1" = "cleanup" ]; then
cleanup;
else
run;
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -ex

# Create AWS environment
export ENABLE_SSH="1"
source ../../common/aws.sh

run() {
ip=$(common_create "$1" "../../common/user.sh" "1")

echo "IP address is $ip"
until nc -z -v -w5 $ip 22; do sleep 5; done

ssh -o StrictHostKeyChecking=no -i ./key.pem "ec2-user@$ip" \
'bash -s' << 'EOS'
sleep 8s
curl --silent --show-error --fail 127.0.0.1:4000
EOS
}

cleanup() {
common_cleanup
}

export AWS_PAGER="";
export AWS_DEFAULT_OUTPUT="text";

user=""
command -v sha256sum &>/dev/null && user=$(aws sts get-caller-identity | sha256sum | cut -c 1-20)
command -v shasum &>/dev/null && user=$(aws sts get-caller-identity | shasum -a 256 | cut -c 1-20)
export name="ockam-ex-rendezvous-aws-aws-same-region-different-zone-alice-$user"

# Check if the first argument is "cleanup"
# If it is, call the cleanup function. If not, call the run function.
if [ "$1" = "cleanup" ]; then cleanup; else run "$1"; fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -ex

source ../../common/aws.sh

run() {
common_create "$1" "../../common/admin.sh" "0"
}

cleanup() {
common_cleanup
}

export AWS_PAGER="";
export AWS_DEFAULT_OUTPUT="text";

user=""
command -v sha256sum &>/dev/null && user=$(aws sts get-caller-identity | sha256sum | cut -c 1-20)
command -v shasum &>/dev/null && user=$(aws sts get-caller-identity | shasum -a 256 | cut -c 1-20)
export name="ockam-ex-rendezvous-aws-aws-same-region-same-zone-bob-$user"

# Check if the first argument is "cleanup"
# If it is, call the cleanup function. If not, call the run function.
if [ "$1" = "cleanup" ]; then cleanup; else run "$1"; fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
set -ex

# PROD RENDEZVOUS
export OCKAM_RENDEZVOUS_SERVER="rendezvous.orchestrator.ockam.io:4000"

run() {
ockam enroll

bob_ticket=$(ockam project ticket --usage-count 1 --expires-in 100h --relay bob)
alice_ticket=$(ockam project ticket --usage-count 1 --expires-in 100h)

if [[ -n "$OCKAM_VERSION" ]]; then
export OCKAM_VERSION="v${OCKAM_VERSION}";
fi

echo; pushd administrator_bob; ./run.sh "$bob_ticket"; popd
echo; pushd user_alice; ./run.sh "$alice_ticket"; popd
}


# Cleanup after the example - `./run.sh cleanup`
# Remove all resources that were created in AWS.
cleanup() {
pushd administrator_bob; ./run.sh cleanup; popd
pushd user_alice; ./run.sh cleanup; popd
}

# Check if Ockam Command is already installed and available in path.
# If it's not, then install it.
if ! type ockam &>/dev/null; then
curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash
source "$HOME/.ockam/env"
fi

# Check that tools we we need installed.
for c in curl aws; do
if ! type "$c" &>/dev/null; then echo "ERROR: Please install: $c" && exit 1; fi
done

# Check if the first argument is "cleanup"
# If it is, call the cleanup function. If not, call the run function.
if [ "$1" = "cleanup" ]; then
cleanup;
else
run;
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -ex

# Create AWS environment
export ENABLE_SSH="1"
source ../../common/aws.sh

run() {
ip=$(common_create "$1" "../../common/user.sh" "0")

echo "IP address is $ip"
until nc -z -v -w5 $ip 22; do sleep 5; done

ssh -o StrictHostKeyChecking=no -i ./key.pem "ec2-user@$ip" \
'bash -s' << 'EOS'
sleep 8s
curl --silent --show-error --fail 127.0.0.1:4000
EOS
}

cleanup() {
common_cleanup
}

export AWS_PAGER="";
export AWS_DEFAULT_OUTPUT="text";

user=""
command -v sha256sum &>/dev/null && user=$(aws sts get-caller-identity | sha256sum | cut -c 1-20)
command -v shasum &>/dev/null && user=$(aws sts get-caller-identity | shasum -a 256 | cut -c 1-20)
export name="ockam-ex-rendezvous-aws-aws-same-region-same-zone-alice-$user"

# Check if the first argument is "cleanup"
# If it is, call the cleanup function. If not, call the run function.
if [ "$1" = "cleanup" ]; then cleanup; else run "$1"; fi
26 changes: 26 additions & 0 deletions examples/command/portals/rendezvous/common/admin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -ex

# Change into ec2-user's home directory and use sudo to run the commands as ec2-user
sudo bash << 'EOS'
set -ex

# Install Ockam Command
export OCKAM_VERSION="$OCKAM_VERSION"
curl --proto '=https' --tlsv1.2 -sSfL https://install.command.ockam.io | bash
source "$HOME/.ockam/env"

# PROD RENDEZVOUS
export OCKAM_RENDEZVOUS_SERVER="rendezvous.orchestrator.ockam.io:443"

ockam identity create bob

ockam project enroll "$ENROLLMENT_TICKET" --identity bob

python3 -m http.server --bind 127.0.0.1 8000 &

ockam node create bob --identity bob --enable-udp
ockam tcp-outlet create --ebpf --at bob --to 127.0.0.1:8000
ockam relay create bob --to /node/bob

EOS
Loading
Loading