Giter Club home page Giter Club logo

docker-machine-driver-triton's Introduction

docker-machine-driver-triton

A Docker Machine driver for Triton.

Requirements

You need a Triton account to use this driver. See this page to create an account on the Triton Public Cloud.

Installation from source

To get the code and compile the binary, run:

go get -u github.com/joyent/docker-machine-driver-triton

Then put the driver in a directory filled in your PATH environment variable or run:

export PATH=$PATH:$GOPATH/bin

This will allow the docker-machine command to find the docker-machine-driver-triton binary.

How to use

Driver-specific command line flags

Flags description

  • --triton-account : The username of the Triton account to use when using the Triton Cloud API. (required)
  • --triton-key-id : The fingerprint of the public key of the SSH key pair to use for authentication with the Triton Cloud API. (required)
  • --triton-key-path : Path to the file in which the private key of triton_key_id is stored.
  • --triton-url : The URL of the Triton Cloud API to use.
  • --triton-image : The name of the Triton image to use.
  • --triton-package : The Triton package to use.
  • --triton-ssh-user: The username to connect to SSH with.

Flags usage

Option Environment Default value
--triton-account TRITON_ACCOUNT
--triton-key-id TRITON_KEY_ID
--triton-key-path TRITON_KEY_PATH "~/.ssh/id_rsa"
--triton-url TRITON_URL "https://us-east-1.api.joyent.com"
--triton-image "debian-8"
--triton-package "g3-standard-0.25-kvm"
--triton-ssh-user TRITON_SSH_USER "root"

Provisioning examples

An example:

docker-machine create -d triton \
--triton-account [email protected] \
--triton-key-id 68:9f:9a:c4:76:3a:f4:62:77:47:3e:47:d4:34:4a:b7 \
test-node

An example using environment variables:

export TRITON_ACCOUNT="[email protected]"
export TRITON_KEY_ID="68:9f:9a:c4:76:3a:f4:62:77:47:3e:47:d4:34:4a:b7"
docker-machine create -d triton test-node

An example using a Ubuntu Image:

docker-machine create -d triton \
--triton-account [email protected] \
--triton-key-id 68:9f:9a:c4:76:3a:f4:62:77:47:3e:47:d4:34:4a:b7 \
--triton-image [email protected] \
--triton-ssh-user ubuntu \
test-node

docker-machine-driver-triton's People

Contributors

misterbisson avatar nimajalali avatar tianon avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-machine-driver-triton's Issues

Make machine driver compatible with Rancher

I tried adding this machine driver as a custom node driver in the Rancher UI and then provisioning a node with it but I had issues trying to give Rancher access to my Triton SSK key. I have Rancher running in a Docker container on an Ubuntu bhyve VM in Triton. I installed my Triton SSH key on the bhyve VM hosting the Rancher docker container and then tried both of these options:

  1. Mounting the SSH key inside the rancher docker container
  2. Adding the SSH key to the SSH agent in the bhyve VM and recreated the rancher docker container with the following arguments: -v $SSH_AUTH_SOCK:$SSH_AUTH_SOCK -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK so that the rancher docker container could access the SSH key via the SSH agent.

With option 1 I was able to see the SSH key when I exec into the docker container but the machine driver still couldn't access the key because Rancher runs the machine driver inside a jail and the jail doesn't have access to the SSH key path (https://forums.rancher.com/t/how-to-pass-ssh-key-to-custom-node-driver/37325).

With option 2 I was able to see the SSH key when I ran ssh-add -l from inside the rancher docker container and I could also echo $SSH_AUTH_SOCK and see that it’s set but $SSH_AUTH_SOCK was still not accessible to the machine driver since Rancher runs it in a jail. I also tried setting ssh_agent_auth: true with no luck.

Since I was unsuccessful in giving the machine driver access to the SSH key via a file path I decided to modify the driver and add a new optional -triton-key-material argument that accepts a base64 encoded private key string. I looked at the other driver implementations that ship with Rancher such as digitialocean and amazonec2 and it seems that most of them accept strings such as AccessKey and SecretKey rather than a path to a SSH key. Since Triton's CloudAPI requires requests to be signed with a SSH key then it seems that's the only credential needed/available so having the ability to pass that to the machine driver as a string rather than a file path seems advantageous and more inline with how the other drivers work.

Once I modified the machine driver and added it as a custom node driver in the Rancher UI I created a new node template with my base64 encoded private key and then Rancher was able to successfully provision new nodes (Triton bhyve VMs) without issue.

In addition to passing in the base64 encoded private key I also had to add code to wait for the IP to be available so that Rancher doesn't try to SSH into the node until it has all the necessary info.

I'm open to suggestions on improving what I've done but so far this works without issue.

vrcis@f2125d5

Remove old Joyent Go libraries in favor of triton-go

There are several dependencies that need to be removed in favor of triton-go.

Go engineers at Joyent are centralizing tools around our new SDK with the hope of expiring the old libraries. There are examples of using triton-go in the repo and/or I can help with any part of it. If something doesn't map over please let us know.

  • github.com/joyent/gocommon/client
  • github.com/joyent/gosdc/cloudapi
  • github.com/joyent/gosign/auth

Also, I would have done this myself but I'm not entirely certain of how this project is being distributed or how I can test it (?). A README.md would be nice.

Support passing in raw ssh key

I'm attempting to use the Triton driver with Rancher.

Rancher runs the docker-machine command on the server side, this requires uploading the Triton ssh key to the server before hand and referencing the key path in the Rancher UI.

I'm looking to add support for passing in the raw ssh key so adding a machine can happen all within the Rancher UI.

Before I started the changes I wanted to get opinions on the approach.

We could create a new flag, --triton-key-material
or
We could overload the current flag --triton-key-path

By overload I mean we could try to interpret the triton-key-path as a file path first, if that fails we could assume the contents is a raw ssh key.

Thoughts?

docker-machine Cannot connect to the docker engine endpoint (centos-7)

docker-machine works fine with debian, but when creating a centos machine, it throws an error about not being able to connect to docker engine endpoint.

$ docker-machine create -d "triton" --triton-image "debian-8" --triton-key-path ".ssh/id_rsa" --triton-package "k4-highcpu-kvm-1.75G" --engine-install-url "https://releases.rancher.com/install-docker/1.12.sh" testingdriverwithdebian8
Running pre-create checks...
(testingdriverwithdebian8) resolved image "debian-8" to "a55d245e-1e14-11e7-a248-63e9c9423280" (most recent of 15 name matches)
Creating machine...
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 debian...
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 testingdriverwithdebian8

$ docker-machine create -d "triton" --triton-image "centos-7@20170327" --triton-key-path ".ssh/id_rsa" --triton-package "k4-highcpu-kvm-1.75G" --engine-install-url "https://releases.rancher.com/install-docker/1.12.sh" testingdriverwithcentos7
Running pre-create checks...
(testingdriverwithcentos7) resolved image "centos-7@20170327" to "66d919a8-132a-11e7-a7b8-5b99fa122880" (exact name match)
Creating machine...
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 centos...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Error creating machine: Error checking the host: Error checking and/or regenerating the certs: There was an error validating certificates for host "72.2.115.48:2376": dial tcp 72.2.115.48:2376: getsockopt: connection refused
You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'.
Be advised that this will trigger a Docker daemon restart which might stop running containers.

$ docker-machine regenerate-certs testingdriverwithcentos7
Regenerate TLS machine certs?  Warning: this is irreversible. (y/n): y
Regenerating TLS certificates
Waiting for SSH to be available...
Detecting the provisioner...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...

$ docker-machine ls
NAME                       ACTIVE   DRIVER   STATE     URL                          SWARM   DOCKER    ERRORS
testingdriverwithcentos7   -        triton   Running   tcp://165.225.128.163:2376           Unknown   Unable to query docker version: Cannot connect to the docker engine endpoint
testingdriverwithdebian8   -        triton   Running   tcp://165.225.139.41:2376            v1.12.6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.