aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.travis.yml1
-rw-r--r--README.md15
-rw-r--r--dhall/Config.dhall25
-rwxr-xr-xfiles/clever-set-scalability.sh19
-rw-r--r--tasks/deploy.yml14
-rw-r--r--tasks/setup.yml1
-rw-r--r--tests/test-scalability.yml37
7 files changed, 111 insertions, 1 deletions
diff --git a/.travis.yml b/.travis.yml
index 752366f..d287c26 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -30,6 +30,7 @@ script:
30 - ansible-playbook tests/test-simple-app.yml -i tests/inventory 30 - ansible-playbook tests/test-simple-app.yml -i tests/inventory
31 - ansible-playbook tests/test-haskell-app.yml -i tests/inventory 31 - ansible-playbook tests/test-haskell-app.yml -i tests/inventory
32 - ansible-playbook tests/test-configure-app.yml -i tests/inventory 32 - ansible-playbook tests/test-configure-app.yml -i tests/inventory
33 - ansible-playbook tests/test-scalability.yml -i tests/inventory
33 34
34notifications: 35notifications:
35 slack: fretlink:pTIylIN7zkwRFuL3aHERmsbB 36 slack: fretlink:pTIylIN7zkwRFuL3aHERmsbB
diff --git a/README.md b/README.md
index c0f7959..348f36d 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,7 @@ Variables for the application
36- `clever_disable_metrics`: a boolean to disable metrics support. Optional, default to `false`. 36- `clever_disable_metrics`: a boolean to disable metrics support. Optional, default to `false`.
37- `clever_env_output_file`: as a post deploy task you might need to retrieve the full Clever environment configuration (i.e. with addon env variables). If this variable is set to a filename then the env will be retrieved after a successful deploy inside this file. Optional. 37- `clever_env_output_file`: as a post deploy task you might need to retrieve the full Clever environment configuration (i.e. with addon env variables). If this variable is set to a filename then the env will be retrieved after a successful deploy inside this file. Optional.
38- `clever_build_flavor`: an optional text value used to configure the size of the dedicated build instance (for instance `S` or `XL`). If not defined, it delegates to clever cloud default behaviour. Setting `disabled` disables the dedicated build instance altogether. 38- `clever_build_flavor`: an optional text value used to configure the size of the dedicated build instance (for instance `S` or `XL`). If not defined, it delegates to clever cloud default behaviour. Setting `disabled` disables the dedicated build instance altogether.
39- `clever_scaling`: an optional object used to configure the runtime instances flavours and numbers. If not defined, it delegates to clever cloud default behaviour.
39 40
40Variables specific to deployment, default should be fine: 41Variables specific to deployment, default should be fine:
41- `clever_cli_version`: Version of clever cli tools, default to `2.6.1`. 42- `clever_cli_version`: Version of clever cli tools, default to `2.6.1`.
@@ -44,6 +45,20 @@ Variables specific to deployment, default should be fine:
44- `clever_app_confdir`: Path where to store clever cloud data specific to this application, default to `"{{ clever_app_root }}/.clever_cloud"` 45- `clever_app_confdir`: Path where to store clever cloud data specific to this application, default to `"{{ clever_app_root }}/.clever_cloud"`
45- `clever_login_file`: Path to store login information. Default to `"{{ clever_app_confdir }}/login"`. 46- `clever_login_file`: Path to store login information. Default to `"{{ clever_app_confdir }}/login"`.
46 47
48Scaling configuration
49---------------------
50
51```yaml
52clever_scaling:
53 # instances and flavors are optional and can be configured as
54 # either a fixed value (with `fixed`) or a range # (with `min` and `max`)
55 flavors:
56 fixed: XS
57 instances:
58 min: 2
59 max: 5
60```
61
47 62
48Dependencies 63Dependencies
49------------ 64------------
diff --git a/dhall/Config.dhall b/dhall/Config.dhall
index e092e2c..12371f5 100644
--- a/dhall/Config.dhall
+++ b/dhall/Config.dhall
@@ -2,6 +2,20 @@ let Addon = (./Addon.dhall).Type
2 2
3let Vault = ./Vault.dhall 3let Vault = ./Vault.dhall
4 4
5let FixedOrRange =
6 λ(t : Type) → < Fixed : { fixed : t } | Range : { min : t, max : t } >
7
8let fixed = λ(t : Type) → λ(f : t) → (FixedOrRange t).Fixed { fixed = f }
9
10let range = λ(t : Type) → λ(r : { min : t, max : t }) → (FixedOrRange t).Range r
11
12let InstancesConfig = FixedOrRange Natural
13
14let FlavorsConfig = FixedOrRange Text
15
16let ScalingParameters =
17 { flavor : Optional FlavorsConfig, instances : Optional InstancesConfig }
18
5let Config = 19let Config =
6 λ(Environment : Type) 20 λ(Environment : Type)
7 → { clever_app : Text 21 → { clever_app : Text
@@ -16,6 +30,7 @@ let Config =
16 , clever_addons : List Addon 30 , clever_addons : List Addon
17 , clever_env : Environment 31 , clever_env : Environment
18 , clever_build_flavor : Optional Text 32 , clever_build_flavor : Optional Text
33 , clever_scaling : Optional ScalingParameters
19 } 34 }
20 35
21let mkConfig = 36let mkConfig =
@@ -34,7 +49,15 @@ let mkConfig =
34 , clever_addons = [] : List Addon 49 , clever_addons = [] : List Addon
35 , clever_env = {=} 50 , clever_env = {=}
36 , clever_build_flavor = None Text 51 , clever_build_flavor = None Text
52 , clever_scaling = None ScalingParameters
37 } 53 }
38 : Config {} 54 : Config {}
39 55
40in { Type = Config, mkConfig = mkConfig } 56in { Type = Config
57 , mkConfig = mkConfig
58 , ScalingParameters = ScalingParameters
59 , InstancesConfig = InstancesConfig
60 , FlavorsConfig = FlavorsConfig
61 , fixed = fixed
62 , range = range
63 }
diff --git a/files/clever-set-scalability.sh b/files/clever-set-scalability.sh
new file mode 100755
index 0000000..34a5a24
--- /dev/null
+++ b/files/clever-set-scalability.sh
@@ -0,0 +1,19 @@
1#!/usr/bin/env bash
2
3set -eo pipefail
4params=()
5if [ -n "$INSTANCES" ]; then
6 params+=("--instances" "${INSTANCES}")
7elif [ -n "$MIN_INSTANCES" ] && [ -n "$MAX_INSTANCES" ]; then
8 params+=("--min-instances" "${MIN_INSTANCES}")
9 params+=("--max-instances" "${MAX_INSTANCES}")
10
11fi
12if [ -n "$FLAVOR" ]; then
13 params+=("--flavor" "${FLAVOR}")
14elif [ -n "$MIN_FLAVOR" ] && [ -n "$MAX_FLAVOR" ]; then
15 params+=("--min-flavor" "${MIN_FLAVOR}")
16 params+=("--max-flavor" "${MAX_FLAVOR}")
17fi
18
19clever scale "${params[@]}"
diff --git a/tasks/deploy.yml b/tasks/deploy.yml
index ca1e54a..c567981 100644
--- a/tasks/deploy.yml
+++ b/tasks/deploy.yml
@@ -24,6 +24,20 @@
24 environment: 24 environment:
25 CONFIGURATION_FILE: "{{ clever_login_file }}" 25 CONFIGURATION_FILE: "{{ clever_login_file }}"
26 26
27- name: Configure Scalability
28 when: clever_scaling is defined
29 command: "{{ ansible_env.HOME }}/{{ clever_user_path }}/clever-set-scalability.sh"
30 args:
31 chdir: "{{ clever_app_root }}"
32 environment:
33 CONFIGURATION_FILE: "{{ clever_login_file }}"
34 INSTANCES: "{{ clever_scaling.instances.fixed | default ('') }}"
35 MIN_INSTANCES: "{{ clever_scaling.instances.min | default('') }}"
36 MAX_INSTANCES: "{{ clever_scaling.instances.max | default('') }}"
37 FLAVOR: "{{ clever_scaling.flavor.fixed | default('') }}"
38 MIN_FLAVOR: "{{ clever_scaling.flavor.min | default('') }}"
39 MAX_FLAVOR: "{{ clever_scaling.flavor.max | default('') }}"
40
27- name: Push Environment 41- name: Push Environment
28 shell: "clever env import --json < {{ clever_app_confdir }}/env" 42 shell: "clever env import --json < {{ clever_app_confdir }}/env"
29 args: 43 args:
diff --git a/tasks/setup.yml b/tasks/setup.yml
index a2d5b90..8a11772 100644
--- a/tasks/setup.yml
+++ b/tasks/setup.yml
@@ -29,3 +29,4 @@
29 with_items: 29 with_items:
30 - clever-set-domain.sh 30 - clever-set-domain.sh
31 - clever-set-drain.sh 31 - clever-set-drain.sh
32 - clever-set-scalability.sh
diff --git a/tests/test-scalability.yml b/tests/test-scalability.yml
new file mode 100644
index 0000000..fefc86c
--- /dev/null
+++ b/tests/test-scalability.yml
@@ -0,0 +1,37 @@
1---
2- name: Configure scalability (fixed instances and ranged flavors)
3 hosts: localhost
4 remote_user: root
5 roles:
6 - role: clever
7 vars:
8 clever_token: 123abc
9 clever_secret: cba321
10 clever_app: app_00000000-0000-0000-0000-000000000000
11 clever_scaling:
12 instances: { fixed: 1 }
13 flavors: { min: "nano", max: "XS" }
14
15- name: Configure scalability (no instances and ranged flavors)
16 hosts: localhost
17 remote_user: root
18 roles:
19 - role: clever
20 vars:
21 clever_token: 123abc
22 clever_secret: cba321
23 clever_app: app_00000000-0000-0000-0000-000000000000
24 clever_scaling:
25 flavors: { min: "nano", max: "XS" }
26
27- name: Configure scalability (incomplete flavors)
28 hosts: localhost
29 remote_user: root
30 roles:
31 - role: clever
32 vars:
33 clever_token: 123abc
34 clever_secret: cba321
35 clever_app: app_00000000-0000-0000-0000-000000000000
36 clever_scaling:
37 flavors: { min: "nano" }