aptible-cli 0.22.0 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +81 -79
- data/lib/aptible/cli/resource_formatter.rb +29 -0
- data/lib/aptible/cli/subcommands/services.rb +156 -0
- data/lib/aptible/cli/version.rb +1 -1
- data/spec/aptible/cli/subcommands/services_spec.rb +110 -0
- data/spec/fabricators/service_sizing_policy_fabricator.rb +22 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4a13b0f26d5c480053eb37bcee8287e8f15fa7f48f17a2d2b435ec3c6adf694
|
4
|
+
data.tar.gz: f0f4d6fc308ab9bde7ebf4c76cf804e1990e35dd13fdbf03e0407128df6a6d1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 702b8966a0f5d6c67a0d5bd0c2496cbc90b0fa17c5c4214cbb74c59854ea8810a75723dfe68a6562528ca5955e47657b876b39d23221d6ddde5ecd6e0f7b314f
|
7
|
+
data.tar.gz: 50e7d05a0119c694fff4f7924fad1517fd3a4bc94ecbb9d35c27f3aa6af9166070201c6c4241846208dd6adeb447de366af83dd47f76c5835301972717b240db
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -26,85 +26,87 @@ From `aptible help`:
|
|
26
26
|
<!-- BEGIN USAGE -->
|
27
27
|
```
|
28
28
|
Commands:
|
29
|
-
aptible apps
|
30
|
-
aptible apps:create HANDLE
|
31
|
-
aptible apps:deprovision
|
32
|
-
aptible apps:rename OLD_HANDLE NEW_HANDLE [--environment ENVIRONMENT_HANDLE]
|
33
|
-
aptible apps:scale SERVICE [--container-count COUNT] [--container-size SIZE_MB] [--container-profile PROFILE]
|
34
|
-
aptible backup:list DB_HANDLE
|
35
|
-
aptible backup:orphaned
|
36
|
-
aptible backup:purge BACKUP_ID
|
37
|
-
aptible backup:restore BACKUP_ID [--environment ENVIRONMENT_HANDLE] [--handle HANDLE] [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--key-arn KEY_ARN]
|
38
|
-
aptible backup_retention_policy [ENVIRONMENT_HANDLE]
|
39
|
-
aptible backup_retention_policy:set [ENVIRONMENT_HANDLE] [--daily DAILY_BACKUPS] [--monthly MONTHLY_BACKUPS] [--yearly YEARLY_BACKUPS] [--make-copy|--no-make-copy] [--keep-final|--no-keep-final] [--force]
|
40
|
-
aptible config
|
41
|
-
aptible config:add [VAR1=VAL1] [VAR2=VAL2] [...]
|
42
|
-
aptible config:get [VAR1]
|
43
|
-
aptible config:rm [VAR1] [VAR2] [...]
|
44
|
-
aptible config:set [VAR1=VAL1] [VAR2=VAL2] [...]
|
45
|
-
aptible config:unset [VAR1] [VAR2] [...]
|
46
|
-
aptible db:backup HANDLE
|
47
|
-
aptible db:clone SOURCE DEST
|
48
|
-
aptible db:create HANDLE [--type TYPE] [--version VERSION] [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--key-arn KEY_ARN]
|
49
|
-
aptible db:deprovision HANDLE
|
50
|
-
aptible db:dump HANDLE [pg_dump options]
|
51
|
-
aptible db:execute HANDLE SQL_FILE [--on-error-stop]
|
52
|
-
aptible db:list
|
53
|
-
aptible db:modify HANDLE [--iops IOPS] [--volume-type [gp2, gp3]]
|
54
|
-
aptible db:reload HANDLE
|
55
|
-
aptible db:rename OLD_HANDLE NEW_HANDLE [--environment ENVIRONMENT_HANDLE]
|
56
|
-
aptible db:replicate HANDLE REPLICA_HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--logical --version VERSION] [--key-arn KEY_ARN]
|
57
|
-
aptible db:restart HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--volume-type [gp2, gp3]]
|
58
|
-
aptible db:tunnel HANDLE
|
59
|
-
aptible db:url HANDLE
|
60
|
-
aptible db:versions
|
61
|
-
aptible deploy [OPTIONS] [VAR1=VAL1] [VAR2=VAL2] [...]
|
62
|
-
aptible endpoints:database:create DATABASE
|
63
|
-
aptible endpoints:database:modify --database DATABASE ENDPOINT_HOSTNAME
|
64
|
-
aptible endpoints:deprovision [--app APP | --database DATABASE] ENDPOINT_HOSTNAME
|
65
|
-
aptible endpoints:grpc:create [--app APP] SERVICE
|
66
|
-
aptible endpoints:grpc:modify [--app APP] ENDPOINT_HOSTNAME
|
67
|
-
aptible endpoints:https:create [--app APP] SERVICE
|
68
|
-
aptible endpoints:https:modify [--app APP] ENDPOINT_HOSTNAME
|
69
|
-
aptible endpoints:list [--app APP | --database DATABASE]
|
70
|
-
aptible endpoints:renew [--app APP] ENDPOINT_HOSTNAME
|
71
|
-
aptible endpoints:tcp:create [--app APP] SERVICE
|
72
|
-
aptible endpoints:tcp:modify [--app APP] ENDPOINT_HOSTNAME
|
73
|
-
aptible endpoints:tls:create [--app APP] SERVICE
|
74
|
-
aptible endpoints:tls:modify [--app APP] ENDPOINT_HOSTNAME
|
75
|
-
aptible environment:ca_cert
|
76
|
-
aptible environment:list
|
77
|
-
aptible environment:rename OLD_HANDLE NEW_HANDLE
|
78
|
-
aptible help [COMMAND]
|
79
|
-
aptible log_drain:create:datadog HANDLE --url DATADOG_URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false]
|
80
|
-
aptible log_drain:create:elasticsearch HANDLE --db DATABASE_HANDLE --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false]
|
81
|
-
aptible log_drain:create:https HANDLE --url URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false]
|
82
|
-
aptible log_drain:create:logdna HANDLE --url LOGDNA_URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false]
|
83
|
-
aptible log_drain:create:papertrail HANDLE --host PAPERTRAIL_HOST --port PAPERTRAIL_PORT --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false]
|
84
|
-
aptible log_drain:create:sumologic HANDLE --url SUMOLOGIC_URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false]
|
85
|
-
aptible log_drain:create:syslog HANDLE --host SYSLOG_HOST --port SYSLOG_PORT [--token TOKEN] --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false]
|
86
|
-
aptible log_drain:deprovision HANDLE --environment ENVIRONMENT
|
87
|
-
aptible log_drain:list
|
88
|
-
aptible login
|
89
|
-
aptible logs [--app APP | --database DATABASE]
|
90
|
-
aptible logs_from_archive --bucket NAME --region REGION --stack NAME [ --decryption-keys ONE [OR MORE] ] [ --download-location LOCATION ] [ [ --string-matches ONE [OR MORE] ] | [ --app-id ID | --database-id ID | --endpoint-id ID | --container-id ID ] [ --start-date YYYY-MM-DD --end-date YYYY-MM-DD ] ] --bucket=BUCKET --region=REGION --stack=STACK
|
91
|
-
aptible maintenance:apps
|
92
|
-
aptible maintenance:dbs
|
93
|
-
aptible metric_drain:create:datadog HANDLE --api_key DATADOG_API_KEY --site DATADOG_SITE --environment ENVIRONMENT
|
94
|
-
aptible metric_drain:create:influxdb HANDLE --db DATABASE_HANDLE --environment ENVIRONMENT
|
95
|
-
aptible metric_drain:create:influxdb:custom HANDLE --username USERNAME --password PASSWORD --url URL_INCLUDING_PORT --db INFLUX_DATABASE_NAME --environment ENVIRONMENT
|
96
|
-
aptible metric_drain:create:influxdb:customv2 HANDLE --org ORGANIZATION --token INFLUX_TOKEN --url URL_INCLUDING_PORT --bucket INFLUX_BUCKET_NAME --environment ENVIRONMENT
|
97
|
-
aptible metric_drain:deprovision HANDLE --environment ENVIRONMENT
|
98
|
-
aptible metric_drain:list
|
99
|
-
aptible operation:cancel OPERATION_ID
|
100
|
-
aptible operation:follow OPERATION_ID
|
101
|
-
aptible operation:logs OPERATION_ID
|
102
|
-
aptible rebuild
|
103
|
-
aptible restart
|
104
|
-
aptible services
|
105
|
-
aptible services:
|
106
|
-
aptible
|
107
|
-
aptible
|
29
|
+
aptible apps # List all applications
|
30
|
+
aptible apps:create HANDLE # Create a new application
|
31
|
+
aptible apps:deprovision # Deprovision an app
|
32
|
+
aptible apps:rename OLD_HANDLE NEW_HANDLE [--environment ENVIRONMENT_HANDLE] # Rename an app handle. In order for the new app handle to appear in log drain and metric drain destinations, you must restart the app.
|
33
|
+
aptible apps:scale SERVICE [--container-count COUNT] [--container-size SIZE_MB] [--container-profile PROFILE] # Scale a service
|
34
|
+
aptible backup:list DB_HANDLE # List backups for a database
|
35
|
+
aptible backup:orphaned # List backups associated with deprovisioned databases
|
36
|
+
aptible backup:purge BACKUP_ID # Permanently delete a backup and any copies of it
|
37
|
+
aptible backup:restore BACKUP_ID [--environment ENVIRONMENT_HANDLE] [--handle HANDLE] [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--key-arn KEY_ARN] # Restore a backup
|
38
|
+
aptible backup_retention_policy [ENVIRONMENT_HANDLE] # Show the current backup retention policy for the environment
|
39
|
+
aptible backup_retention_policy:set [ENVIRONMENT_HANDLE] [--daily DAILY_BACKUPS] [--monthly MONTHLY_BACKUPS] [--yearly YEARLY_BACKUPS] [--make-copy|--no-make-copy] [--keep-final|--no-keep-final] [--force] # Change the environment's backup retention policy
|
40
|
+
aptible config # Print an app's current configuration
|
41
|
+
aptible config:add [VAR1=VAL1] [VAR2=VAL2] [...] # Add an ENV variable to an app
|
42
|
+
aptible config:get [VAR1] # Print a specific key within an app's current configuration
|
43
|
+
aptible config:rm [VAR1] [VAR2] [...] # Remove an ENV variable from an app
|
44
|
+
aptible config:set [VAR1=VAL1] [VAR2=VAL2] [...] # Add an ENV variable to an app
|
45
|
+
aptible config:unset [VAR1] [VAR2] [...] # Remove an ENV variable from an app
|
46
|
+
aptible db:backup HANDLE # Backup a database
|
47
|
+
aptible db:clone SOURCE DEST # Clone a database to create a new one
|
48
|
+
aptible db:create HANDLE [--type TYPE] [--version VERSION] [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--key-arn KEY_ARN] # Create a new database
|
49
|
+
aptible db:deprovision HANDLE # Deprovision a database
|
50
|
+
aptible db:dump HANDLE [pg_dump options] # Dump a remote database to file
|
51
|
+
aptible db:execute HANDLE SQL_FILE [--on-error-stop] # Executes sql against a database
|
52
|
+
aptible db:list # List all databases
|
53
|
+
aptible db:modify HANDLE [--iops IOPS] [--volume-type [gp2, gp3]] # Modify a database disk
|
54
|
+
aptible db:reload HANDLE # Reload a database
|
55
|
+
aptible db:rename OLD_HANDLE NEW_HANDLE [--environment ENVIRONMENT_HANDLE] # Rename a database handle. In order for the new database handle to appear in log drain and metric drain destinations, you must reload the database.
|
56
|
+
aptible db:replicate HANDLE REPLICA_HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--logical --version VERSION] [--key-arn KEY_ARN] # Create a replica/follower of a database
|
57
|
+
aptible db:restart HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--volume-type [gp2, gp3]] # Restart a database
|
58
|
+
aptible db:tunnel HANDLE # Create a local tunnel to a database
|
59
|
+
aptible db:url HANDLE # Display a database URL
|
60
|
+
aptible db:versions # List available database versions
|
61
|
+
aptible deploy [OPTIONS] [VAR1=VAL1] [VAR2=VAL2] [...] # Deploy an app
|
62
|
+
aptible endpoints:database:create DATABASE # Create a Database Endpoint
|
63
|
+
aptible endpoints:database:modify --database DATABASE ENDPOINT_HOSTNAME # Modify a Database Endpoint
|
64
|
+
aptible endpoints:deprovision [--app APP | --database DATABASE] ENDPOINT_HOSTNAME # Deprovision an App or Database Endpoint
|
65
|
+
aptible endpoints:grpc:create [--app APP] SERVICE # Create an App gRPC Endpoint
|
66
|
+
aptible endpoints:grpc:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App gRPC Endpoint
|
67
|
+
aptible endpoints:https:create [--app APP] SERVICE # Create an App HTTPS Endpoint
|
68
|
+
aptible endpoints:https:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App HTTPS Endpoint
|
69
|
+
aptible endpoints:list [--app APP | --database DATABASE] # List Endpoints for an App or Database
|
70
|
+
aptible endpoints:renew [--app APP] ENDPOINT_HOSTNAME # Renew an App Managed TLS Endpoint
|
71
|
+
aptible endpoints:tcp:create [--app APP] SERVICE # Create an App TCP Endpoint
|
72
|
+
aptible endpoints:tcp:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App TCP Endpoint
|
73
|
+
aptible endpoints:tls:create [--app APP] SERVICE # Create an App TLS Endpoint
|
74
|
+
aptible endpoints:tls:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App TLS Endpoint
|
75
|
+
aptible environment:ca_cert # Retrieve the CA certificate associated with the environment
|
76
|
+
aptible environment:list # List all environments
|
77
|
+
aptible environment:rename OLD_HANDLE NEW_HANDLE # Rename an environment handle. In order for the new environment handle to appear in log drain/metric destinations, you must restart the apps/databases in this environment.
|
78
|
+
aptible help [COMMAND] # Describe available commands or one specific command
|
79
|
+
aptible log_drain:create:datadog HANDLE --url DATADOG_URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a Datadog Log Drain
|
80
|
+
aptible log_drain:create:elasticsearch HANDLE --db DATABASE_HANDLE --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create an Elasticsearch Log Drain
|
81
|
+
aptible log_drain:create:https HANDLE --url URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a HTTPS Drain
|
82
|
+
aptible log_drain:create:logdna HANDLE --url LOGDNA_URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a LogDNA Log Drain
|
83
|
+
aptible log_drain:create:papertrail HANDLE --host PAPERTRAIL_HOST --port PAPERTRAIL_PORT --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a Papertrail Log Drain
|
84
|
+
aptible log_drain:create:sumologic HANDLE --url SUMOLOGIC_URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a Sumologic Drain
|
85
|
+
aptible log_drain:create:syslog HANDLE --host SYSLOG_HOST --port SYSLOG_PORT [--token TOKEN] --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a Papertrail Log Drain
|
86
|
+
aptible log_drain:deprovision HANDLE --environment ENVIRONMENT # Deprovisions a log drain
|
87
|
+
aptible log_drain:list # List all Log Drains
|
88
|
+
aptible login # Log in to Aptible
|
89
|
+
aptible logs [--app APP | --database DATABASE] # Follows logs from a running app or database
|
90
|
+
aptible logs_from_archive --bucket NAME --region REGION --stack NAME [ --decryption-keys ONE [OR MORE] ] [ --download-location LOCATION ] [ [ --string-matches ONE [OR MORE] ] | [ --app-id ID | --database-id ID | --endpoint-id ID | --container-id ID ] [ --start-date YYYY-MM-DD --end-date YYYY-MM-DD ] ] --bucket=BUCKET --region=REGION --stack=STACK # Retrieves container logs from an S3 archive in your own AWS account. You must provide your AWS credentials via the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
|
91
|
+
aptible maintenance:apps # List Apps impacted by maintenance schedules where restarts are required
|
92
|
+
aptible maintenance:dbs # List Databases impacted by maintenance schedules where restarts are required
|
93
|
+
aptible metric_drain:create:datadog HANDLE --api_key DATADOG_API_KEY --site DATADOG_SITE --environment ENVIRONMENT # Create a Datadog Metric Drain
|
94
|
+
aptible metric_drain:create:influxdb HANDLE --db DATABASE_HANDLE --environment ENVIRONMENT # Create an InfluxDB Metric Drain
|
95
|
+
aptible metric_drain:create:influxdb:custom HANDLE --username USERNAME --password PASSWORD --url URL_INCLUDING_PORT --db INFLUX_DATABASE_NAME --environment ENVIRONMENT # Create an InfluxDB Metric Drain
|
96
|
+
aptible metric_drain:create:influxdb:customv2 HANDLE --org ORGANIZATION --token INFLUX_TOKEN --url URL_INCLUDING_PORT --bucket INFLUX_BUCKET_NAME --environment ENVIRONMENT # Create an InfluxDB v2 Metric Drain
|
97
|
+
aptible metric_drain:deprovision HANDLE --environment ENVIRONMENT # Deprovisions a Metric Drain
|
98
|
+
aptible metric_drain:list # List all Metric Drains
|
99
|
+
aptible operation:cancel OPERATION_ID # Cancel a running operation
|
100
|
+
aptible operation:follow OPERATION_ID # Follow logs of a running operation
|
101
|
+
aptible operation:logs OPERATION_ID # View logs for given operation
|
102
|
+
aptible rebuild # Rebuild an app, and restart its services
|
103
|
+
aptible restart # Restart all services associated with an app
|
104
|
+
aptible services # List Services for an App
|
105
|
+
aptible services:autoscaling_policy SERVICE # Returns the associated sizing policy, if any
|
106
|
+
aptible services:autoscaling_policy:set SERVICE --autoscaling-type (horizontal|vertical) [--metric-lookback-seconds SECONDS] [--percentile PERCENTILE] [--post-scale-up-cooldown-seconds SECONDS] [--post-scale-down-cooldown-seconds SECONDS] [--post-release-cooldown-seconds SECONDS] [--mem-cpu-ratio-r-threshold RATIO] [--mem-cpu-ratio-c-threshold RATIO] [--mem-scale-up-threshold THRESHOLD] [--mem-scale-down-threshold THRESHOLD] [--minimum-memory MEMORY] [--maximum-memory MEMORY] [--min-cpu-threshold THRESHOLD] [--max-cpu-threshold THRESHOLD] [--min-containers CONTAINERS] [--max-containers CONTAINERS] [--scale-up-step STEPS] [--scale-down-step STEPS] # Sets the sizing (autoscaling) policy for a service. This is not incremental, all arguments must be sent at once or they will be set to defaults.
|
107
|
+
aptible services:settings SERVICE [--force-zero-downtime|--no-force-zero-downtime] [--simple-health-check|--no-simple-health-check] # Modifies the zero-downtime deploy setting for a service
|
108
|
+
aptible ssh [COMMAND] # Run a command against an app
|
109
|
+
aptible version # Print Aptible CLI version
|
108
110
|
```
|
109
111
|
<!-- END USAGE -->
|
110
112
|
|
@@ -270,6 +270,35 @@ module Aptible
|
|
270
270
|
attach_account(node, account)
|
271
271
|
end
|
272
272
|
|
273
|
+
def inject_service_sizing_policy(node, policy, service)
|
274
|
+
node.value('autoscaling_type', policy.autoscaling)
|
275
|
+
node.value('metric_lookback_seconds', policy.metric_lookback_seconds)
|
276
|
+
node.value('percentile', policy.percentile)
|
277
|
+
node.value('post_scale_up_cooldown_seconds',
|
278
|
+
policy.post_scale_up_cooldown_seconds)
|
279
|
+
node.value('post_scale_down_cooldown_seconds',
|
280
|
+
policy.post_scale_down_cooldown_seconds)
|
281
|
+
node.value('post_release_cooldown_seconds',
|
282
|
+
policy.post_release_cooldown_seconds)
|
283
|
+
node.value('mem_cpu_ratio_r_threshold',
|
284
|
+
policy.mem_cpu_ratio_r_threshold)
|
285
|
+
node.value('mem_cpu_ratio_c_threshold',
|
286
|
+
policy.mem_cpu_ratio_c_threshold)
|
287
|
+
node.value('mem_scale_up_threshold', policy.mem_scale_up_threshold)
|
288
|
+
node.value('mem_scale_down_threshold',
|
289
|
+
policy.mem_scale_down_threshold)
|
290
|
+
node.value('minimum_memory', policy.minimum_memory)
|
291
|
+
node.value('maximum_memory', policy.maximum_memory)
|
292
|
+
node.value('min_cpu_threshold', policy.min_cpu_threshold)
|
293
|
+
node.value('max_cpu_threshold', policy.max_cpu_threshold)
|
294
|
+
node.value('min_containers', policy.min_containers)
|
295
|
+
node.value('max_containers', policy.max_containers)
|
296
|
+
node.value('scale_up_step', policy.scale_up_step)
|
297
|
+
node.value('scale_down_step', policy.scale_down_step)
|
298
|
+
|
299
|
+
attach_service(node, service)
|
300
|
+
end
|
301
|
+
|
273
302
|
private
|
274
303
|
|
275
304
|
def attach_account(node, account)
|
@@ -44,6 +44,162 @@ module Aptible
|
|
44
44
|
|
45
45
|
service.update!(**updates) if updates.any?
|
46
46
|
end
|
47
|
+
|
48
|
+
desc 'services:autoscaling_policy SERVICE',
|
49
|
+
'Returns the associated sizing policy, if any'
|
50
|
+
app_options
|
51
|
+
define_method 'services:autoscaling_policy' do |service|
|
52
|
+
service = ensure_service(options, service)
|
53
|
+
policy = service.service_sizing_policy
|
54
|
+
|
55
|
+
unless policy
|
56
|
+
raise Thor::Error, "Service #{service} does not have a " \
|
57
|
+
'service sizing policy set'
|
58
|
+
end
|
59
|
+
|
60
|
+
Formatter.render(Renderer.current) do |root|
|
61
|
+
root.object do |node|
|
62
|
+
ResourceFormatter.inject_service_sizing_policy(
|
63
|
+
node, policy, service
|
64
|
+
)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
no_commands do
|
69
|
+
alias_method 'services:sizing_policy',
|
70
|
+
'services:autoscaling_policy'
|
71
|
+
end
|
72
|
+
|
73
|
+
desc 'services:autoscaling_policy:set SERVICE '\
|
74
|
+
'--autoscaling-type (horizontal|vertical) '\
|
75
|
+
'[--metric-lookback-seconds SECONDS] '\
|
76
|
+
'[--percentile PERCENTILE] '\
|
77
|
+
'[--post-scale-up-cooldown-seconds SECONDS] '\
|
78
|
+
'[--post-scale-down-cooldown-seconds SECONDS] '\
|
79
|
+
'[--post-release-cooldown-seconds SECONDS] '\
|
80
|
+
'[--mem-cpu-ratio-r-threshold RATIO] '\
|
81
|
+
'[--mem-cpu-ratio-c-threshold RATIO] '\
|
82
|
+
'[--mem-scale-up-threshold THRESHOLD] '\
|
83
|
+
'[--mem-scale-down-threshold THRESHOLD] '\
|
84
|
+
'[--minimum-memory MEMORY] '\
|
85
|
+
'[--maximum-memory MEMORY] '\
|
86
|
+
'[--min-cpu-threshold THRESHOLD] '\
|
87
|
+
'[--max-cpu-threshold THRESHOLD] '\
|
88
|
+
'[--min-containers CONTAINERS] '\
|
89
|
+
'[--max-containers CONTAINERS] '\
|
90
|
+
'[--scale-up-step STEPS] '\
|
91
|
+
'[--scale-down-step STEPS] ',
|
92
|
+
'Sets the sizing (autoscaling) policy for a service.'\
|
93
|
+
' This is not incremental, all arguments must be sent'\
|
94
|
+
' at once or they will be set to defaults.'
|
95
|
+
app_options
|
96
|
+
option :autoscaling_type,
|
97
|
+
type: :string,
|
98
|
+
desc: 'The type of autoscaling. Must be either '\
|
99
|
+
'"horizontal" or "vertical"'
|
100
|
+
option :metric_lookback_seconds,
|
101
|
+
type: :numeric,
|
102
|
+
desc: '(Default: 1800) The duration in seconds for '\
|
103
|
+
'retrieving past performance metrics.'
|
104
|
+
option :percentile,
|
105
|
+
type: :numeric,
|
106
|
+
desc: '(Default: 99) The percentile for evaluating metrics.'
|
107
|
+
option :post_scale_up_cooldown_seconds,
|
108
|
+
type: :numeric,
|
109
|
+
desc: '(Default: 60) The waiting period in seconds after '\
|
110
|
+
'an automated scale-up before another scaling action can '\
|
111
|
+
'be considered.'
|
112
|
+
option :post_scale_down_cooldown_seconds,
|
113
|
+
type: :numeric,
|
114
|
+
desc: '(Default: 300) The waiting period in seconds after '\
|
115
|
+
'an automated scale-down before another scaling action can '\
|
116
|
+
'be considered.'
|
117
|
+
option :post_release_cooldown_seconds,
|
118
|
+
type: :numeric,
|
119
|
+
desc: '(Default: 300) The time in seconds to wait '\
|
120
|
+
'following a deploy before another scaling action can '\
|
121
|
+
'be considered.'
|
122
|
+
option :mem_cpu_ratio_r_threshold,
|
123
|
+
type: :numeric,
|
124
|
+
desc: '(Default: 4.0) Establishes the ratio of Memory '\
|
125
|
+
'(in GB) to CPU (in CPUs) at which values exceeding the '\
|
126
|
+
'threshold prompt a shift to an R (Memory Optimized) '\
|
127
|
+
'profile.'
|
128
|
+
option :mem_cpu_ratio_c_threshold,
|
129
|
+
type: :numeric,
|
130
|
+
desc: '(Default: 2.0) Sets the Memory-to-CPU ratio '\
|
131
|
+
'threshold, below which the service is transitioned to a '\
|
132
|
+
'C (Compute Optimized) profile.'
|
133
|
+
option :mem_scale_up_threshold,
|
134
|
+
type: :numeric,
|
135
|
+
desc: '(Default: 0.9) Vertical autoscaling only - '\
|
136
|
+
'Specifies the percentage of the current memory limit '\
|
137
|
+
'at which the service’s memory usage triggers an '\
|
138
|
+
'up-scaling action.'
|
139
|
+
option :mem_scale_down_threshold,
|
140
|
+
type: :numeric,
|
141
|
+
desc: '(Default: 0.75) Vertical autoscaling only - '\
|
142
|
+
'Specifies the percentage of the current memory limit at '\
|
143
|
+
'which the service’s memory usage triggers a '\
|
144
|
+
'down-scaling action.'
|
145
|
+
option :minimum_memory,
|
146
|
+
type: :numeric,
|
147
|
+
desc: '(Default: 2048) Vertical autoscaling only - Sets '\
|
148
|
+
'the lowest memory limit to which the service can be '\
|
149
|
+
'scaled down by Autoscaler.'
|
150
|
+
option :maximum_memory,
|
151
|
+
type: :numeric,
|
152
|
+
desc: 'Vertical autoscaling only - Defines the upper '\
|
153
|
+
'memory threshold, capping the maximum memory allocation'\
|
154
|
+
' possible through Autoscaler. If blank, the container can'\
|
155
|
+
' scale to the largest size available.'
|
156
|
+
option :min_cpu_threshold,
|
157
|
+
type: :numeric,
|
158
|
+
desc: 'Horizontal autoscaling only - Specifies the '\
|
159
|
+
'percentage of the current CPU usage at which a '\
|
160
|
+
'down-scaling action is triggered.'
|
161
|
+
option :max_cpu_threshold,
|
162
|
+
type: :numeric,
|
163
|
+
desc: 'Horizontal autoscaling only - Specifies the '\
|
164
|
+
'percentage of the current CPU usage at which an '\
|
165
|
+
'up-scaling action is triggered.'
|
166
|
+
option :min_containers,
|
167
|
+
type: :numeric,
|
168
|
+
desc: 'Horizontal autoscaling only - Sets the lowest'\
|
169
|
+
' container count to which the service can be scaled down.'
|
170
|
+
option :max_containers,
|
171
|
+
type: :numeric,
|
172
|
+
desc: 'Horizontal autoscaling only - Sets the highest '\
|
173
|
+
'container count to which the service can be scaled up to.'
|
174
|
+
option :scale_up_step,
|
175
|
+
type: :numeric,
|
176
|
+
desc: '(Default: 1) Horizontal autoscaling only - Sets '\
|
177
|
+
'the amount of containers to add when autoscaling (ex: a '\
|
178
|
+
'value of 2 will go from 1->3->5). Container count will '\
|
179
|
+
'never exceed the configured maximum.'
|
180
|
+
option :scale_down_step,
|
181
|
+
type: :numeric,
|
182
|
+
desc: '(Default: 1) Horizontal autoscaling only - Sets '\
|
183
|
+
'the amount of containers to remove when autoscaling (ex:'\
|
184
|
+
' a value of 2 will go from 4->2->1). Container count '\
|
185
|
+
'will never exceed the configured minimum.'
|
186
|
+
define_method 'services:autoscaling_policy:set' do |service|
|
187
|
+
service = ensure_service(options, service)
|
188
|
+
ignored_attrs = %i(autoscaling_type app environment remote)
|
189
|
+
args = options.except(*ignored_attrs)
|
190
|
+
args[:autoscaling] = options[:autoscaling_type]
|
191
|
+
|
192
|
+
sizing_policy = service.service_sizing_policy
|
193
|
+
if sizing_policy
|
194
|
+
sizing_policy.update!(**args)
|
195
|
+
else
|
196
|
+
service.create_service_sizing_policy!(**args)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
no_commands do
|
200
|
+
alias_method 'services:sizing_policy:set',
|
201
|
+
'services:autoscaling_policy:set'
|
202
|
+
end
|
47
203
|
end
|
48
204
|
end
|
49
205
|
end
|
data/lib/aptible/cli/version.rb
CHANGED
@@ -79,6 +79,116 @@ describe Aptible::CLI::Agent do
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
+
describe '#services:sizing_policy' do
|
83
|
+
let(:base_options) { { app: app.handle } }
|
84
|
+
|
85
|
+
it 'returns the sizing policy' do
|
86
|
+
stub_options
|
87
|
+
service = Fabricate(:service, app: app, process_type: 'foo')
|
88
|
+
sizing_policy = Fabricate(:service_sizing_policy)
|
89
|
+
expect(service).to receive(:service_sizing_policy)
|
90
|
+
.and_return(sizing_policy)
|
91
|
+
|
92
|
+
subject.send('services:sizing_policy', 'foo')
|
93
|
+
|
94
|
+
out = captured_output_text
|
95
|
+
expect(out).to match(/Autoscaling Type: vertical/i)
|
96
|
+
expect(out).to match(/Metric Lookback Seconds: 1800/i)
|
97
|
+
expect(out).to match(/Percentile: 99.0/i)
|
98
|
+
expect(out).to match(/Post Scale Up Cooldown Seconds: 60/i)
|
99
|
+
expect(out).to match(/Post Scale Down Cooldown Seconds: 300/i)
|
100
|
+
expect(out).to match(/Post Release Cooldown Seconds: 300/i)
|
101
|
+
expect(out).to match(/Mem Cpu Ratio R Threshold: 4/i)
|
102
|
+
expect(out).to match(/Mem Cpu Ratio C Threshold: 2/i)
|
103
|
+
expect(out).to match(/Mem Scale Up Threshold: 0.9/i)
|
104
|
+
expect(out).to match(/Mem Scale Down Threshold: 0.75/i)
|
105
|
+
expect(out).to match(/Minimum Memory: 2048/i)
|
106
|
+
expect(out).to match(/Maximum Memory:/i)
|
107
|
+
expect(out).to match(/Min Cpu Threshold: 0.4/i)
|
108
|
+
expect(out).to match(/Max Cpu Threshold: 0.9/i)
|
109
|
+
expect(out).to match(/Min Containers: 2/i)
|
110
|
+
expect(out).to match(/Max Containers: 5/i)
|
111
|
+
expect(out).to match(/Scale Up Step: 1/i)
|
112
|
+
expect(out).to match(/Scale Down Step: 1/i)
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'raises an error if the environment has no policy' do
|
116
|
+
stub_options
|
117
|
+
service = Fabricate(:service, app: app, process_type: 'foo')
|
118
|
+
expect(service).to receive(:service_sizing_policy).and_return(nil)
|
119
|
+
expect { subject.send('services:sizing_policy', 'foo') }
|
120
|
+
.to raise_error(/does not have a service sizing policy set/)
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'is aliased to autoscaling_policy' do
|
124
|
+
stub_options
|
125
|
+
service = Fabricate(:service, app: app, process_type: 'foo')
|
126
|
+
sizing_policy = Fabricate(:service_sizing_policy)
|
127
|
+
expect(service).to receive(:service_sizing_policy)
|
128
|
+
.and_return(sizing_policy)
|
129
|
+
|
130
|
+
subject.send('services:autoscaling_policy', 'foo')
|
131
|
+
|
132
|
+
out = captured_output_text
|
133
|
+
expect(out).to match(/Autoscaling Type: vertical/i)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe '#services:sizing_policy:set' do
|
138
|
+
let(:base_options) { { app: app.handle } }
|
139
|
+
let(:args) do
|
140
|
+
{
|
141
|
+
autoscaling_type: 'vertical',
|
142
|
+
mem_scale_down_threshold: 0.5,
|
143
|
+
scale_up_step: 2,
|
144
|
+
post_scale_down_cooldown_seconds: 3,
|
145
|
+
percentile: 93.2
|
146
|
+
}
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'updates existing sizing policy' do
|
150
|
+
stub_options(**args)
|
151
|
+
service = Fabricate(:service, app: app, process_type: 'foo')
|
152
|
+
sizing_policy = double(sizing_policy)
|
153
|
+
expect(service).to receive(:service_sizing_policy)
|
154
|
+
.and_return(sizing_policy)
|
155
|
+
|
156
|
+
api_args = args.except(:autoscaling_type)
|
157
|
+
api_args[:autoscaling] = args[:autoscaling_type]
|
158
|
+
|
159
|
+
expect(sizing_policy).to receive(:update!)
|
160
|
+
.with(**api_args)
|
161
|
+
|
162
|
+
subject.send('services:sizing_policy:set', 'foo')
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'creates a new sizing policy if necessary' do
|
166
|
+
stub_options(**args)
|
167
|
+
service = Fabricate(:service, app: app, process_type: 'foo')
|
168
|
+
|
169
|
+
api_args = args.except(:autoscaling_type)
|
170
|
+
api_args[:autoscaling] = args[:autoscaling_type]
|
171
|
+
|
172
|
+
expect(service).to receive(:create_service_sizing_policy!)
|
173
|
+
.with(**api_args)
|
174
|
+
|
175
|
+
subject.send('services:sizing_policy:set', 'foo')
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'is aliased to autoscaling_policy:set' do
|
179
|
+
stub_options(**args)
|
180
|
+
service = Fabricate(:service, app: app, process_type: 'foo')
|
181
|
+
|
182
|
+
api_args = args.except(:autoscaling_type)
|
183
|
+
api_args[:autoscaling] = args[:autoscaling_type]
|
184
|
+
|
185
|
+
expect(service).to receive(:create_service_sizing_policy!)
|
186
|
+
.with(**api_args)
|
187
|
+
|
188
|
+
subject.send('services:autoscaling_policy:set', 'foo')
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
82
192
|
def stub_options(**opts)
|
83
193
|
allow(subject).to receive(:options).and_return(base_options.merge(opts))
|
84
194
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class StubServiceSizingPolicy < OpenStruct; end
|
2
|
+
|
3
|
+
Fabricator(:service_sizing_policy, from: :stub_service_sizing_policy) do
|
4
|
+
autoscaling 'vertical'
|
5
|
+
metric_lookback_seconds 1800
|
6
|
+
percentile 99.0
|
7
|
+
post_scale_up_cooldown_seconds 60
|
8
|
+
post_scale_down_cooldown_seconds 300
|
9
|
+
post_release_cooldown_seconds 300
|
10
|
+
mem_cpu_ratio_r_threshold 4
|
11
|
+
mem_cpu_ratio_c_threshold 2
|
12
|
+
mem_scale_up_threshold 0.9
|
13
|
+
mem_scale_down_threshold 0.75
|
14
|
+
minimum_memory 2048
|
15
|
+
maximum_memory nil
|
16
|
+
min_cpu_threshold 0.4
|
17
|
+
max_cpu_threshold 0.9
|
18
|
+
min_containers 2
|
19
|
+
max_containers 5
|
20
|
+
scale_up_step 1
|
21
|
+
scale_down_step 1
|
22
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aptible-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Macreery
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -455,6 +455,7 @@ files:
|
|
455
455
|
- spec/fabricators/metric_drain_fabricator.rb
|
456
456
|
- spec/fabricators/operation_fabricator.rb
|
457
457
|
- spec/fabricators/service_fabricator.rb
|
458
|
+
- spec/fabricators/service_sizing_policy_fabricator.rb
|
458
459
|
- spec/fabricators/stack_fabricator.rb
|
459
460
|
- spec/fabricators/vhost_fabricator.rb
|
460
461
|
- spec/mock/git
|
@@ -541,6 +542,7 @@ test_files:
|
|
541
542
|
- spec/fabricators/metric_drain_fabricator.rb
|
542
543
|
- spec/fabricators/operation_fabricator.rb
|
543
544
|
- spec/fabricators/service_fabricator.rb
|
545
|
+
- spec/fabricators/service_sizing_policy_fabricator.rb
|
544
546
|
- spec/fabricators/stack_fabricator.rb
|
545
547
|
- spec/fabricators/vhost_fabricator.rb
|
546
548
|
- spec/mock/git
|