ufo 6.0.5 → 6.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/lib/templates/init/.ufo/config.rb.tt +10 -9
- data/lib/ufo/aws_services.rb +7 -0
- data/lib/ufo/booter.rb +1 -1
- data/lib/ufo/cfn/stack/builder/resources/scaling/target.rb +27 -2
- data/lib/ufo/cfn/stack/vars.rb +23 -15
- data/lib/ufo/cfn/stack.rb +2 -18
- data/lib/ufo/cli/help/ship.md +0 -4
- data/lib/ufo/cli/scale.rb +12 -6
- data/lib/ufo/config.rb +6 -5
- data/lib/ufo/info.rb +1 -1
- data/lib/ufo/version.rb +1 -1
- data/lib/ufo/yaml/validator.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ebcf583b29f7a6bd3e78d01091d1c993799b3ee3b30f139ae13fec372ca6328
|
4
|
+
data.tar.gz: 745a00ef65d3788e2b986f33cde18d763ee2167f205e1e7ed2d4340be2383529
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c511ee4143f521d907ffd066fa2bd2c15b8dbad9a4e647e7646418ed936a7c3f4956f8e142eb551c53990be6bb6ae049bd29c6022dcefd311a420ba204f725ae
|
7
|
+
data.tar.gz: e55927bdc1d09f921c35f27ceaac142022d7fd2a73fefd0fa9e96cff6b846340e01f540be09669f0f03ab31c8c39e4f16ed60202b20cb47d02fee5ab9235c21d
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,22 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [6.0.8] - 2022-03-10
|
7
|
+
- [#135](https://github.com/tongueroo/ufo/pull/135) improve .ufo/config/boot.rb location
|
8
|
+
- change default config.ship.docker.quiet to false
|
9
|
+
|
10
|
+
## [6.0.7] - 2022-03-07
|
11
|
+
- fix autoscaling.manual_changes.retain check
|
12
|
+
- improve Configured autoscaling message
|
13
|
+
|
14
|
+
## [6.0.6] - 2022-03-07
|
15
|
+
- [#134](https://github.com/tongueroo/ufo/pull/134) config.autoscaling.manual_changes.retain support
|
16
|
+
- change default `elb.healthy_threshold_count = 3`
|
17
|
+
- change default `config.ship.docker.quiet = true`
|
18
|
+
- config.autoscaling.manual_changes.retain support
|
19
|
+
- fix yaml validator print code
|
20
|
+
- ship cli help
|
21
|
+
|
6
22
|
## [6.0.5] - 2022-03-07
|
7
23
|
- change default config.ship.docker.quiet = true
|
8
24
|
|
@@ -4,36 +4,37 @@ Ufo.configure do |config|
|
|
4
4
|
config.docker.repo = "<%= @repo %>"
|
5
5
|
# config.ecs.cluster = ":ENV" # :ENV pattern is replaced with UFO_ENV. Default is UFO_ENV=dev
|
6
6
|
|
7
|
-
#
|
7
|
+
# VPC Docs: https://ufoships.com/docs/config/vpc/
|
8
8
|
# When not set, it's assumed that the ECS cluster using default vpc and default subnets.
|
9
9
|
# Notice the ability to use `stack_output` helpers to set the values.
|
10
10
|
# config.vpc.id = stack_output("vpc-:ENV.Vpc")
|
11
11
|
# config.vpc.subnets.ecs = stack_output("vpc-:ENV.PrivateAppSubnets").split(',')
|
12
12
|
# config.vpc.subnets.elb = stack_output("vpc-:ENV.PublicSubnets").split(',')
|
13
13
|
|
14
|
-
#
|
14
|
+
# AutoScaling Docs: https://ufoships.com/docs/features/autoscaling/
|
15
15
|
# config.autoscaling.enabled = true
|
16
|
-
# config.autoscaling.
|
16
|
+
# config.autoscaling.manual_changes.retain = false
|
17
17
|
# config.autoscaling.max_capacity = 3
|
18
|
+
# config.autoscaling.min_capacity = 2
|
18
19
|
# config.autoscaling.target_value = 50.0
|
19
20
|
|
20
|
-
#
|
21
|
+
# Route DNS Docs: https://ufoships.com/docs/features/dns-route53-support/
|
21
22
|
# config.dns.domain = "domain.com"
|
22
23
|
|
23
|
-
#
|
24
|
+
# Ufo exec Docs: https://ufoships.com/docs/intro/ufo-exec/
|
24
25
|
# bash is default but may not be available your Docker image
|
25
26
|
# Configure to /bin/sh if needed
|
26
|
-
# config.
|
27
|
+
# config.exec.command = "/bin/bash"
|
27
28
|
|
28
|
-
#
|
29
|
+
# Docs: https://ufoships.com/docs/config/reference/
|
29
30
|
# config.ps.summary = false # false to turn off the summary at top of ufo ps output
|
30
31
|
# config.ps.format = "table" # Examples: csv table tab json
|
31
32
|
|
32
|
-
#
|
33
|
+
# Docs: https://ufoships.com/docs/config/reference/
|
33
34
|
# Note: the `-` (minus sign) in front rejects the pattern
|
34
35
|
# config.logs.filter_pattern = '- "HealthChecker"'
|
35
36
|
|
36
|
-
#
|
37
|
+
# Docs: https://ufoships.com/docs/config/reference/
|
37
38
|
# You may want to set to false if your docker build and push process takes a while
|
38
39
|
# config.ship.docker.quiet = false # default is true.
|
39
40
|
end
|
data/lib/ufo/aws_services.rb
CHANGED
@@ -103,6 +103,13 @@ module Ufo
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
+
def stack_resources(stack_name)
|
107
|
+
resp = cloudformation.describe_stack_resources(stack_name: stack_name)
|
108
|
+
resp.stack_resources
|
109
|
+
rescue Aws::CloudFormation::Errors::ValidationError => e
|
110
|
+
e.message.include?("does not exist") ? return : raise
|
111
|
+
end
|
112
|
+
|
106
113
|
def task_definition_arns(family, max_items=10)
|
107
114
|
resp = ecs.list_task_definitions(
|
108
115
|
family_prefix: family,
|
data/lib/ufo/booter.rb
CHANGED
@@ -13,10 +13,35 @@ module Ufo::Cfn::Stack::Builder::Resources::Scaling
|
|
13
13
|
- [service, #{@cluster}, !GetAtt [EcsService, Name]]
|
14
14
|
ServiceNamespace: ecs
|
15
15
|
ScalableDimension: ecs:service:DesiredCount
|
16
|
-
MinCapacity: #{
|
17
|
-
MaxCapacity: #{
|
16
|
+
MinCapacity: #{min_capacity}
|
17
|
+
MaxCapacity: #{max_capacity}
|
18
18
|
EOL
|
19
19
|
Ufo::Yaml.load(text).deep_symbolize_keys
|
20
20
|
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def min_capacity
|
24
|
+
return autoscaling.min_capacity if vars[:new_stack] || !autoscaling.manual_changes.retain
|
25
|
+
scalable_target ? scalable_target.min_capacity : autoscaling.min_capacity
|
26
|
+
end
|
27
|
+
|
28
|
+
def max_capacity
|
29
|
+
return autoscaling.max_capacity if vars[:new_stack] || !autoscaling.manual_changes.retain
|
30
|
+
scalable_target ? scalable_target.max_capacity : autoscaling.max_capacity
|
31
|
+
end
|
32
|
+
|
33
|
+
def scalable_target
|
34
|
+
resources = stack_resources(vars[:stack_name])
|
35
|
+
return unless resources
|
36
|
+
ecs_service = resources.find { |r| r.logical_resource_id == "EcsService" }
|
37
|
+
service_name = File.basename(ecs_service.physical_resource_id) # IE: demo-web-dev-EcsService-Tw0nPMgpkmm4
|
38
|
+
resource_id = "service/#{vars[:cluster]}/#{service_name}"
|
39
|
+
resp = applicationautoscaling.describe_scalable_targets(
|
40
|
+
service_namespace: "ecs",
|
41
|
+
resource_ids: [resource_id],
|
42
|
+
)
|
43
|
+
resp.scalable_targets.first
|
44
|
+
end
|
45
|
+
memoize :scalable_target
|
21
46
|
end
|
22
47
|
end
|
data/lib/ufo/cfn/stack/vars.rb
CHANGED
@@ -1,33 +1,41 @@
|
|
1
1
|
class Ufo::Cfn::Stack
|
2
2
|
class Vars < Ufo::Cfn::Base
|
3
3
|
attr_reader :stack_name
|
4
|
-
def initialize(options={})
|
5
|
-
super
|
6
|
-
@cluster = options[:cluster].dup # Thor options are frozen, we thaw it because CustomProperties#substitute_variables does a sub!
|
7
|
-
@stack_name = options[:stack_name] || [Ufo.app, @task_definition.role, Ufo.env].join('-')
|
8
|
-
@stack = options[:stack]
|
9
|
-
@new_stack = !@stack
|
10
|
-
end
|
11
4
|
|
12
5
|
def values
|
6
|
+
# Not passing stack down to vars beause its easier to debug. Will require another lookup by thats ok
|
13
7
|
{
|
14
8
|
cluster: @cluster,
|
15
|
-
stack_name: @stack_name, # used in custom_properties
|
16
9
|
container: container,
|
17
|
-
# to reconstruct TaskDefinition in the CloudFormation template
|
18
|
-
task_definition: @task_definition,
|
19
|
-
rollback_task_definition: @options[:rollback_task_definition],
|
20
|
-
# elb options remember that their 'state'
|
21
10
|
create_elb: create_elb?, # helps set Ecs DependsOn
|
22
|
-
|
11
|
+
create_listener_ssl: create_listener_ssl?,
|
23
12
|
create_route53: create_elb? && dns_configured?,
|
24
|
-
default_target_group_protocol: default_target_group_protocol,
|
25
13
|
default_listener_protocol: default_listener_protocol,
|
26
14
|
default_listener_ssl_protocol: default_listener_ssl_protocol,
|
27
|
-
|
15
|
+
default_target_group_protocol: default_target_group_protocol,
|
16
|
+
elb_type: elb_type,
|
17
|
+
new_stack: new_stack,
|
18
|
+
rollback_task_definition: rollback_task_definition,
|
19
|
+
stack_name: @stack_name, # used in custom_properties
|
20
|
+
task_definition: @task_definition, # to reconstruct TaskDefinition for CloudFormation template
|
28
21
|
}
|
29
22
|
end
|
30
23
|
|
24
|
+
def new_stack
|
25
|
+
!stack
|
26
|
+
end
|
27
|
+
|
28
|
+
# Find stack in vars to ensure both ufo build and ufo ship can tell if stack has already been built
|
29
|
+
def stack
|
30
|
+
find_stack(@stack_name)
|
31
|
+
end
|
32
|
+
memoize :stack
|
33
|
+
|
34
|
+
def rollback_task_definition
|
35
|
+
return unless @options[:rollback]
|
36
|
+
@options[:rollback_task_definition]
|
37
|
+
end
|
38
|
+
|
31
39
|
def dns_configured?
|
32
40
|
!!Ufo.config.dns.domain || !!Ufo.config.dns.name
|
33
41
|
end
|
data/lib/ufo/cfn/stack.rb
CHANGED
@@ -78,35 +78,19 @@ module Ufo::Cfn
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def build
|
81
|
-
|
81
|
+
vars = Vars.new(@options).values
|
82
|
+
options_with_vars = @options.dup.merge(vars: vars)
|
82
83
|
params = Params.new(options_with_vars)
|
83
84
|
@parameters = params.build
|
84
85
|
template = Template.new(options_with_vars)
|
85
86
|
@template_body = template.body
|
86
87
|
end
|
87
88
|
|
88
|
-
def vars
|
89
|
-
o = @options.merge(
|
90
|
-
cluster: @cluster,
|
91
|
-
stack_name: @stack_name,
|
92
|
-
stack: @stack,
|
93
|
-
)
|
94
|
-
o[:rollback_task_definition] = rollback_task_definition if rollback_task_definition
|
95
|
-
Vars.new(o)
|
96
|
-
end
|
97
|
-
memoize :vars
|
98
|
-
|
99
89
|
def scheduling_strategy
|
100
90
|
scheduling_strategy = Ufo.config.ecs.scheduling_strategy
|
101
91
|
scheduling_strategy.upcase if scheduling_strategy
|
102
92
|
end
|
103
93
|
|
104
|
-
def rollback_task_definition
|
105
|
-
return unless @options[:rollback]
|
106
|
-
@options[:rollback_task_definition]
|
107
|
-
end
|
108
|
-
memoize :rollback_task_definition
|
109
|
-
|
110
94
|
def exit_with_message(stack)
|
111
95
|
url = "https://console.aws.amazon.com/cloudformation/home?region=#{region}#/stacks"
|
112
96
|
logger.info "The stack is not in an updateable state: #{stack.stack_status.color(:yellow)}."
|
data/lib/ufo/cli/help/ship.md
CHANGED
data/lib/ufo/cli/scale.rb
CHANGED
@@ -46,7 +46,10 @@ class Ufo::CLI
|
|
46
46
|
r.logical_resource_id == "ScalingTarget"
|
47
47
|
end
|
48
48
|
register_scalable_target(scalable_target)
|
49
|
-
|
49
|
+
to = []
|
50
|
+
to << "min: #{@min}" if @min
|
51
|
+
to << "max: #{@max}" if @max
|
52
|
+
logger.info "Configured autoscaling to #{to.join(' ')}"
|
50
53
|
end
|
51
54
|
|
52
55
|
def register_scalable_target(scalable_target)
|
@@ -65,18 +68,21 @@ class Ufo::CLI
|
|
65
68
|
end
|
66
69
|
|
67
70
|
def warning
|
68
|
-
|
71
|
+
autoscaling = Ufo.config.autoscaling
|
72
|
+
return if autoscaling.manual_changes.warning == false or autoscaling.manual_changes.retain
|
69
73
|
logger.info <<~EOL
|
70
74
|
Note: The settings are temporary.
|
71
75
|
They can be overwritten in the next `ufo ship` deploy.
|
72
|
-
To make the settings permanent update your ufo config.
|
73
76
|
|
74
|
-
|
77
|
+
You can turn off this warning with
|
75
78
|
|
76
|
-
|
79
|
+
config.autoscaling.warning = false
|
77
80
|
|
78
|
-
|
81
|
+
Or you can use the
|
79
82
|
|
83
|
+
config.autoscaling.manual_changes.retain = true
|
84
|
+
|
85
|
+
For considerations, see: https://ufoships.com/docs/features/autoscaling/
|
80
86
|
EOL
|
81
87
|
end
|
82
88
|
end
|
data/lib/ufo/config.rb
CHANGED
@@ -21,6 +21,9 @@ module Ufo
|
|
21
21
|
|
22
22
|
config.autoscaling = ActiveSupport::OrderedOptions.new
|
23
23
|
config.autoscaling.enabled = true
|
24
|
+
config.autoscaling.manual_changes = ActiveSupport::OrderedOptions.new
|
25
|
+
config.autoscaling.manual_changes.retain = false
|
26
|
+
config.autoscaling.manual_changes.warning = true
|
24
27
|
config.autoscaling.max_capacity = 5 # dont use max thats an OrderedOptions method
|
25
28
|
config.autoscaling.min_capacity = 1 # dont use min thats an OrderedOptions method
|
26
29
|
config.autoscaling.predefined_metric_type = "ECSServiceAverageCPUUtilization"
|
@@ -28,6 +31,7 @@ module Ufo
|
|
28
31
|
config.autoscaling.scale_out_cooldown = nil
|
29
32
|
config.autoscaling.target_value = 75.0
|
30
33
|
|
34
|
+
|
31
35
|
config.cfn = ActiveSupport::OrderedOptions.new
|
32
36
|
config.cfn.disable_rollback = nil
|
33
37
|
config.cfn.notification_arns = nil
|
@@ -59,9 +63,9 @@ module Ufo
|
|
59
63
|
config.elb.default_actions = nil # full override
|
60
64
|
config.elb.enabled = "auto" # "auto", true or false
|
61
65
|
|
62
|
-
config.elb.health_check_interval_seconds = 10
|
66
|
+
config.elb.health_check_interval_seconds = 10 # keep at 10 in case of network ELB, which is min 10
|
63
67
|
config.elb.health_check_path = nil # When nil its AWS default /
|
64
|
-
config.elb.healthy_threshold_count = 5
|
68
|
+
config.elb.healthy_threshold_count = 3 # The AWS usual default is 5
|
65
69
|
config.elb.unhealthy_threshold_count = 2
|
66
70
|
|
67
71
|
config.elb.port = 80 # default listener port
|
@@ -105,9 +109,6 @@ module Ufo
|
|
105
109
|
config.secrets.pattern.ssm = ":APP/:ENV/:SECRET_NAME" # => demo/dev/DB_PASS
|
106
110
|
config.secrets.provider = "ssm" # default provider for conventional expansion IE: ssm or secretsmanager
|
107
111
|
|
108
|
-
config.scale = ActiveSupport::OrderedOptions.new
|
109
|
-
config.scale.warning = true
|
110
|
-
|
111
112
|
config.ship = ActiveSupport::OrderedOptions.new
|
112
113
|
config.ship.docker = ActiveSupport::OrderedOptions.new
|
113
114
|
config.ship.docker.quiet = false # only affects ufo ship docker commands output
|
data/lib/ufo/info.rb
CHANGED
data/lib/ufo/version.rb
CHANGED
data/lib/ufo/yaml/validator.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ufo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
4
|
+
version: 6.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-logs
|