BlueGreen deployments (starting with Docker on AWS). This is a highly opinionated framework for deploying Docker containers onto AWS.
Initially, we are targeting Elastic Beanstalk multi-container Docker deployments in an autoscale group. Furthermore, this is designed to target the Web Application profile in an autoscale group with accompanying Elastic Load Balancer.
The Blue-Green environments are swapped by adding/removing the Elastic Beanstalks ELB instance from a global ELB instance (representing the entry point of the application).
In the future, I'd like to migrate this to ECS. Keep in mind, this represents my current workflow and will mature when I change that workflow or find free time to expand it's functionality.
Service
: is a unit of management for an independent service-providing entity. Typically a single application, like a Node.js web server, but it can also be something like multiple Docker containers that are always deployed together. These are the core of what BlueGreen manages.
Version
: each service has zero or more deployable Versions. A large part of the BlueGreen workflow is specifying what version should be deployed to a target Environment, and whether it should be accessible to a specific Gateway. The default implementation of versions is an Elastic Beanstalk Docker deployment as an Application Version. This implies two subphases of version creation:
Build
: build a codebase. The default action is to build a Docker image.Push
: push the deployment artifacts to a remote repositories. The default action is to push a Docker image to a Docker repository.
Environments
: where Versions of your Services get deployed. By default, we use blue
and green
, because conceptually, that's the whole point of this framework. However, we aren't so unimaginative that we don't realize you might also want to deploy to test
or qa
.
Gateways
: these are where your customers (or other services) access your Services. In BlueGreen, this could simply be a CNAME swap in DNS, or the attaching of an Environment
to a load balancer.
Modes of Operation
The BlueGreen toolchain can be used within the directory of a configured codebase or from any directory in your shell. This is similar to tools like Vagrant
. Some commands are only designed to work within a codebase (like creating a new version), while the majority of commands can be operating from anywhere in a shell (like listing model constructs, or modifying entities from resources external to the local machine).
Help
bluegreen help
Get overall Statuses of services an environments
bluegreen ps
List Services
bluegreen services
Create a new service
bluegreen create service <service>
bluegreen create service www
Teardown a service
bluegreen teardown service <service>
bluegreen teardown service www
List all environments (regardless of service)
bluegreen environments
List available Environments of a Service
bluegreen <service> environments
bluegreen www environments
Create an environment
bluegreen <service> create environment <environment>
bluegreen www create environment test
Teardown an Environment
bluegreen <service> teardown environment <environment>
bluegreen www teardown environment test
List available Versions of a Service
bluegreen <service> versions
bluegreen www versions
Create a new Version of a Service
bluegreen <service> create version <version>
bluegreen www create version
bluegreen www create version 0.3.2
Deploy a Version of a Service to an Environment
bluegreen <service> deploy <version> to <environment>
bluegreen www deploy 0.3.2 to blue
Delete a Version of a Service
bluegreen <service> delete version <version>
bluegreen www delete version 0.3.1
List all available Gateways
bluegreen gateways
List all available Gateways for a service
bluegreen <service> gateways
bluegreen www gateways
Create a Gateway (and attach to environment)
bluegreen <service> create gateway <name>
bluegreen www create gateway production
Teardown a Gateway
bluegreen <service> teardown gateway <name>
bluegreen www teardown gateway production
Swap the Gateways of two environments. If you are using CNAMEs as your Gateway, this
will just switch blue
to green
's record, and vice versa.
bluegreen <service> swap [blue] [green]
bluegreen www swap blue green
Attach an environment to a Gateway. If the Gateway is something simple (like a CNAME), this
may simply mean "detach the current environment, and use the new one". If it's a load balancer,
it will attach both environments to the same load balancer (you might want this for a smoke test). If you want to detach the old environment and attach the new one, use swap
.
bluegreen <service> attach <environment> to <gateway>
bluereen www attach blue to production
Detach an environment from a Gateway.
bluegreen <service> detach <environment> from <gateway>
bluegreen www detach blue from production
bluegreen debug:create-version