Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emerleite/tsuru-bluegreen
A blue-green deployment plugin for tsuru client
https://github.com/emerleite/tsuru-bluegreen
Last synced: 3 months ago
JSON representation
A blue-green deployment plugin for tsuru client
- Host: GitHub
- URL: https://github.com/emerleite/tsuru-bluegreen
- Owner: emerleite
- License: mit
- Created: 2014-08-26T13:12:56.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2021-07-28T13:59:50.000Z (almost 3 years ago)
- Last Synced: 2023-04-17T11:06:14.526Z (about 1 year ago)
- Language: Python
- Size: 104 KB
- Stars: 32
- Watchers: 52
- Forks: 11
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- License: LICENSE
Lists
- awesome-tsuru - tsuru-bluegreen - A blue-green deployment plugin for tsuru client (Extensions / Plugins)
README
# tsuru-bluegreen [![Build Status](https://travis-ci.org/emerleite/tsuru-bluegreen.svg?branch=master)](https://travis-ci.org/emerleite/tsuru-bluegreen)
A blue-green deployment plugin for tsuru client
## Dependencies
Python 2.7
## Installation
```
tsuru plugin-install bluegreen https://raw.githubusercontent.com/emerleite/tsuru-bluegreen/1.4.4/src/bluegreen.py
```## Deployment methods
By default, the plugin deploys using `git push`. But if you define a `deploy_dir` key, inside the `Application` section of the configuration file, it uses `tsuru app-deploy` command instead.
## Configuration
Tsuru bluegreen uses convention over configuration. It assumes your application backend is named using blue and green sufixes, as explained bellow:
Create a **tsuru-bluegreen.ini** in your application root with the following configuration:
```
[Application]
name:
deploy_dir: <./build> <./build2>[NewRelic]
api_key:
app_id:[Grafana]
endpoint:
index:[WebHook]
endpoint: http://example.com
payload_extras: key1=value1&key2=value2[Hooks]
before_pre:
after_pre:
before_swap:
after_swap:[UnitsRemoval]
retry_times: 20
retry_sleep: 10
```**Note:** if a NewRelic key's value is left blank, the plugin will try to get it from an environment variable (`NEW_RELIC_API_KEY` or `NEW_RELIC_APP_ID`).
### 'Application' section
Based on the `name` configuration value, you must have to have two tsuru applications and git remotes named: your_app**-blue** and your_app**-green**.
The `deploy_dir` configuration value is used with the `--app-deploy` flag. The default value is `.`.
### 'NewRelic' section
Notify New Relic about your deployment after swap. See [NewRelic docs](https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/deployment-notifications).
### 'Grafana' section
Notify Grafana about your deployment after swap. See [Grafana docs](http://docs.grafana.org/reference/annotations/).
### 'WebHook' section
POST to a **WebHook** after deployment swap. The payload is the defined payload_extras plus **tag=**.
### 'Hooks' section
Hooks are optional. They are ran before or after the corresponding actions, and everything sent to stdout and stderr is ignored. **If a before hook fails (return value isn't zero), the action (pre/swap) is cancelled.** If you want to run the pre/swap action independently of the before hook execution, you need to make sure it always returns `0`.
Hooks must run inside a shell. If you want to run a `curl` command, for instance, you should do it inside a shell script:
```
$ cat script.sh
#! /bin/sh
curl http://example.com$ cat tsuru-bluegreen.ini
[Application]
name: test[Hooks]
before_pre: ./script.sh$ tsuru bluegreen pre -t some-tag
```In this case, if `curl` command fails, the `pre` action will be
cancelled.### 'UnitsRemoval' section
There's an issue when performing the swap of an app with multiple units.
After the first unit is removed, errors are encountered when trying to
remove the remaining processes.According to [tsuru](https://github.com/tsuru/tsuru) contributors,
this behavior is most likely do to the project's internal lock scheme.This section defines how many times the plugin is going to retry
removing a unit and how much time will it wait between tries. For
example, to tell `bluegreen` to retry removing a unit twenty (20)
times and to wait ten (10) seconds between each try, write this to you
`.ini` fiel:```
[UnitsRemoval]
retry_times: 20
retry_sleep: 10
```> **Note:** experimentation showed that small values for `retry_sleep`
> and large values for `retry_times` yields better usability.## Example
```
$ tsuru app-list+---------------+-------------------------+---------------------------------------------------+--------+
| Application | Units State Summary | Address | Ready? |
+---------------+-------------------------+---------------------------------------------------+--------+
| sample-blue | 4 of 4 units in-service | sample.example.com, sample-blue.cloud.example.com | Yes |
| sample-green | 0 of 0 units in-service | sample-green.cloud.globoi.com | Yes |
+---------------+-------------------------+---------------------------------------------------+--------+
``````
$ git remotesample-blue
sample-green```
## Usage
```
tsuru bluegreen --helpusage: tsuru bluegreen action [options]
Tsuru blue-green deployment (pre and live).
positional arguments:
action pre or swapoptional arguments:
-h, --help show this help message and exit
-t [TAG], --tag [TAG] Tag to be deployed (default: master)
```## Tests
```
$ make testdeps
$ make test
```Or, if you wish to use Docker;
```
$ make docker-test
```