mmihira / gec2

EC2 deploy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gec2

GEC2 is a lightweight tool to provision EC2 nodes on an AWS compatible Elatic Compute service provider. The default way to run Gec2 is to build the docker image and run in a docker container.

Configuration

Currently AmazonAWS and NeCTAR are supported. EC2 nodes are specified in a yaml file like:

provider: "AWS"
nodes:
   - node1:
       ami: "ami-e686e12c"
       type: "m1.medium"
       placement: "ap-southeast-2a"
       keyname: "sshkey"
       security_groups:
         - "ssh"
       roles:
         - "init"

roles: ["init"]

Furthermore roles can be assigned to nodes. Roles are post deployment instructions which are run against nodes.

Roles are defined in a roles.yaml file and look like this:

init:
  steps:
    - stepType: "script"
      scripts:
        - "roles/init/run.sh"

There are three types of steps available:

  • script Run a script on the server
  • copy Copy a file from the docker context to the node
  • template Template a file and then copy it to the node

All filenames are resolved relative to the context folder specified on startup. When the nodes are provisioned a file called deployed_schema.json is created in the context which looks like :

{
  "node1": {
    "name": "node1",
    "keyname": "somesshkey",
    "roles": [
      "init",
    ],
    "ip": "34.xxx.xx.xxx"
  }
}

This data structure can be used in templating using golang template syntax: https://golang.org/pkg/text/template/

See the examples folders for an example.

Installating and running

First build this image

  git clone https://github.com/mmihra/gec2
  cd gec2
  ./docker_build.sh

Or pull the latest version from dockerhub

  docker pull mmihira/gec2:1.1

Then run using the provided script

./scripts/run.sh -c=<AWS_CREDENTIALS_PATH> -r=<REGION> -l=<CONTEXT_FOLDER> -s=<SSH_KEY_PATH> --roles=<PATH_TO_ROLES> --logs=<PATH_TO_LOGS>

AWS_CREDENTIALS_PATH must be the path to you AWS (or NeCTAR) credentails file which looks like:

[default]
aws_access_key_id = <>
aws_secret_access_key = <>
region = <>

SSH_KEY_PATH the path to the ssh key for access to the nodes.
The use of only one key is supported at this time

  • The context foler should be a folder with at a minimum these files:
    • config.yaml
  • The roles folder should be a folder with the roles
  • The log folder is where deploy logs are written to

Available run modes

  • listImages List all the available images
  • provision Provision the nodes don't run any roles
  • cmd Run a specific command on a specific node

cmd -a

It's possible to run a script with args passed to the script: `-s cmd -r -a=

Tests

Run go test -v ./...

About

EC2 deploy

License:Apache License 2.0


Languages

Language:Go 96.2%Language:Shell 2.4%Language:Dockerfile 1.4%