Grab bag of stuff for CMPT 756
These come pre-installed in the course code repository c756-exer
for use
in the course tools container.
If you want to use them in your host OS:
$ cd ~
$ mkdir scratch
$ cd scratch
$ git clone https://github.com/overcoil/c756-quickies.git c756q
# cp to taste any of the above
$ cp c756q/.aws-* ~
In your .bashrc/.zshrc, add as appropriate:
if [ -f ~/.kubectl-a ]; then . ~/.kubectl-a; fi
if [ -f ~/.docker-a ]; then . ~/.docker-a; fi
if [ -f ~/.aws-a ]; then . ~/.aws-a; fi
This set of aliases relies on jq
extensively. The tool-container environment already has this installed. But if you wish to use these in your host environment directly, install it per the instructions.
Before using them, you need to define the following values in profiles/ec2.mak
(for the tools container)
or ~/.ec2.mak
(for your host OS). They are specified near the start of the file:
-
REGION
: The default region isus-west-2
. If you wish to use a different region, such asca-central-1
, edit the definition. -
SGI_WFH
: You need to specify a security group id. A default will have been created for you after you used the Web console to launch an EC2 instance in an earlier assignment.To list your available security groups, either:
- View the appropriate Console page for your region in a browser:
- Or run on the command line, where
REGION
is your chosen region:
aws --region REGION ec2 describe-security-groups --output json | jq '.SecurityGroups[].GroupId'
-
KEY
: The name of an AWS key pair that you have downloaded.To list your available key pairs, either
-
View the appropriate Console page for your region in a browser:
-
Or run on the command line, where
REGION
is your chosen region:aws --region REGION ec2 describe-key-pairs
-
-
LKEY
: The path to your downloaded key pair. In earlier assignments, we requested that you place the pairs in~/.ssh
. If your key pair name wasaws
, then setLKEY=~/.ssh/aws.pem
.
The .ec2.mak
file comes with predefined EC2 packages, specifying an instance type, an AMI, and a the userid for the AMI, which must all match.
Run a package specifying an x86 instance via the command:
epkg <package-name>
A partial list of the available packages for x86 machines:
gpu
: A mid-sized EC2 x86 instance with an attached GPU. Sign on with useridec2-user
.gpu_small
: A smaller EC2 x86 instance with an attached GPU. Sign on with useridec2-user
.gpu_big
: A larger EC2 x86 instance with an attached GPU. Sign on with useridec2-user
.gpu_very_big
: A much larger EC2 x86 instance with an attached GPU. Sign on with useridec2-user
.- default: A small EC2 x86 instance eligible for the AWS Free Tier. You specify the default via either of
epkg ''
orerun
. Sign on with useridubuntu
.
Run a package specifying an ARM instance via the command:
armpkg <package-name>
A partial list of the available instances for ARM machines:
gpu
: A mid-sized EC2 ARM instance with an attached GPU. Sign on with useridubuntu
.gpu_small
: A smaller EC2 ARM instance with an attached GPU. Sign on with useridubuntu
.gpu_big
: A larger EC2 ARMinstance with an attached GPU. Sign on with useridubuntu
.gpu_very_big
: A much larger EC2 ARM instance with two attached GPUs. Sign on with useridubuntu
.- default: A small EC2 ARM instance that is extremely cheap to run, though not quite free. You specify the default via either of
armpkg ''
orarmrun
. Sign on with useridubuntu
.
-
esn NAME USERID
: AddNAME
to the command-line prompt of the instance tagged withNAME
, whereNAME
is an adjective_name pair such asjoyous_allen
. Specify theUSERID
required by the AMI loaded into the instance, typicallyubuntu
(for an Ubuntu-based image) orec2-user
(for an Amazon Linux 2 image). This is annoying but there is no easy way around this.This command should be run 1–2 minutes after starting an instance, allowing enough time for it to fully start up. Doing so provides a helpful reminder in your terminal session.
Only sign on to an instance after running esn
, to ensure that your prompt line identifies the instance your are signed in to.
essh
: Sign on to the most-recently-started x86 instance.armssh
: Sign on to the most-recently-started ARM instance.esshn NAME USERID
: Sign on to instance taggedNAME
(either x86 or ARM), with useridUSERID
.
eps
: List all instances and their status. The output will include recently-terminated instances.
There are several commands to terminate one or more instances:
epurge
: Terminate all running EC2 instances.ekill
: Terminate the most-recently-started x86 instance.armkill
: Terminate the most-recently-started ARM instance.ekn NAME
: Terminate the instance (either x86 or ARM) tagged withNAME
.
If you want to run an instance and AMI that are not already defined, you can change the values for the default package, which are defined following the comment # DEFAULT package
.
Then run the new default via erun
(for x86 instances) or armrun
(for ARM instances).
In the host OS, to turn off the aliases, source .aws-off
:
$ source ~/.aws-off
In the tools container, to turn off the aliases, simply exit the container and start a fresh copy.