cpl 1.1.2.rc.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +1 -1
- data/CHANGELOG.md +36 -1
- data/CONTRIBUTING.md +2 -6
- data/Gemfile.lock +7 -7
- data/README.md +94 -53
- data/docs/commands.md +22 -5
- data/docs/migrating.md +3 -3
- data/examples/controlplane.yml +63 -4
- data/lib/command/apply_template.rb +30 -54
- data/lib/command/base.rb +43 -0
- data/lib/command/copy_image_from_upstream.rb +5 -2
- data/lib/command/delete.rb +40 -11
- data/lib/command/env.rb +1 -0
- data/lib/command/generate.rb +45 -0
- data/lib/command/info.rb +5 -5
- data/lib/command/latest_image.rb +1 -0
- data/lib/command/maintenance.rb +1 -0
- data/lib/command/no_command.rb +6 -3
- data/lib/command/open_console.rb +26 -0
- data/lib/command/ps.rb +5 -1
- data/lib/command/run.rb +2 -2
- data/lib/command/run_detached.rb +2 -1
- data/lib/command/setup_app.rb +3 -3
- data/lib/command/version.rb +1 -0
- data/lib/core/config.rb +185 -54
- data/lib/core/controlplane.rb +76 -24
- data/lib/core/controlplane_api.rb +9 -1
- data/lib/core/controlplane_api_direct.rb +20 -2
- data/lib/core/helpers.rb +10 -0
- data/lib/core/shell.rb +36 -2
- data/lib/cpl/version.rb +1 -1
- data/lib/cpl.rb +28 -2
- data/lib/generator_templates/Dockerfile +27 -0
- data/lib/generator_templates/controlplane.yml +57 -0
- data/lib/generator_templates/entrypoint.sh +8 -0
- data/lib/generator_templates/templates/gvc.yml +21 -0
- data/lib/generator_templates/templates/postgres.yml +176 -0
- data/lib/generator_templates/templates/rails.yml +36 -0
- metadata +14 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 711286ef49686f6c51df2a94c533b3df94f4d71d3fb6018b6ed61c210593dd47
|
4
|
+
data.tar.gz: '085357faac6b5b27e493049b34c27debab21fa19950af21548fe11889140b557'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac229234f4919d8e1b3485095476ef0fddac04573d8dd03aba6a3737fd5e90b319538e04c51d98e5f33f244fe304c519d949a624a377bbc9ee9067754a0c71dd
|
7
|
+
data.tar.gz: 0ba5203d4f8539dde89a2eb5a52dc92c2098d11bb1914002cd57628081465d08e9842f47546da563bc18edda17fbf12101bfefca8fdcee4088825c0e56ee0fa0
|
data/.github/workflows/rspec.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -14,11 +14,44 @@ Changes since the last non-beta release.
|
|
14
14
|
|
15
15
|
_Please add entries here for your pull requests that are not yet released._
|
16
16
|
|
17
|
+
### Fixed
|
18
|
+
|
19
|
+
- Fixed issue where `info` command does not respect `CPLN_ORG` env var. [PR 88](https://github.com/shakacode/heroku-to-control-plane/pull/88) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
|
20
|
+
- Fixed issues with running `cpl --version` and `cpl --help` where no configuration file exists. [PR 100](https://github.com/shakacode/heroku-to-control-plane/pull/100) by [Mostafa Ahangarha](https://github.com/ahangarha).
|
21
|
+
- Fixed issue where `delete` command fails to delete apps with volumesets. [PR 123](https://github.com/shakacode/heroku-to-control-plane/pull/123) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
|
22
|
+
|
23
|
+
### Added
|
24
|
+
|
25
|
+
- Added `--org` option to all commands. [PR 88](https://github.com/shakacode/heroku-to-control-plane/pull/88) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
|
26
|
+
- Added option to set the app with a `CPLN_APP` env var. [PR 88](https://github.com/shakacode/heroku-to-control-plane/pull/88) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
|
27
|
+
- Show `org` and `app` on every command excluding `info`, `version`, `maintenance`, `env`, `ps`, and `latest_image`. [PR 94](https://github.com/shakacode/heroku-to-control-plane/pull/94) by [Mostafa Ahangarha](https://github.com/ahangarha).
|
28
|
+
- Added option to only use `CPLN_ORG` and `CPLN_APP` env vars if `allow_org_override_by_env` and `allow_app_override_by_env` configs are set to `true` in `controlplane.yml`. [PR 109](https://github.com/shakacode/heroku-to-control-plane/pull/109) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
|
29
|
+
- Added `CPLN_LOCATION` env variable and `--location` option for `apply-template`, `ps`, `run`, `run:detached`. [PR 105](https://github.com/shakacode/heroku-to-control-plane/pull/105) by [Mostafa Ahangarha](https://github.com/ahangarha).
|
30
|
+
- Added `generate` command for creating basic Control Plane configuration directory. [PR 116](https://github.com/shakacode/heroku-to-control-plane/pull/116) by [Mostafa Ahangarhga](https://github.com/ahangarha).
|
31
|
+
- Added `--trace` option to all commands for more detailed logs. [PR 124](https://github.com/shakacode/heroku-to-control-plane/pull/124) by [justin808](https://github.com/justin808)
|
32
|
+
- Added better error message to check the org name in case of a 403 error. [PR 124](https://github.com/justin808) by [justin808](https://github.com/justin808)
|
33
|
+
|
34
|
+
### Changed
|
35
|
+
|
36
|
+
- `--org` option now takes precedence over `CPLN_ORG` env var, which takes precedence over `cpln_org` from `controlplane.yml`. [PR 88](https://github.com/shakacode/heroku-to-control-plane/pull/88) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
|
37
|
+
- Renamed `setup` config into `setup_app_templates`. [PR 112](https://github.com/shakacode/heroku-to-control-plane/pull/112) by [Mostafa Ahangarha](https://github.com/ahangarha).
|
38
|
+
|
17
39
|
## [1.1.2] - 2023-10-17
|
40
|
+
|
18
41
|
### Fixed
|
19
42
|
|
20
43
|
- Fixed failed build on MacOS by adding platform flag and fixed multiple files in yaml document for template. [PR 81](https://github.com/shakacode/heroku-to-control-plane/pull/81) by [justin808](https://github.com/justin808).
|
21
44
|
|
45
|
+
### Added
|
46
|
+
|
47
|
+
- Added `open-console` command to open the app console on Control Plane. [PR 83](https://github.com/shakacode/heroku-to-control-plane/pull/83) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
|
48
|
+
- Added option to set the org with a `CPLN_ORG`/`CPLN_ORG_UPSTREAM` env var. [PR 83](https://github.com/shakacode/heroku-to-control-plane/pull/83) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
|
49
|
+
- Added `--verbose` option to all commands for more detailed logs. [PR 83](https://github.com/shakacode/heroku-to-control-plane/pull/83) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
|
50
|
+
|
51
|
+
### Changed
|
52
|
+
|
53
|
+
- Calling `cpl` with no command now shows the help menu. [PR 83](https://github.com/shakacode/heroku-to-control-plane/pull/83) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
|
54
|
+
|
22
55
|
## [1.1.1] - 2023-09-23
|
23
56
|
|
24
57
|
### Fixed
|
@@ -84,7 +117,9 @@ _Please add entries here for your pull requests that are not yet released._
|
|
84
117
|
|
85
118
|
- Initial release
|
86
119
|
|
87
|
-
[Unreleased]: https://github.com/shakacode/heroku-to-control-plane/compare/v1.1.
|
120
|
+
[Unreleased]: https://github.com/shakacode/heroku-to-control-plane/compare/v1.1.2...HEAD
|
121
|
+
[1.1.2]: https://github.com/shakacode/heroku-to-control-plane/compare/v1.1.1...v1.1.2
|
122
|
+
[1.1.1]: https://github.com/shakacode/heroku-to-control-plane/compare/v1.1.0...v1.1.1
|
88
123
|
[1.1.0]: https://github.com/shakacode/heroku-to-control-plane/compare/v1.0.4...v1.1.0
|
89
124
|
[1.0.4]: https://github.com/shakacode/heroku-to-control-plane/compare/v1.0.3...v1.0.4
|
90
125
|
[1.0.3]: https://github.com/shakacode/heroku-to-control-plane/compare/v1.0.2...v1.0.3
|
data/CONTRIBUTING.md
CHANGED
@@ -12,12 +12,6 @@ git clone https://github.com/shakacode/heroku-to-control-plane
|
|
12
12
|
alias cpl="~/projects/heroku-to-control-plane/bin/cpl"
|
13
13
|
```
|
14
14
|
|
15
|
-
Or set the path of the Ruby gem in your Gemfile.
|
16
|
-
|
17
|
-
```ruby
|
18
|
-
gem 'cpl', path: '~/projects/heroku-to-control-plane'
|
19
|
-
```
|
20
|
-
|
21
15
|
## Linting/Testing
|
22
16
|
|
23
17
|
Before committing or pushing code, be sure to:
|
@@ -36,6 +30,8 @@ overcommit --install
|
|
36
30
|
|
37
31
|
## Debugging
|
38
32
|
|
33
|
+
1. Use the `--verbose` option to see more detailed logs.
|
34
|
+
2. Use the `--trace` option to see full logging of HTTP requests. Warning, this will display keys to your logs or console.
|
39
35
|
1. Add a breakpoint (`debugger`) to any line of code you want to debug.
|
40
36
|
2. Modify the `lib/command/test.rb` file to trigger the code you want to test. To simulate a command, you can use
|
41
37
|
`Cpl::Cli.start` (e.g., `Cpl::Cli.start(["deploy-image", "-a", "my-app-name"])` would be the same as running
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cpl (1.
|
4
|
+
cpl (1.2.0)
|
5
5
|
debug (~> 1.7.1)
|
6
6
|
dotenv (~> 2.8.1)
|
7
7
|
psych (~> 5.1.0)
|
@@ -24,8 +24,8 @@ GEM
|
|
24
24
|
dotenv (2.8.1)
|
25
25
|
hashdiff (1.0.1)
|
26
26
|
iniparse (1.5.0)
|
27
|
-
io-console (0.
|
28
|
-
irb (1.
|
27
|
+
io-console (0.7.1)
|
28
|
+
irb (1.11.0)
|
29
29
|
rdoc
|
30
30
|
reline (>= 0.3.8)
|
31
31
|
json (2.6.3)
|
@@ -36,15 +36,15 @@ GEM
|
|
36
36
|
parallel (1.22.1)
|
37
37
|
parser (3.2.0.0)
|
38
38
|
ast (~> 2.4.1)
|
39
|
-
psych (5.1.
|
39
|
+
psych (5.1.2)
|
40
40
|
stringio
|
41
41
|
public_suffix (5.0.1)
|
42
42
|
rainbow (3.1.1)
|
43
43
|
rake (13.0.6)
|
44
|
-
rdoc (6.
|
44
|
+
rdoc (6.6.2)
|
45
45
|
psych (>= 4.0.0)
|
46
46
|
regexp_parser (2.6.2)
|
47
|
-
reline (0.
|
47
|
+
reline (0.4.1)
|
48
48
|
io-console (~> 0.5)
|
49
49
|
rexml (3.2.5)
|
50
50
|
rspec (3.12.0)
|
@@ -86,7 +86,7 @@ GEM
|
|
86
86
|
simplecov_json_formatter (~> 0.1)
|
87
87
|
simplecov-html (0.12.3)
|
88
88
|
simplecov_json_formatter (0.1.4)
|
89
|
-
stringio (3.0
|
89
|
+
stringio (3.1.0)
|
90
90
|
thor (1.2.2)
|
91
91
|
timecop (0.9.6)
|
92
92
|
unicode-display_width (2.4.2)
|
data/README.md
CHANGED
@@ -6,13 +6,19 @@
|
|
6
6
|
<meta name="keywords" content="Control Plane, Heroku, Kubernetes, K8, Infrastructure">
|
7
7
|
<meta name="google-site-verification" content="dIV4nMplcYl6YOKOaZMqgvdKXhLJ4cdYY6pS6e_YrPU" />
|
8
8
|
|
9
|
-
_A gem that provides **Heroku Flow** functionality on Control Plane, including docs for migrating from [Heroku](https://heroku.com) to [Control Plane](https://controlplane.com)_
|
9
|
+
_A gem that provides **Heroku Flow** functionality on Control Plane, including docs for migrating from [Heroku](https://heroku.com) to [Control Plane](https://shakacode.controlplane.com/)._
|
10
10
|
|
11
11
|
[](https://github.com/shakacode/heroku-to-control-plane/actions/workflows/rspec.yml)
|
12
12
|
[](https://github.com/shakacode/heroku-to-control-plane/actions/workflows/rubocop.yml)
|
13
13
|
|
14
14
|
[](https://badge.fury.io/rb/cpl)
|
15
15
|
|
16
|
+
---
|
17
|
+
|
18
|
+
_If you need a free demo account for Control Plane (no CC required), you can contact [controlplane@shakacode.com](mailto:controlplane@shakacode.com)._
|
19
|
+
|
20
|
+
---
|
21
|
+
|
16
22
|
This playbook shows how to move "Heroku apps" to "Control Plane workloads" via an open-source `cpl` CLI on top of
|
17
23
|
Control Plane's `cpln` CLI.
|
18
24
|
|
@@ -29,17 +35,18 @@ a **helper CLI** based on templates to save lots of day-to-day typing (and human
|
|
29
35
|
2. [Concept Mapping](#concept-mapping)
|
30
36
|
3. [Installation](#installation)
|
31
37
|
4. [Steps to Migrate](#steps-to-migrate)
|
32
|
-
5. [
|
33
|
-
6. [
|
34
|
-
7. [
|
35
|
-
8. [
|
36
|
-
9. [
|
37
|
-
10. [
|
38
|
-
11. [
|
39
|
-
12. [
|
40
|
-
13. [
|
41
|
-
14. [Migrating
|
42
|
-
15. [
|
38
|
+
5. [Configuration Files](#configuration-files)
|
39
|
+
6. [Workflow](#workflow)
|
40
|
+
7. [Environment](#environment)
|
41
|
+
8. [Database](#database)
|
42
|
+
9. [In-memory Databases](#in-memory-databases)
|
43
|
+
10. [Scheduled Jobs](#scheduled-jobs)
|
44
|
+
11. [CLI Commands Reference](#cli-commands-reference)
|
45
|
+
12. [Mapping of Heroku Commands to `cpl` and `cpln`](#mapping-of-heroku-commands-to-cpl-and-cpln)
|
46
|
+
13. [Examples](#examples)
|
47
|
+
14. [Migrating Postgres Database from Heroku Infrastructure](/docs/postgres.md)
|
48
|
+
15. [Migrating Redis Database from Heroku Infrastructure](/docs/redis.md)
|
49
|
+
16. [Tips](/docs/tips.md)
|
43
50
|
|
44
51
|
## Key Features
|
45
52
|
|
@@ -89,23 +96,30 @@ For the typical Rails app, this means:
|
|
89
96
|
|
90
97
|
## Installation
|
91
98
|
|
92
|
-
1. Ensure your [Control Plane](https://controlplane.com) account is set up. Set up an `organization`
|
93
|
-
|
99
|
+
1. Ensure your [Control Plane](https://shakacode.controlplane.com/) account is set up. Set up an `organization` `<your-org>` for testing in that account and modify the value for `aliases.common.cpln_org` in `.controlplane/controlplane.yml`, or you can also set it with the `CPLN_ORG` environment variable. If you need an organization, please [contact Shakacode](mailto:controlplane@shakacode.com).
|
100
|
+
|
101
|
+
2. Install [Node.js](https://nodejs.org/en) (required for Control Plane CLI).
|
102
|
+
|
103
|
+
3. Install [Ruby](https://www.ruby-lang.org/en/) (required for these helpers).
|
94
104
|
|
95
|
-
|
105
|
+
4. Install Control Plane CLI, and configure access ([docs here](https://docs.controlplane.com/quickstart/quick-start-3-cli#getting-started-with-the-cli)).
|
96
106
|
|
97
|
-
1. Install Control Plane CLI (and configure access) [docs here](https://docs.controlplane.com/quickstart/quick-start-3-cli#getting-started-with-the-cli), `npm install -g @controlplane/cli`. You can update the `cpln` command line with `npm update -g @controlplane/cli`. Then run `cpln login` to ensure access.
|
98
107
|
```sh
|
108
|
+
# Install CLI
|
99
109
|
npm install -g @controlplane/cli
|
110
|
+
|
111
|
+
# Configure access
|
100
112
|
cpln login
|
113
|
+
|
114
|
+
# Update CLI
|
115
|
+
npm update -g @controlplane/cli
|
101
116
|
```
|
102
117
|
|
103
|
-
|
118
|
+
5. Run `cpln image docker-login --org <your-org>` to ensure that you have access to the Control Plane Docker registry.
|
104
119
|
|
105
|
-
|
106
|
-
For information on the latter, see [CONTRIBUTING.md](CONTRIBUTING.md). You may also install `cpl` in your project's Gemfile.
|
120
|
+
6. Install Heroku to Control Plane `cpl` CLI as a [Ruby gem](https://rubygems.org/gems/cpl): `gem install cpl`. If you want to hack on the source code, see [CONTRIBUTING.md](CONTRIBUTING.md).
|
107
121
|
|
108
|
-
|
122
|
+
7. You can use [this Dockerfile](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/.controlplane/Dockerfile) as an example for your project. Ensure that you have Docker running.
|
109
123
|
|
110
124
|
**Note:** Do not confuse the `cpl` CLI with the `cpln` CLI. The `cpl` CLI is the Heroku to Control Plane playbook CLI.
|
111
125
|
The `cpln` CLI is the Control Plane CLI.
|
@@ -116,7 +130,7 @@ Click [here](/docs/migrating.md) to see the steps to migrate.
|
|
116
130
|
|
117
131
|
## Configuration Files
|
118
132
|
|
119
|
-
The `cpl` gem is based on several configuration files within a `/.controlplane` top-level directory in your
|
133
|
+
The `cpl` gem is based on several configuration files within a `/.controlplane` top-level directory in your project.
|
120
134
|
|
121
135
|
```
|
122
136
|
.controlplane/
|
@@ -129,32 +143,46 @@ The `cpl` gem is based on several configuration files within a `/.controlplane`
|
|
129
143
|
├─ entrypoint.sh
|
130
144
|
```
|
131
145
|
|
132
|
-
1. `controlplane.yml` describes the overall application. Be sure to have
|
146
|
+
1. `controlplane.yml` describes the overall application. Be sure to have `<your-org>` as the value for `aliases.common.cpln_org`, or set it with the `CPLN_ORG` environment variable.
|
133
147
|
2. `Dockerfile` builds the production application. `entrypoint.sh` is an _example_ entrypoint script for the production application, referenced in your Dockerfile.
|
134
148
|
3. `templates` directory contains the templates for the various workloads, such as `rails.yml` and `postgres.yml`.
|
135
|
-
4. `templates/gvc.yml` defines your project's GVC (like a Heroku app).
|
136
|
-
5. `templates/rails.yml` defines your Rails workload. It may inherit ENV values from the parent GVC, which is populated from the `templates/gvc.yml`. This file also configures scaling, sizing, firewalls, and other workload
|
137
|
-
6. For other workloads (like lines in a Heroku Procfile), you create additional template files. For example, you can base a `templates/sidekiq.yml` on the `templates/rails.yml` file.
|
138
|
-
7. You can have other files in the `templates` directory, such as `redis.yml` and `postgres.yml
|
149
|
+
4. `templates/gvc.yml` defines your project's GVC (like a Heroku app). More importantly, it contains ENV values for the app.
|
150
|
+
5. `templates/rails.yml` defines your Rails workload. It may inherit ENV values from the parent GVC, which is populated from the `templates/gvc.yml`. This file also configures scaling, sizing, firewalls, and other workload-specific values.
|
151
|
+
6. For other workloads (like lines in a Heroku `Procfile`), you create additional template files. For example, you can base a `templates/sidekiq.yml` on the `templates/rails.yml` file.
|
152
|
+
7. You can have other files in the `templates` directory, such as `redis.yml` and `postgres.yml`, which could setup Redis and Postgres for a testing application.
|
139
153
|
|
140
154
|
Here's a complete example of all supported config keys explained for the `controlplane.yml` file:
|
141
|
-
|
155
|
+
|
142
156
|
### `controlplane.yml`
|
157
|
+
|
143
158
|
```yaml
|
144
159
|
# Keys beginning with "cpln_" correspond to your settings in Control Plane.
|
145
160
|
|
161
|
+
# Global settings that apply to `cpl` usage.
|
162
|
+
# You can opt out of allowing the use of CPLN_ORG and CPLN_APP env vars
|
163
|
+
# to avoid any accidents with the wrong org / app.
|
164
|
+
allow_org_override_by_env: true
|
165
|
+
allow_app_override_by_env: true
|
166
|
+
|
146
167
|
aliases:
|
147
168
|
common: &common
|
148
|
-
# Organization
|
149
|
-
# Production apps will use a different organization, specified
|
169
|
+
# Organization for staging and QA apps is typically set as an alias.
|
170
|
+
# Production apps will use a different organization, specified in `apps`, for security.
|
171
|
+
# Change this value to your organization name
|
172
|
+
# or set the CPLN_ORG env var and it will override this for all `cpl` commands
|
173
|
+
# (provided that `allow_org_override_by_env` is set to `true`).
|
150
174
|
cpln_org: my-org-staging
|
151
175
|
|
152
|
-
#
|
176
|
+
# Control Plane offers the ability to use multiple locations.
|
177
|
+
# default_location is used for commands that require a location
|
178
|
+
# including `ps`, `run`, `run:detached`, `apply-template`.
|
179
|
+
# This can be overridden with option --location=<location> and
|
180
|
+
# CPLN_LOCATION environment variable.
|
153
181
|
default_location: aws-us-east-2
|
154
182
|
|
155
183
|
# Allows running the command `cpl setup-app`
|
156
184
|
# instead of `cpl apply-template gvc redis postgres memcached rails sidekiq`.
|
157
|
-
|
185
|
+
setup_app_templates:
|
158
186
|
- gvc
|
159
187
|
- redis
|
160
188
|
- postgres
|
@@ -214,6 +242,11 @@ apps:
|
|
214
242
|
my-app-production:
|
215
243
|
<<: *common
|
216
244
|
|
245
|
+
# You can also opt out of allowing the use of CPLN_ORG and CPLN_APP env vars per app.
|
246
|
+
# It's recommended to leave this off for production, to avoid any accidents.
|
247
|
+
allow_org_override_by_env: false
|
248
|
+
allow_app_override_by_env: false
|
249
|
+
|
217
250
|
# Use a different organization for production.
|
218
251
|
cpln_org: my-org-production
|
219
252
|
|
@@ -234,58 +267,64 @@ apps:
|
|
234
267
|
|
235
268
|
## Workflow
|
236
269
|
|
237
|
-
For a live example, see the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/.controlplane/readme.md).
|
270
|
+
For a live example, see the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/.controlplane/readme.md) repository.
|
271
|
+
|
238
272
|
This example should closely match the below example.
|
239
273
|
|
240
274
|
Suppose your app is called `tutorial-app`. You can run the following commands.
|
241
275
|
|
242
276
|
### Setup Commands
|
277
|
+
|
243
278
|
```sh
|
244
279
|
# Provision all infrastructure on Control Plane.
|
245
|
-
#
|
246
|
-
cpl apply-template gvc postgres redis rails -a tutorial-app
|
280
|
+
# `tutorial-app` will be created per definition in .controlplane/controlplane.yml.
|
281
|
+
cpl apply-template gvc postgres redis rails daily-task -a tutorial-app
|
247
282
|
|
248
|
-
# Build and push
|
249
|
-
# Note, may take many minutes. Be patient.
|
283
|
+
# Build and push the Docker image to the Control Plane repository.
|
284
|
+
# Note, it may take many minutes. Be patient.
|
285
|
+
# Check for error messages, such as forgetting to run `cpln image docker-login --org <your-org>`.
|
250
286
|
cpl build-image -a tutorial-app
|
251
287
|
|
252
|
-
# Promote image to app after running `cpl build-image command
|
253
|
-
# Note, the UX of images may not show the image for up to 5 minutes. However, it's ready.
|
288
|
+
# Promote the image to the app after running the `cpl build-image` command.
|
289
|
+
# Note, the UX of the images may not show the image for up to 5 minutes. However, it's ready.
|
254
290
|
cpl deploy-image -a tutorial-app
|
255
291
|
|
256
|
-
# See how app is starting up
|
292
|
+
# See how the app is starting up.
|
257
293
|
cpl logs -a tutorial-app
|
258
294
|
|
259
|
-
# Open app in browser (once it has started up)
|
295
|
+
# Open the app in browser (once it has started up).
|
260
296
|
cpl open -a tutorial-app
|
261
297
|
```
|
262
298
|
|
263
|
-
### Promoting
|
299
|
+
### Promoting Code Updates
|
264
300
|
|
265
301
|
After committing code, you will update your deployment of `tutorial-app` with the following commands:
|
266
302
|
|
267
303
|
```sh
|
268
|
-
# Build and push new image with sequential image tagging, e.g. 'tutorial-app:1', then 'tutorial-app:2', etc.
|
304
|
+
# Build and push a new image with sequential image tagging, e.g. 'tutorial-app:1', then 'tutorial-app:2', etc.
|
269
305
|
cpl build-image -a tutorial-app
|
270
306
|
|
271
|
-
# Run database migrations (or other release tasks) with latest image,
|
272
|
-
# while app is still running on previous image.
|
307
|
+
# Run database migrations (or other release tasks) with the latest image,
|
308
|
+
# while the app is still running on the previous image.
|
273
309
|
# This is analogous to the release phase.
|
274
|
-
cpl
|
310
|
+
cpl run:detached rails db:migrate -a tutorial-app --image latest
|
275
311
|
|
276
|
-
# Pomote latest image to app
|
312
|
+
# Pomote the latest image to the app.
|
277
313
|
cpl deploy-image -a tutorial-app
|
278
314
|
```
|
279
315
|
|
280
316
|
If you needed to push a new image with a specific commit SHA, you can run the following command:
|
281
317
|
|
282
318
|
```sh
|
283
|
-
# Build and push with sequential image tagging and commit SHA, e.g. 'tutorial-app:123_ABCD'
|
319
|
+
# Build and push with sequential image tagging and commit SHA, e.g. 'tutorial-app:123_ABCD', etc.
|
284
320
|
cpl build-image -a tutorial-app --commit ABCD
|
285
321
|
```
|
286
322
|
|
287
323
|
### Real World
|
288
|
-
|
324
|
+
|
325
|
+
Most companies will configure their CI system to handle the above steps. Please [contact Shakacode](mailto:controlplane@shakacode.com) for examples of how to do this.
|
326
|
+
|
327
|
+
You can also join our [**Slack channel**](https://reactrails.slack.com/join/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE) for ShakaCode open source projects.
|
289
328
|
|
290
329
|
## Environment
|
291
330
|
|
@@ -307,25 +346,27 @@ It is also possible to set up a Secret store (of type `Dictionary`), which we ca
|
|
307
346
|
Policy to access the secret.
|
308
347
|
|
309
348
|
In `templates/gvc.yml`:
|
349
|
+
|
310
350
|
```yaml
|
311
351
|
spec:
|
312
352
|
env:
|
313
353
|
- name: MY_GLOBAL_VAR
|
314
|
-
value:
|
354
|
+
value: "value"
|
315
355
|
- name: MY_SECRET_GLOBAL_VAR
|
316
|
-
value:
|
356
|
+
value: "cpln://secret/MY_SECRET_STORE_NAME/MY_SECRET_GLOBAL_VAR"
|
317
357
|
```
|
318
358
|
|
319
359
|
In `templates/rails.yml`:
|
360
|
+
|
320
361
|
```yaml
|
321
362
|
spec:
|
322
363
|
containers:
|
323
364
|
- name: rails
|
324
365
|
env:
|
325
366
|
- name: MY_LOCAL_VAR
|
326
|
-
value:
|
367
|
+
value: "value"
|
327
368
|
- name: MY_SECRET_LOCAL_VAR
|
328
|
-
value:
|
369
|
+
value: "cpln://secret/MY_SECRET_STORE_NAME/MY_SECRET_LOCAL_VAR"
|
329
370
|
inheritEnv: true # To enable global env inheritance.
|
330
371
|
```
|
331
372
|
|
@@ -387,7 +428,7 @@ spec:
|
|
387
428
|
type: cron
|
388
429
|
job:
|
389
430
|
# Run daily job at 2am.
|
390
|
-
schedule: 0
|
431
|
+
schedule: "0 2 * * *"
|
391
432
|
# "Never" or "OnFailure"
|
392
433
|
restartPolicy: Never
|
393
434
|
containers:
|
data/docs/commands.md
CHANGED
@@ -100,7 +100,7 @@ cpl copy-image-from-upstream -a $APP_NAME --upstream-token $UPSTREAM_TOKEN --ima
|
|
100
100
|
|
101
101
|
### `delete`
|
102
102
|
|
103
|
-
- Deletes the whole app (GVC with all workloads and all images)
|
103
|
+
- Deletes the whole app (GVC with all workloads, all volumesets and all images)
|
104
104
|
- Will ask for explicit user confirmation
|
105
105
|
|
106
106
|
```sh
|
@@ -131,6 +131,15 @@ cpl env -a $APP_NAME
|
|
131
131
|
if [ cpl exists -a $APP_NAME ]; ...
|
132
132
|
```
|
133
133
|
|
134
|
+
### `generate`
|
135
|
+
|
136
|
+
Creates base Control Plane config and template files
|
137
|
+
|
138
|
+
```sh
|
139
|
+
# Creates .controlplane directory with Control Plane config and other templates
|
140
|
+
cpl generate
|
141
|
+
```
|
142
|
+
|
134
143
|
### `info`
|
135
144
|
|
136
145
|
- Displays the diff between defined/available apps/workloads (apps equal GVCs)
|
@@ -140,7 +149,7 @@ if [ cpl exists -a $APP_NAME ]; ...
|
|
140
149
|
- The diff is based on what's defined in the `.controlplane/controlplane.yml` file
|
141
150
|
|
142
151
|
```sh
|
143
|
-
# Shows diff for all apps in all orgs.
|
152
|
+
# Shows diff for all apps in all orgs (based on `.controlplane/controlplane.yml`).
|
144
153
|
cpl info
|
145
154
|
|
146
155
|
# Shows diff for all apps in a specific org.
|
@@ -227,6 +236,15 @@ cpl open -a $APP_NAME
|
|
227
236
|
cpl open -a $APP_NAME -w $WORKLOAD_NAME
|
228
237
|
```
|
229
238
|
|
239
|
+
### `open-console`
|
240
|
+
|
241
|
+
- Opens the app console on Control Plane in the default browser
|
242
|
+
- Can also go directly to a workload page if `--workload` is provided
|
243
|
+
|
244
|
+
```sh
|
245
|
+
cpl open-console -a $APP_NAME
|
246
|
+
```
|
247
|
+
|
230
248
|
### `promote-app-from-upstream`
|
231
249
|
|
232
250
|
- Copies the latest image from upstream, runs a release script (optional), and deploys the image
|
@@ -303,7 +321,6 @@ cpl ps:swait -a $APP_NAME -w $WORKLOAD_NAME
|
|
303
321
|
|
304
322
|
- Runs one-off **_interactive_** replicas (analog of `heroku run`)
|
305
323
|
- Uses `Standard` workload type and `cpln exec` as the execution method, with CLI streaming
|
306
|
-
- May not work correctly with tasks that last over 5 minutes (there's a Control Plane scaling bug at the moment)
|
307
324
|
- If `fix_terminal_size` is `true` in the `.controlplane/controlplane.yml` file, the remote terminal size will be fixed to match the local terminal size (may also be overriden through `--terminal-size`)
|
308
325
|
|
309
326
|
> **IMPORTANT:** Useful for development where it's needed for interaction, and where network connection drops and
|
@@ -382,8 +399,8 @@ cpl run:detached rails db:migrate:status -a $APP_NAME --use-local-token
|
|
382
399
|
### `setup-app`
|
383
400
|
|
384
401
|
- Creates an app and all its workloads
|
385
|
-
- Specify the templates for the app and workloads through `
|
386
|
-
- This should
|
402
|
+
- Specify the templates for the app and workloads through `setup_app_templates` in the `.controlplane/controlplane.yml` file
|
403
|
+
- This should only be used for temporary apps like review apps, never for persistent apps like production (to update workloads for those, use 'cpl apply-template' instead)
|
387
404
|
|
388
405
|
```sh
|
389
406
|
cpl setup-app -a $APP_NAME
|
data/docs/migrating.md
CHANGED
@@ -29,13 +29,13 @@ Edit the `.controlplane/controlplane.yml` file as needed. Note that the `my-app-
|
|
29
29
|
is defined in this file. See
|
30
30
|
[this example](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/.controlplane/controlplane.yml).
|
31
31
|
|
32
|
-
Before the initial setup, add the templates for the app to the `.controlplane/controlplane.yml` file, using the `
|
32
|
+
Before the initial setup, add the templates for the app to the `.controlplane/controlplane.yml` file, using the `setup_app_templates`
|
33
33
|
key, e.g.:
|
34
34
|
|
35
35
|
```yaml
|
36
36
|
my-app-staging:
|
37
37
|
<<: *common
|
38
|
-
|
38
|
+
setup_app_templates:
|
39
39
|
- gvc
|
40
40
|
- redis
|
41
41
|
- memcached
|
@@ -191,7 +191,7 @@ configure an entry for, e.g., `my-app-review`, and then create review apps start
|
|
191
191
|
my-app-review:
|
192
192
|
<<: *common
|
193
193
|
match_if_app_name_starts_with: true
|
194
|
-
|
194
|
+
setup_app_templates:
|
195
195
|
- gvc
|
196
196
|
- redis
|
197
197
|
- memcached
|
data/examples/controlplane.yml
CHANGED
@@ -1,15 +1,38 @@
|
|
1
1
|
# Keys beginning with "cpln_" correspond to your settings in Control Plane.
|
2
2
|
|
3
|
+
# Global settings that apply to `cpl` usage.
|
4
|
+
# You can opt out of allowing the use of CPLN_ORG and CPLN_APP env vars
|
5
|
+
# to avoid any accidents with the wrong org / app.
|
6
|
+
allow_org_override_by_env: true
|
7
|
+
allow_app_override_by_env: true
|
8
|
+
|
3
9
|
aliases:
|
4
10
|
common: &common
|
5
|
-
# Organization
|
6
|
-
# Production apps will use a different organization, specified
|
11
|
+
# Organization for staging and QA apps is typically set as an alias.
|
12
|
+
# Production apps will use a different organization, specified in `apps`, for security.
|
13
|
+
# Change this value to your organization name
|
14
|
+
# or set the CPLN_ORG env var and it will override this for all `cpl` commands
|
15
|
+
# (provided that `allow_org_override_by_env` is set to `true`).
|
7
16
|
cpln_org: my-org-staging
|
8
17
|
|
9
|
-
#
|
18
|
+
# Control Plane offers the ability to use multiple locations.
|
19
|
+
# default_location is used for commands that require a location
|
20
|
+
# including `ps`, `run`, `run:detached`, `apply-template`.
|
21
|
+
# This can be overridden with option --location=<location> and
|
22
|
+
# CPLN_LOCATION environment variable.
|
10
23
|
# TODO: Allow specification of multiple locations.
|
11
24
|
default_location: aws-us-east-2
|
12
25
|
|
26
|
+
# Allows running the command `cpl setup-app`
|
27
|
+
# instead of `cpl apply-template gvc redis postgres memcached rails sidekiq`.
|
28
|
+
setup:
|
29
|
+
- gvc
|
30
|
+
- redis
|
31
|
+
- postgres
|
32
|
+
- memcached
|
33
|
+
- rails
|
34
|
+
- sidekiq
|
35
|
+
|
13
36
|
# Configure the workload name used as a template for one-off scripts, like a Heroku one-off dyno.
|
14
37
|
one_off_workload: rails
|
15
38
|
|
@@ -24,26 +47,62 @@ aliases:
|
|
24
47
|
- postgres
|
25
48
|
- memcached
|
26
49
|
|
27
|
-
# Configure the workload name used when maintenance mode is on (defaults to "maintenance")
|
50
|
+
# Configure the workload name used when maintenance mode is on (defaults to "maintenance").
|
28
51
|
maintenance_workload: maintenance
|
29
52
|
|
53
|
+
# Fixes the remote terminal size to match the local terminal size
|
54
|
+
# when running the commands `cpl run` or `cpl run:detached`.
|
55
|
+
fix_terminal_size: true
|
56
|
+
|
57
|
+
# Apps with a deployed image created before this amount of days will be listed for deletion
|
58
|
+
# when running the command `cpl cleanup-stale-apps`.
|
59
|
+
stale_app_image_deployed_days: 5
|
60
|
+
|
61
|
+
# Images that exceed this quantity will be listed for deletion
|
62
|
+
# when running the command `cpl cleanup-images`.
|
63
|
+
image_retention_max_qty: 20
|
64
|
+
|
65
|
+
# Images created before this amount of days will be listed for deletion
|
66
|
+
# when running the command `cpl cleanup-images` (`image_retention_max_qty` takes precedence).
|
67
|
+
image_retention_days: 5
|
68
|
+
|
69
|
+
# Run workloads created before this amount of days will be listed for deletion
|
70
|
+
# when running the command `cpl run:cleanup`.
|
71
|
+
stale_run_workload_created_days: 2
|
72
|
+
|
30
73
|
apps:
|
31
74
|
my-app-staging:
|
32
75
|
# Use the values from the common section above.
|
33
76
|
<<: *common
|
77
|
+
|
34
78
|
my-app-review:
|
35
79
|
<<: *common
|
80
|
+
|
36
81
|
# If `match_if_app_name_starts_with` is `true`, then use this config for app names starting with this name,
|
37
82
|
# e.g., "my-app-review-pr123", "my-app-review-anything-goes", etc.
|
38
83
|
match_if_app_name_starts_with: true
|
84
|
+
|
39
85
|
my-app-production:
|
40
86
|
<<: *common
|
87
|
+
|
88
|
+
# You can also opt out of allowing the use of CPLN_ORG and CPLN_APP env vars per app.
|
89
|
+
# It's recommended to leave this off for production, to avoid any accidents.
|
90
|
+
allow_org_override_by_env: false
|
91
|
+
allow_app_override_by_env: false
|
92
|
+
|
41
93
|
# Use a different organization for production.
|
42
94
|
cpln_org: my-org-production
|
95
|
+
|
43
96
|
# Allows running the command `cpl promote-app-from-upstream -a my-app-production`
|
44
97
|
# to promote the staging app to production.
|
45
98
|
upstream: my-app-staging
|
99
|
+
|
100
|
+
# Used by the command `cpl promote-app-from-upstream` to run a release script before deploying.
|
101
|
+
# This is relative to the `.controlplane/` directory.
|
102
|
+
release_script: release_script
|
103
|
+
|
46
104
|
my-app-other:
|
47
105
|
<<: *common
|
106
|
+
|
48
107
|
# You can specify a different `Dockerfile` relative to the `.controlplane/` directory (defaults to "Dockerfile").
|
49
108
|
dockerfile: ../some_other/Dockerfile
|