empire

module
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2015 License: BSD-2-Clause

README

Empire

Empire is a control layer on top of Amazon EC2 Container Service (ECS) that provides a Heroku like workflow. It conforms to a subset of the Heroku Platform API, which means you can use the same tools and processes that you use with Heroku, but with all the power of EC2 and Docker.

Empire is targeted at small to medium sized startups that are running a large number of microservices and need more flexibility than what Heroku provides.

Quickstart

To use Empire, you'll need to have an ECS cluster running. See the quickstart guide for more information.

Architecture

Empire aims to make it trivially easy to deploy a container based microservices architecture, without all of the complexities of managing systems like Mesos or Kubernetes. ECS takes care of much of that work, but lacks a convenient interface for performing common administrative tasks like deploying new versions, scaling and updating configuration. This is where Empire comes in, allowing you to deploy Docker images as easily as:

$ emp deploy remind101/acme-inc:latest
Heroku API compatibility

Empire supports a subset of the Heroku Platform API, which means any tool that uses the Heroku API can probably be used with Empire, if the endpoint is supported.

As an example, you can use the hk CLI with Empire like this:

$ HEROKU_API_URL=<empire_url> hk ...

However, the best user experience will be by using the emp command, which is a fork of hk with Empire specific features.

Routing

Empire's routing layer is backed by internal ELB's. Any application that specifies a web process will get an internal ELB attached to it's associated ECS Service. When a new version of the app is deployed, ECS manages spinning up the new versions of the process, waiting for old connections to drain, then killing the old release.

When a new internal ELB is created, an associated CNAME record will be created in Route53 under the internal TLD, which means you can use DNS for service discovery. If we deploy an app named feed then it will be available at http://feed within the ECS cluster.

Apps default to only being exposed internally, unless you add a custom domain to them. Adding a custom domain will create a new external ELB for the ECS service.

Deploying

Any tagged Docker image can be deployed to Empire as an app. Empire doesn't enforce how you tag your Docker images, but we recommend tagging the image with the git sha that it was built from, and deploying that. We have a tool for performing deployments called Tugboat that supports deploying Docker images to empire.

When you deploy a Docker image to Empire, it will extract a Procfile from the WORKDIR. Like Heroku, you can specify different process types that compose your service (e.g. web and worker), and scale them individually. Each process type in the Procfile maps directly to an ECS Service.

Caveats

Because docker run does not exec commands within a shell, commands specified within the Procfile will also not be exec'd within a shell. This means that you cannot specify environment variables in the Procfile. The following is not valid:

web: acme-inc server -port=$PORT

If you need to specify environment variables as part of the command, we recommend splitting out your Procfile commands into small bash shims instead:

web: ./bin/web
#!/bin/bash

set -e

exec acme-inc server -port=$PORT

Tests

Unit tests live alongside each go file as _test.go.

There is also a tests directory that contains integration and functional tests that tests the system using the heroku-go client and the hk command.

To get started, run:

$ make bootstrap

To run the tests:

$ godep go test ./...

Development

If you want to contribute to empire, you may end up wanting to run a local instance against an ECS cluster. Doing this is relatively easy:

  1. Ensure that you have the AWS CLI installed and configured.

  2. Ensure that you accepted the terms and conditions for the official ECS AMI:

    https://aws.amazon.com/marketplace/ordering?productId=4ce33fd9-63ff-4f35-8d3a-939b641f1931&ref_=dtl_psb_continue&region=us-east-1

    Also check that the offical ECS AMI ID for US East matches with the one in cloudformation.json: https://github.com/remind101/empire/blob/master/docs/guide/cloudformation.json#L20

  3. Run boot2docker and export the environment variables so empire can connect:

    $ boot2docker start
    $ $(boot2docker shellinit)
    

    You should ensure that you've configured boot2docker to disable TLS. Refer to https://coderwall.com/p/siqnjg/disable-tls-on-boot2docker.

  4. Run the bootstrap script, which will create a cloudformation stack, ecs cluster and populate a .env file:

    $ ./bin/bootstrap
    
  5. Run empire with docker-compose:

    $ docker-compose up
    
  6. Install the emp CLI.

    $ go get -u github.com/remind101/emp
    

Empire will be available at http://$(boot2docker ip):8080 and you can point the CLI there.

$ export EMPIRE_API_URL=http://$(boot2docker ip):8080
$ emp deploy remind101/acme-inc

If you run into problems with authentication, ensure that the hk client you're using is built from the master branch of github.com/heroku/hk.

Directories

Path Synopsis
Godeps/_workspace/src/code.google.com/p/go-uuid/uuid
The uuid package generates and inspects UUIDs.
The uuid package generates and inspects UUIDs.
Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws
Package aws provides core functionality for making requests to AWS services.
Package aws provides core functionality for making requests to AWS services.
Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awserr
Package awserr represents API error interface accessors for the SDK.
Package awserr represents API error interface accessors for the SDK.
Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials
Package credentials provides credential retrieval and management The Credentials is the primary method of getting access to and managing credentials Values.
Package credentials provides credential retrieval and management The Credentials is the primary method of getting access to and managing credentials Values.
Godeps/_workspace/src/github.com/aws/aws-sdk-go/internal/apierr
Package apierr represents API error types.
Package apierr represents API error types.
Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/ecs
Package ecs provides a client for Amazon EC2 Container Service.
Package ecs provides a client for Amazon EC2 Container Service.
Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/ecs/ecsiface
Package ecsiface provides an interface for the Amazon EC2 Container Service.
Package ecsiface provides an interface for the Amazon EC2 Container Service.
Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/elb
Package elb provides a client for Elastic Load Balancing.
Package elb provides a client for Elastic Load Balancing.
Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/elb/elbiface
Package elbiface provides an interface for the Elastic Load Balancing.
Package elbiface provides an interface for the Elastic Load Balancing.
Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/iam
Package iam provides a client for AWS Identity and Access Management.
Package iam provides a client for AWS Identity and Access Management.
Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/iam/iamiface
Package iamiface provides an interface for the AWS Identity and Access Management.
Package iamiface provides an interface for the AWS Identity and Access Management.
Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/route53
Package route53 provides a client for Amazon Route 53.
Package route53 provides a client for Amazon Route 53.
Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/route53/route53iface
Package route53iface provides an interface for the Amazon Route 53.
Package route53iface provides an interface for the Amazon Route 53.
Godeps/_workspace/src/github.com/bgentry/heroku-go
Package heroku is a client interface to the Heroku API.
Package heroku is a client interface to the Heroku API.
Godeps/_workspace/src/github.com/codegangsta/cli
Package cli provides a minimal framework for creating and organizing command line Go applications.
Package cli provides a minimal framework for creating and organizing command line Go applications.
Godeps/_workspace/src/github.com/dgrijalva/jwt-go
Package jwt is a Go implementation of JSON Web Tokens: http://self-issued.info/docs/draft-jones-json-web-token.html See README.md for more info.
Package jwt is a Go implementation of JSON Web Tokens: http://self-issued.info/docs/draft-jones-json-web-token.html See README.md for more info.
A useful example app.
Godeps/_workspace/src/github.com/docker/docker/pkg/pools
Package pools provides a collection of pools which provide various data types with buffers.
Package pools provides a collection of pools which provide various data types with buffers.
Godeps/_workspace/src/github.com/fsouza/go-dockerclient
Package docker provides a client for the Docker remote API.
Package docker provides a client for the Docker remote API.
Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing
Package testing provides a fake implementation of the Docker API, useful for testing purpose.
Package testing provides a fake implementation of the Docker API, useful for testing purpose.
Godeps/_workspace/src/github.com/go-sql-driver/mysql
Go MySQL Driver - A MySQL-Driver for Go's database/sql package The driver should be used via the database/sql package: import "database/sql" import _ "github.com/go-sql-driver/mysql" db, err := sql.Open("mysql", "user:password@/dbname") See https://github.com/go-sql-driver/mysql#usage for details
Go MySQL Driver - A MySQL-Driver for Go's database/sql package The driver should be used via the database/sql package: import "database/sql" import _ "github.com/go-sql-driver/mysql" db, err := sql.Open("mysql", "user:password@/dbname") See https://github.com/go-sql-driver/mysql#usage for details
Godeps/_workspace/src/github.com/gocql/gocql
Package gocql implements a fast and robust Cassandra driver for the Go programming language.
Package gocql implements a fast and robust Cassandra driver for the Go programming language.
Godeps/_workspace/src/github.com/golang/groupcache/lru
Package lru implements an LRU cache.
Package lru implements an LRU cache.
Godeps/_workspace/src/github.com/golang/snappy/snappy
Package snappy implements the snappy block-based compression format.
Package snappy implements the snappy block-based compression format.
Godeps/_workspace/src/github.com/gorilla/context
Package context stores values shared during a request lifetime.
Package context stores values shared during a request lifetime.
Godeps/_workspace/src/github.com/gorilla/mux
Package gorilla/mux implements a request router and dispatcher.
Package gorilla/mux implements a request router and dispatcher.
Godeps/_workspace/src/github.com/inconshreveable/log15
Package log15 provides an opinionated, simple toolkit for best-practice logging that is both human and machine readable.
Package log15 provides an opinionated, simple toolkit for best-practice logging that is both human and machine readable.
Godeps/_workspace/src/github.com/inconshreveable/log15/stack
Package stack implements utilities to capture, manipulate, and format call stacks.
Package stack implements utilities to capture, manipulate, and format call stacks.
Godeps/_workspace/src/github.com/lib/pq
Package pq is a pure Go Postgres driver for the database/sql package.
Package pq is a pure Go Postgres driver for the database/sql package.
Godeps/_workspace/src/github.com/lib/pq/listen_example
Below you will find a self-contained Go program which uses the LISTEN / NOTIFY mechanism to avoid polling the database while waiting for more work to arrive.
Below you will find a self-contained Go program which uses the LISTEN / NOTIFY mechanism to avoid polling the database while waiting for more work to arrive.
Godeps/_workspace/src/github.com/lib/pq/oid
Package oid contains OID constants as defined by the Postgres server.
Package oid contains OID constants as defined by the Postgres server.
Godeps/_workspace/src/github.com/mattes/migrate/driver
Package driver holds the driver interface.
Package driver holds the driver interface.
Godeps/_workspace/src/github.com/mattes/migrate/driver/bash
Package bash implements the Driver interface.
Package bash implements the Driver interface.
Godeps/_workspace/src/github.com/mattes/migrate/driver/cassandra
Package cassandra implements the Driver interface.
Package cassandra implements the Driver interface.
Godeps/_workspace/src/github.com/mattes/migrate/driver/mysql
Package mysql implements the Driver interface.
Package mysql implements the Driver interface.
Godeps/_workspace/src/github.com/mattes/migrate/driver/postgres
Package postgres implements the Driver interface.
Package postgres implements the Driver interface.
Godeps/_workspace/src/github.com/mattes/migrate/file
Package file contains functions for low-level migration files handling.
Package file contains functions for low-level migration files handling.
Godeps/_workspace/src/github.com/mattes/migrate/migrate
Package migrate is imported by other Go code.
Package migrate is imported by other Go code.
Godeps/_workspace/src/github.com/mattes/migrate/migrate/direction
Package direction just holds convenience constants for Up and Down migrations.
Package direction just holds convenience constants for Up and Down migrations.
Godeps/_workspace/src/github.com/mattes/migrate/pipe
Package pipe has functions for pipe channel handling.
Package pipe has functions for pipe channel handling.
Godeps/_workspace/src/github.com/remind101/newrelic
No op implementation for non linux platforms (new relix agent sdk only support linux right now)
No op implementation for non linux platforms (new relix agent sdk only support linux right now)
Godeps/_workspace/src/github.com/remind101/pkg/httpx
package httpx provides an extra layer of convenience over package http.
package httpx provides an extra layer of convenience over package http.
Godeps/_workspace/src/github.com/remind101/pkg/logger
package logger is a package that provides a structured logger that's context.Context aware.
package logger is a package that provides a structured logger that's context.Context aware.
Godeps/_workspace/src/github.com/remind101/pkg/reporter
package reporter provides a context.Context aware abstraction for shuttling errors and panics to third partys.
package reporter provides a context.Context aware abstraction for shuttling errors and panics to third partys.
Godeps/_workspace/src/github.com/remind101/pkg/reporter/hb
package hb is a Go package from sending errors to Honeybadger.
package hb is a Go package from sending errors to Honeybadger.
Godeps/_workspace/src/github.com/vaughan0/go-ini
Package ini provides functions for parsing INI configuration files.
Package ini provides functions for parsing INI configuration files.
Godeps/_workspace/src/golang.org/x/net/context
Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.
Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.
Godeps/_workspace/src/gopkg.in/yaml.v2
Package yaml implements YAML support for the Go language.
Package yaml implements YAML support for the Go language.
Godeps/_workspace/src/speter.net/go/exp/math/dec/inf
Package inf (type inf.Dec) implements "infinite-precision" decimal arithmetic.
Package inf (type inf.Dec) implements "infinite-precision" decimal arithmetic.
pkg/arn
package arn is a Go package for parsing Amazon Resource Names.
package arn is a Go package for parsing Amazon Resource Names.
pkg/bytesize
package bytesize contains constants for easily switching between different byte sizes.
package bytesize contains constants for easily switching between different byte sizes.
pkg/constraints
package constraints contains methods for decoding a compact CPU and Memory constraints format.
package constraints contains methods for decoding a compact CPU and Memory constraints format.
pkg/ecsutil
Package ecsutil is a layer on top of Amazon ECS to provide an app aware ECS client.
Package ecsutil is a layer on top of Amazon ECS to provide an app aware ECS client.
pkg/lb
package lb provides an abstraction around creating load balancers.
package lb provides an abstraction around creating load balancers.
pkg/service
A Go package that provides a layer of abstraction above ECS to introduce the concept of Apps, which have are a collection of services.
A Go package that provides a layer of abstraction above ECS to introduce the concept of Apps, which have are a collection of services.
Godeps/_workspace/src/code.google.com/p/go-uuid/uuid
The uuid package generates and inspects UUIDs.
The uuid package generates and inspects UUIDs.
Godeps/_workspace/src/github.com/codegangsta/cli
Package cli provides a minimal framework for creating and organizing command line Go applications.
Package cli provides a minimal framework for creating and organizing command line Go applications.
Godeps/_workspace/src/github.com/docker/docker/pkg/pools
Package pools provides a collection of pools which provide various data types with buffers.
Package pools provides a collection of pools which provide various data types with buffers.
Godeps/_workspace/src/github.com/fsouza/go-dockerclient
Package docker provides a client for the Docker remote API.
Package docker provides a client for the Docker remote API.
Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing
Package testing provides a fake implementation of the Docker API, useful for testing purpose.
Package testing provides a fake implementation of the Docker API, useful for testing purpose.
Godeps/_workspace/src/github.com/gorilla/context
Package context stores values shared during a request lifetime.
Package context stores values shared during a request lifetime.
Godeps/_workspace/src/github.com/gorilla/mux
Package gorilla/mux implements a request router and dispatcher.
Package gorilla/mux implements a request router and dispatcher.
Godeps/_workspace/src/github.com/remind101/pkg/httpx
package httpx provides an extra layer of convenience over package http.
package httpx provides an extra layer of convenience over package http.
Godeps/_workspace/src/github.com/remind101/pkg/logger
package logger is a package that provides a structured logger that's context.Context aware.
package logger is a package that provides a structured logger that's context.Context aware.
Godeps/_workspace/src/github.com/remind101/pkg/reporter
package reporter provides a context.Context aware abstraction for shuttling errors and panics to third partys.
package reporter provides a context.Context aware abstraction for shuttling errors and panics to third partys.
Godeps/_workspace/src/github.com/remind101/pkg/reporter/hb
package hb is a Go package from sending errors to Honeybadger.
package hb is a Go package from sending errors to Honeybadger.
Godeps/_workspace/src/golang.org/x/net/context
Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.
Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.
tcp

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL