github.com/StackPointCloud/docker-machine-driver-profitbricks

Docker Machine Driver for the ProfitBricks Compute Cloud


License
Apache-2.0
Install
go get github.com/StackPointCloud/docker-machine-driver-profitbricks

Documentation

ProfitBricks Docker Machine Driver

This is the official Docker Machine driver for use with the ProfitBricks Cloud.

Table of Contents

Install Docker Machine

This ProfitBricks plugin will only work with Docker Machine. Before we continue, you will need to install Docker Machine. Docker Machine is included as part of Docker Toolbox. You can gain access to docker-machine by installing Docker Toolbox on Mac OS X or Windows. It is also possible to install just Docker Machine without the rest of the components of Docker Toolbox.

Install Go

The ProfitBricks Docker Machine Driver is written in the Go programming language. Your system will need to have Go installed. Please refer to the Go Install Documentation if you do not have Go installed and configured for your system.

Remember to set $GOPATH and update $PATH. The following are just examples using the export command, you will need to adjust the paths for your particular installation.

export GOPATH=/usr/local/go
export PATH=$PATH:/usr/local/go/bin

Install Driver

With those prerequisites taken care of, will need to run the following commands to install the ProfitBricks Docker Machine driver:

go get github.com/profitbricks/docker-machine-driver-profitbricks

If you just installed Go, you may get an error indicating the need to configure the $GOPATH environment variable. Once $GOPATH is set properly, the command should complete successfully.

Next we need to build and install the driver itself.

cd $GOPATH/src/github.com/profitbricks/docker-machine-driver-profitbricks
make install

When successful, we will end up with a newly created docker-machine-driver-profitbricks binary in $GOPATH/bin/.

Create a Machine

Before you create a ProfitBricks machine you will need to set two environment variables containing your ProfitBricks credentials. These would be the same username and password that you use to log into the ProfitBricks DCD (Data Center Designer):

export PROFITBRICKS_USERNAME="profitbricks_username"
export PROFITBRICKS_PASSWORD="profitbricks_password"

It is possible to pass your credentials on the command-line using --profitbricks-username and --profitbricks-password if you prefer.

Now run docker-machine create with the relevant parameters. This example will use mostly default values and will therefore be created in the us/las location.

docker-machine create --driver profitbricks test-machine

It should produce results similar to this:

Running pre-create checks...
Creating machine...
(test-machine) Datacenter Created
(test-machine) Server Created
(test-machine) Volume Created
(test-machine) Attached a volume  to a server.
(test-machine) LAN Created
(test-machine) NIC created
(test-machine) Updated server's boot image
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with ubuntu(systemd)...
Installing Docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env test-machine

To get detailed information about the possible options, run the command:

docker-machine create --help --driver profitbricks

Usage: Usage: docker-machine create [OPTIONS] [arg...]

       Create a machine

       Description:
          Run 'docker-machine create --driver name' to include the create flags for that driver in the help text.

       Options:

          --driver, -d "none"                               Driver to create machine with.
          --engine-env [--engine-env option --engine-env option]            Specify environment variables to set in the engine
          --engine-insecure-registry [--engine-insecure-registry option --engine-insecure-registry option]  Specify insecure registries to allow with the created engine
          --engine-install-url "https://get.docker.com"             Custom URL to use for engine installation [$MACHINE_DOCKER_INSTALL_URL]
          --engine-label [--engine-label option --engine-label option]          Specify labels for the created engine
          --engine-opt [--engine-opt option --engine-opt option]            Specify arbitrary flags to include with the created engine in the form flag=value
          --engine-registry-mirror [--engine-registry-mirror option --engine-registry-mirror option]        Specify registry mirrors to use
          --engine-storage-driver                           Specify a storage driver to use with the engine
          --profitbricks-cores "4"                          profitbricks cores (2, 3, 4, 5, 6, etc.) [$PROFITBRICKS_CORES]
          --profitbricks-cpu-family "AMD_OPTERON"           profitbricks CPU families (INTEL_XEON, AMD_OPTERON) [$PROFITBRICKS_CPU_FAMILY]
          --profitbricks-disk-size "50"                     profitbricks disk size (10, 50, 100, 200, 400) [$PROFITBRICKS_DISK_SIZE]
          --profitbricks-disk-type "HDD"                        profitbricks disk type (HDD, SSD) [$PROFITBRICKS_DISK_TYPE]
          --profitbricks-endpoint "https://api.profitbricks.com/rest/v2"        profitbricks API endpoint [$PROFITBRICKS_ENDPOINT]
          --profitbricks-image "Ubuntu-16.04"           profitbricks image [$PROFITBRICKS_IMAGE]
          --profitbricks-location "us/las"                      profitbricks location [$PROFITBRICKS_LOCATION]
          --profitbricks-password                           profitbricks password [$PROFITBRICKS_PASSWORD]
          --profitbricks-ram "2048"                         profitbricks ram (1024, 2048, 3072, 4096, etc.) [$PROFITBRICKS_RAM]
          --profitbricks-username                           profitbricks username [$PROFITBRICKS_USERNAME]
          --swarm                                   Configure Machine with Swarm
          --swarm-addr                              addr to advertise for Swarm (default: detect and use the machine IP)
          --swarm-discovery                                 Discovery service to use with Swarm
          --swarm-host "tcp://0.0.0.0:3376"                     ip/socket to listen on for Swarm master
          --swarm-image "swarm:latest"                          Specify Docker image to use for Swarm [$MACHINE_SWARM_IMAGE]
          --swarm-master                                Configure Machine to be a Swarm master
          --swarm-opt [--swarm-opt option --swarm-opt option]               Define arbitrary flags for swarm
          --swarm-strategy "spread"                         Define a default scheduling strategy for Swarm
          --tls-san [--tls-san option --tls-san option]             Support extra SANs for TLS certs

To list the machines you have created, use the command:

docker-machine ls

It will return information about your machines, similar to this:

NAME           ACTIVE   DRIVER         STATE     URL                         SWARM   DOCKER    ERRORS
default        -        virtualbox     Running   tcp://192.168.99.100:2376           v1.10.2
test-machine   -        profitbricks   Running   tcp://162.254.26.156:2376           v1.10.3

Create a Swarm

Before you create a swarm of ProfitBricks machines, run this command:

docker run --rm swarm create

Then use the output to create the swarm and set a swarm master:

docker-machine create -d profitbricks --swarm --swarm-master --swarm-discovery token://f3a75db19a03589ac28550834457bfc3 swarm-master-test

To create a swarm child, use the command:

docker-machine create -d profitbricks --swarm --swarm-discovery token://f3a75db19a03589ac28550834457bfc3 swarm-child-test

Support

You are welcome to contact us with questions or comments at ProfitBricks DevOps Central. Please report any issues via GitHub's issue tracker.