A cross platform service that synchronises the set of applications installed on a machine with a manifest stored in a Consul key value store.
See this Overview for more information about what exactly the CDA does.
consul-deployment-agent installs applications packaged in the AWS CodeDeploy revision format. This is a .zip file containing your code and an appspec.yml file that describes how to install the application.
consul-deployment-agent supports the following subset of the deployment lifecycle hooks:
- BeforeInstall
- AfterInstall
- StartApplication
- ValidateService
consul-deployment-agent sets the following variables in the hook script execution environment
| Variable | Value |
|---|---|
| APPLICATION_ID | ? |
| DEPLOYMENT_BASE_DIR | ? |
| DEPLOYMENT_ID | Environment Manager deployment ID for this application installation |
| LIFECYCLE_EVENT | The name of the currently executing lifecycle event. One of BeforeInstall, AfterInstall, StartApplication, ValidateService |
| EM_SERVICE_SLICE | The slice the service is being installed to. One of blue, green, none |
| EM_SERVICE_NAME | The name of the service being installed |
| EM_SERVICE_PORT | The port on which the service should listen |
| EM_SERVICE_VERSION | The version of the service being installed |
$ python agent/core.py -h usage: core.py [-h] [-config-dir CONFIG_DIR] [-v] optional arguments: -h, --help show this help message and exit -config-dir CONFIG_DIR Location of configuration files (e.g. config.yml and config-logging.yml) -v, --version show program's version number and exitDeployment agent supports multiple configuration files. The agent will look for configuration files in the same directory as the executable.
| Filename | Description | Example |
|---|---|---|
| config-logging.yml | (optional) Python logging module configuration. If not specified, logs will be sent to stdout with level set to DEBUG. | [sample-config-logging.yml] (https://github.thetrainline.com/PlatformServices/consul-deployment-agent/blob/master/config/sample-config-logging.yml) |
| config.yml | (optional) Various configuration settings. See example for supported options. | [sample-config.yml] (https://github.thetrainline.com/PlatformServices/consul-deployment-agent/blob/master/config/sample-config.yml) |
Please make sure you have downloaded and setup the following first. You might also need to update your path environment variables for this to work.
If you are checking this out for the first time you will need to make sure that you have setup your PYTHONPATH environment variable.
For example if you have checked out this project to:
C:\code\consul-deployment-agent OR
~/code/consul-deployment-agent Then you would need to make sure you set this exact path as a value.
For windows:
SET PYTHONPATH=C:\code\consul-deployment-agent For linux:
export PYTHONPATH=~/code/consul-deployment-agent First, initialise the dependencies by running:
sudo make initStart Consul agent in development mode:
consul agent -devTo start the deployment agent:
python agent/core.pyRunning the tests:
sudo make init-test make testFirst, initialise the dependencies by running:
pip install -r requirements.txtStart Consul agent in development mode:
consul agent -dev -advertise=127.0.0.1Start the deployment agent:
python agent/core.pyRunning the tests:
pip install -r test-requirements.txt nosetests --verbosity=2 testsFollow these steps to perform a deployment simulation:
- Upload a deployment package to tl-deployment-sandbox S3 bucket in the Sandbox account
- Start Consul agent as per instructions above.
- Start Consul deployment agent as per instructions above.
- Run the following script to trigger the deployment:
./scripts/deploy_service.py -n <service_name> -p <service_port> -v <version> -s <slice_name> -t <environment_type> -c <cluster_name> -b tl-deployment-sandbox -k <s3_object_key>