Skip to content

Spearhead Cloud CLI tool

Last edit: Thu May 18 11:18:54 EEST 2023

The primary method to manage your Spearhead Cloud infrastructure is by using the Triton CLI.

The triton CLI tool can currently handle the following tasks:

  • manage compute instances (containers and virtual machines)
  • create, delete, resize, snapshot
  • view Spearhead Cloud packages
  • create, delete and manage Spearhead Cloud images
  • view networks
  • create and delete firewall rules
  • view Spearhead Cloud Datacenter's
  • management of your own account
  • manage your SSH key(s)

Install Triton CLI tool

The triton CLI tool can be installed via npm (Node Package Manager). This requires that you have a recent version of npm installed from http://www.npmjs.org.

Once you have npm installed just run the following command to configure the Triton CLI tool. Please note that on windows you need to use the global flag (-g).

npm install -g triton

On some platforms you may be required to use sudo (sudo npm install ...).

Environment Variables

On Windows, setting up these variables is required.

export TRITON_PROFILE="env"
export SDC_URL="https://eu-ro-1.api.spearhead.cloud"
export SDC_ACCOUNT="<SDC_USERNAME>"
unset SDC_USER
export SCD_KEY_ID="$(ssh-keygen -l -f $HOME/.ssh/id_rsa.pub | awk '{print $2}')"
unset SDC_TESTING

These variables will configure the triton env profile for you.

Spearhead Profiles

The triton CLI tool allows for the use of profiles to manage multiple Spearhead Cloud accounts. A profile contains your user details (username), a Spearhead Cloud Datacenter API URL and SSH key(s).

Configure a Spearhead Cloud Profile

To configure a new Spearhead Cloud Profile have the name of the datacenter API endpoint ready and run the following command and answer the questions.

$ triton profile create

For more information about Profile, run triton profile --help command.

Create an instance

Creating an instance is possible via the triton create command. You will first need to identify the image and package to assign to you new instance.

Finding on image

To list all available images run triton imgs and you will be presented with a list of our available images.

Finding a package

To list all available packages run triton pkgs and you will be presented with a list of our available packages.

Note that the names starting with hvm are KVM or byve hardware virtual machines while standard refers to Infrastructure Containers such as SmartOS Zones or LX Branded Zones.

Delete an instance

To remove an instance run triton delete <instance> command. Optionally you can use triton rm <instance>. <instance> can be either an instance name, id or short id.

Viewing instances

To view a list of all instances configured for your account run triton ls.

$ triton ls
SHORTID   NAME                    IMG                    STATE    FLAGS  AGE
c0fe5e19  code.alberta.internal   ubuntu-16.04@20170403  running  -      8w
f49f145e  ns01                    ubuntu-16.04@20170403  running  -      7w
5940b249  agitated_turing         0227ae25               running  D      2d
fb174b04  ncmysql                 ff8ecad5               running  DF     2d
9adb0454  routeme                 ubuntu-16.04@20170403  running  -      2d
64e8917b  kubecon                 ubuntu-16.04@20170403  running  -      2d

Useful commands

wait

The triton tool does not wait for commands to finish, it will return control back to you quickly. There are situation where waiting for one thing to finish before starting another is useful. For such scenarios you can wait by using the --wait or -w flags or by using triton instance create wait command.

script

Another useful command is the --script flag which will run a user specified script at the end of provisioning.

Below is an example of using the --script flag.

triton instance create \
    --name=some-instance \
    7b5981c4 \
    8b4fdd0b \
    --wait \
    --script=./myscrtip.sh

instance details

To view all of your instance's details run triton instance get -j some-instance. This will give you a full JSON blob of your instance details. You can optionally pipe the instance details output through the json command and parse or perform other operations.