|
1 |
| -OpenShift Binary Deployment Solution |
2 |
| -==================================== |
3 |
| -This is an external solution to allow deploying binary artifacts to OpenShift applications without the need to use git. It consists of a single command line script called "deploy" that performs the following actions: |
| 1 | +# OpenShift Binary Deployment Solution |
| 2 | + |
| 3 | +## Background & Motivation |
| 4 | +OpenShift currently only supports deploying updated code for an application via git. When you commit and push code to your application's OpenShift git repository, OpenShift takes care of doing everything necessary to deploy your latest changes. |
| 5 | + |
| 6 | +If you have a scalable application, a `git push` will result in your latest changes being copied to all the gears that make up your application. Features such as rolling deployments and rollback have not yet been implemented in OpenShift, and this tooling attempts to provide these features. |
| 7 | + |
| 8 | +This is an external solution to allow deploying binary artifacts to OpenShift applications without the need to use git. It consists of a single command line script called "deploy" that performs several actions, described below. |
| 9 | + |
| 10 | +But first, some information on binary artifacts and what they are. |
| 11 | + |
| 12 | +## Binary Artifacts |
| 13 | +Binary artifacts are compressed tar files (.tar.gz). They contain everything you would expect to see in a normal OpenShift application: |
| 14 | + |
| 15 | +- .openshift directory (including .openshift/actions_hooks/user_prepare, if desired) |
| 16 | +- application code |
| 17 | + |
| 18 | +**NOTE**: If your artifact is Java-based, make sure it includes the precompiled/packaged output (e.g. a .war file) in the deployments directory, as this tooling will **NOT** run the build hook. |
| 19 | + |
| 20 | +Prior to executing the commands below, create a binary artifact and upload it to a web server (e.g., for Java-based deployments, deploying your artifacts to a Maven repository server such as Nexus or Artifactory is a good option). |
| 21 | + |
| 22 | +# Usage |
| 23 | +## Init |
| 24 | +Usage: `deploy init APP` |
| 25 | + |
| 26 | +Initializes the application to be able to use this tooling. This action will copy the supporting scripts to the application's head gear and initialize the gear for binary deployments. |
4 | 27 |
|
5 | 28 | ## Prepare
|
6 |
| -Downloads the binary artifact from an external location and prepares it for deployment using this tooling. The prepare action invokes a script called `user_prepare` that is responsible for downloading the artifact to a temporary location (e.g. /tmp/somefile.tgz) and reporting the file's location and sha1 checksum back to the prepare action. |
| 29 | +Usage: `deploy prepare APP ARTIFACT_URL` |
7 | 30 |
|
8 |
| -Currently, `user_prepare` must be colocated with the scripts in the gear directory. A sample user_prepare script is provided. |
| 31 | +Downloads a binary artifact from an external location and prepares it for deployment using this tooling. After downloading the artifact, the prepare action extracts .openshift/action_hooks/user_prepare from the artifact and invokes it, if it exists. The `user_prepare` script may perform operations such as downloading environment specific files and incorporating them into the artifact (since typically you want your artifacts to be able to be deployed to development, testing, staging, and production environments without having to make any changes to them). |
9 | 32 |
|
10 | 33 | When this action finishes, it returns the sha1 checksum to the user, who must then use that to identify which artifact to distribute and activate.
|
11 | 34 |
|
12 | 35 | ## Distribute
|
13 |
| -Distributes the binary artifact to all child gears. |
| 36 | +Usage: `deploy distribute APP CHECKSUM` |
| 37 | + |
| 38 | +Distributes the binary artifact to all child gears of a scalable application. This action is only necessary for scalable applications that have at least 1 child gear. |
14 | 39 |
|
15 | 40 | ## Activate
|
16 |
| -Activates (deploys) the binary artifact to the head gear and all child gears. Deployments using this process are placed in |
| 41 | +Usage: `deploy activate APP CHECKSUM [--dry-run] [--gears GEARS]` |
| 42 | + |
| 43 | +Activates (deploys) the binary artifact to some or all of the gears for the application. Deployments using this process are placed in |
| 44 | + |
| 45 | +`app-root/runtime/user/deployments/[datetime]` |
| 46 | + |
| 47 | +The existing `app-root/runtime/repo` directory is moved aside and is now a symlink to `app-root/runtime/user/deployments/[datetime]/repo`. |
| 48 | + |
| 49 | +### Targeting gears |
| 50 | +Activations can apply to all of an application's gears (the default behavior), or a subset. To operate on a subset of gears, use the `deploy partition` action to divide the application's gears into multiple sets (see below for details on running that action). Once you have your partition files, you can use the `--gears` option to specify the partition file containing the gears you wish to activate. |
| 51 | + |
| 52 | +### Dry runs |
| 53 | +If you want to see if the activation should be able to succeed, without actually performing the activation, you can use the `--dry-run` option to do so. |
| 54 | + |
| 55 | +## Partition |
| 56 | +Usage: `deploy partition APP --output-dir OUTPUT_DIR --counts COUNTS` |
| 57 | + |
| 58 | +This will create 1 or more files containing subsets of gears that can be used as input to the activate and rollback actions. A partition file simply contains the SSH urls of the desired gears, one per line. |
| 59 | + |
| 60 | +The files will be named using the following convention: APP-[parition number]-[total number of partitions]. For example, if the application's name is myapp, and there are 3 total partitions, the files would be named |
| 61 | + |
| 62 | +* myapp-1-3 |
| 63 | +* myapp-2-3 |
| 64 | +* myapp-3-3 |
| 65 | + |
| 66 | +You can specify an `--output-dir` in which all the partition files will be created. |
| 67 | + |
| 68 | +### How to partition |
| 69 | +Currently you create partitions by specifying the number of gears you want in each partition, separated by commas. For example: |
| 70 | + |
| 71 | +`--counts 2,3,4` will create 3 partitions. The first partition will have 2 gears in it, the second partition will have 3 gears in it, and the third partition will have 4 gears in it. |
| 72 | + |
| 73 | +If there are still gears left over after assigning gears to the partitions based on the counts specified, a final partition will be created with all the remaining unassigned gears. For example, if you have 10 gears, and you do `--counts 2`, you will get 2 partition files: 1 with 2 gears, and 1 with 8 gears. |
| 74 | + |
| 75 | +## Rollback |
| 76 | +Usage: `deploy rollback APP [--dry-run] [--gears GEARS]` |
| 77 | + |
| 78 | +Rolls back to the previously deployed version (if it exists). In order for the rollback action to succeed, you need to have deployed at least 2 versions using this tooling. It will not rollback to the original non-binary deployment. |
| 79 | + |
| 80 | +You can use `--dry-run` to see which gears should roll back successfully. |
| 81 | + |
| 82 | +By default, the rollback command applies to all of an application's gears. You can use the `--gears` option to target specific subsets of gears, as described above. |
| 83 | + |
| 84 | +## Status |
| 85 | +Usage: `deploy status APP` |
| 86 | + |
| 87 | +Displays information about all the gears of an application: |
| 88 | + |
| 89 | +* Gear UUID |
| 90 | +* SSH URL |
| 91 | +* Deployed artifact |
| 92 | +* Gear state |
| 93 | + |
| 94 | +Example output: |
| 95 | + |
| 96 | + $ ./deploy status s2 |
| 97 | + Application s2 has 3 gears: |
| 98 | + Gear 51b0dde3a7cfd1abf200006d |
| 99 | + |
| 100 | + Deployed version: myapp-1.0.tar.gz (34e2c81bc295d8b769d9531c44532390d4104705: OK) |
| 101 | + State: started |
| 102 | + |
| 103 | + Gear 51b0e483a7cfd1abf2000092 |
| 104 | + SSH URL: ssh://51b0e483a7cfd1abf2000092@51b0e483a7cfd1abf2000092-agoldstein.example.com |
| 105 | + Deployed version: Unknown; deployment not activated using binary deployment process |
| 106 | + State: stopped |
| 107 | + |
| 108 | + Gear 51b0e665a7cfd1abf20000a5 |
| 109 | + |
| 110 | + Deployed version: myapp-1.0.tar.gz (34e2c81bc295d8b769d9531c44532390d4104705: OK) |
| 111 | + State: started |
| 112 | + |
| 113 | +## Artifacts |
| 114 | +Usage: `deploy artifacts APP` |
| 115 | + |
| 116 | +Displays information about the artifacts distributed to all the gears of an application: |
| 117 | + |
| 118 | +* artifact checksum |
| 119 | +* artifact name |
| 120 | + |
| 121 | +Example output: |
| 122 | + |
| 123 | + $ ./deploy artifacts s2 |
| 124 | + Gear 51b0dde3a7cfd1abf200006d |
| 125 | + 34e2c81bc295d8b769d9531c44532390d4104705: myapp-1.0.tar.gz |
| 126 | + |
| 127 | + Gear 51b0e483a7cfd1abf2000092 |
| 128 | + 34e2c81bc295d8b769d9531c44532390d4104705: myapp-1.0.tar.gz |
| 129 | + |
| 130 | + Gear 51b0e665a7cfd1abf20000a5 |
| 131 | + 34e2c81bc295d8b769d9531c44532390d4104705: myapp-1.0.tar.gz |
| 132 | + |
| 133 | + |
| 134 | +## Deployments |
| 135 | +Usage: `deploy deployments APP` |
| 136 | + |
| 137 | +Displays information about the deployments deployed to all the gears of an application: |
| 138 | + |
| 139 | +* deployment date/time |
| 140 | +* artifact checksum |
| 141 | +* artifact name |
17 | 142 |
|
18 |
| -`app-root/runtime/deployments/[datetime]` |
| 143 | +Example output: |
19 | 144 |
|
20 |
| -The existing app-root/runtime/repo directory is moved aside and is now a symlink to `app-root/runtime/deployments/[datetime]/repo`. |
| 145 | + $ ./deploy deployments s2 |
| 146 | + Gear 51b0dde3a7cfd1abf200006d |
| 147 | + 20130606121412 - 34e2c81bc295d8b769d9531c44532390d4104705 - myapp-1.0.tar.gz |
| 148 | + |
| 149 | + Gear 51b0e483a7cfd1abf2000092 |
| 150 | + |
| 151 | + Gear 51b0e665a7cfd1abf20000a5 |
| 152 | + 20130606121412 - 34e2c81bc295d8b769d9531c44532390d4104705 - myapp-1.0.tar.gz |
0 commit comments