19 May 2014

joyent sdc

by mo

To provision new nodes using the Joyent Smart Data Center install the SDC command line tools. You will need nodejs and npm installed.

  $ npm install -g smartdc

Then configure 3 environment variables to connect to your account. The SDC_KEY_ID is the public fingerprint of your ssh public key.

  export SDC_URL=https://us-sw-1.api.joyentcloud.com
  export SDC_KEY_ID=6f:c4:53:a7:52:16:3f:bd:e7:eb:9b:e4:59:87:c4:63

Your public key will need to be added to your ssh agent. You can list them by using the following command:

$ ssh-add -l
2048 6f:c4:53:a7:52:16:3f:bd:e7:eb:9b:e4:59:87:c4:63 /Users/mo/.ssh/id_rsa (RSA)

Now you should be able to connect to the SDC api via the command line tools. To create a new machine you will need to specify the image, network and package to use.
The image specifies the type of operating system. The network specifies the configuration for the network to use, and the packages specifies how many processors and memory your new machine should have.

You can list out the different images, networks, and packages by using the following commands.

  $ sdc-listimages
  $ sdc-networks
  $ sdc-packages

Records the id of the image network and package you wish to use. Then you can create and provision a new machine using the createmachine command.

  $ sdc-createmachine -n mo-development --image 1eadbc8a-cd49-11e3-8331-d7e9df15d645 --package 5d367f42-867b-4cc3-883c-b329cbaad9d4 --network bd88a427-7ebd-403e-90e5-9b4834ed1d51

This will start to provision a new machine. It will take a bit of time to get this machine running. You can monitor the progress by getting the state of the new machine.

  $ sdc-listmachines
  $ sdc-getmachine <MACHINE-ID> | grep state

Once the machine is running, you should be able to ssh in to the new machine. The public keys specified in your account should be added to the authorized_keys file so you should have no problem.