hako 2.14.0 → 2.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -1
- data/.rubocop_todo.yml +0 -2
- data/.travis.yml +3 -7
- data/CHANGELOG.md +4 -0
- data/examples/hello-grpc.jsonnet +60 -0
- data/hako.gemspec +2 -2
- data/lib/hako/commander.rb +2 -2
- data/lib/hako/env_providers/file.rb +1 -1
- data/lib/hako/env_providers/yaml.rb +1 -1
- data/lib/hako/schedulers/ecs.rb +32 -33
- data/lib/hako/schedulers/ecs_autoscaling.rb +1 -3
- data/lib/hako/schedulers/ecs_elb_v2.rb +9 -0
- data/lib/hako/scripts/nginx_front.rb +1 -1
- data/lib/hako/version.rb +1 -1
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c1298dda5d9e120f1856ed3a559c520451b1023384d1a56bd921f66c70f6da5
|
4
|
+
data.tar.gz: 833a89a305a9e075df8016e90a7d4ad45f18c29ad208197e3ebdacba5a60848b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfba96a068f38a760e7760188574e7b5afe2dd5400ce745905f3611f71fe18f87d2cbe446878c2d00ee55e56b423ac0185baa96c91737b10847f3f77442d5035
|
7
|
+
data.tar.gz: cfa5202766106d88e125cba58011fcccff3954a843c2fdc56a301e62d476239b1ae955b627de3dfbcf185e08bfb721418669c6f86548f68d55765f164e969e56
|
data/.rubocop.yml
CHANGED
@@ -2,10 +2,13 @@ inherit_from: .rubocop_todo.yml
|
|
2
2
|
|
3
3
|
AllCops:
|
4
4
|
DisplayCopNames: true
|
5
|
-
TargetRubyVersion: 2.
|
5
|
+
TargetRubyVersion: 2.5
|
6
|
+
NewCops: disable
|
6
7
|
|
7
8
|
Layout/FirstArgumentIndentation:
|
8
9
|
Enabled: false
|
10
|
+
Layout/LineLength:
|
11
|
+
Enabled: false
|
9
12
|
|
10
13
|
Naming/PredicateName:
|
11
14
|
Enabled: false
|
@@ -35,6 +38,8 @@ Style/RaiseArgs:
|
|
35
38
|
EnforcedStyle: compact
|
36
39
|
Style/SignalException:
|
37
40
|
Enabled: false
|
41
|
+
Style/SoleNestedConditional:
|
42
|
+
Enabled: false
|
38
43
|
Style/StderrPuts:
|
39
44
|
Enabled: false
|
40
45
|
Style/TrailingCommaInArguments:
|
data/.rubocop_todo.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,14 +1,10 @@
|
|
1
1
|
language: ruby
|
2
2
|
sudo: false
|
3
3
|
rvm:
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
- 2.6.3
|
4
|
+
- 2.5.8
|
5
|
+
- 2.6.6
|
6
|
+
- 2.7.2
|
8
7
|
- ruby-head
|
9
|
-
before_install:
|
10
|
-
- gem update --system # https://github.com/rubygems/rubygems/pull/1819
|
11
|
-
- gem install bundler
|
12
8
|
matrix:
|
13
9
|
allow_failures:
|
14
10
|
- rvm: ruby-head
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
{
|
2
|
+
scheduler: {
|
3
|
+
type: 'ecs',
|
4
|
+
region: 'ap-northeast-1',
|
5
|
+
cluster: 'eagletmt',
|
6
|
+
desired_count: 2,
|
7
|
+
role: 'ecsServiceRole',
|
8
|
+
elb_v2: {
|
9
|
+
// Specify protocol_version for gRPC servers
|
10
|
+
protocol_version: 'GRPC',
|
11
|
+
// VPC id where the target group is located
|
12
|
+
vpc_id: 'vpc-WWWWWWWW',
|
13
|
+
// If you want internal ELB, then use 'scheme'. (ex. internal service that like microservice inside VPC)
|
14
|
+
scheme: 'internal',
|
15
|
+
// Health check path of the target group
|
16
|
+
health_check_path: '/AWS.ELB/healthcheck',
|
17
|
+
listeners: [
|
18
|
+
{
|
19
|
+
port: 50051,
|
20
|
+
protocol: 'HTTPS',
|
21
|
+
certificate_arn: 'arn:aws:acm:ap-northeast-1:012345678901:certificate/01234567-89ab-cdef-0123-456789abcdef',
|
22
|
+
},
|
23
|
+
],
|
24
|
+
subnets: ['subnet-XXXXXXXX', 'subnet-YYYYYYYY'],
|
25
|
+
security_groups: ['sg-ZZZZZZZZ'],
|
26
|
+
load_balancer_attributes: {
|
27
|
+
'access_logs.s3.enabled': 'true',
|
28
|
+
'access_logs.s3.bucket': 'hako-access-logs',
|
29
|
+
'access_logs.s3.prefix': 'hako-hello-grpc',
|
30
|
+
},
|
31
|
+
target_group_attributes: {
|
32
|
+
// http://docs.aws.amazon.com/en_us/elasticloadbalancing/latest/application/load-balancer-target-groups.html#target-group-attributes
|
33
|
+
'deregistration_delay.timeout_seconds': '20',
|
34
|
+
},
|
35
|
+
// Route ELB traffic to app container directly
|
36
|
+
container_name: 'app',
|
37
|
+
container: 50051,
|
38
|
+
},
|
39
|
+
},
|
40
|
+
app: {
|
41
|
+
image: 'awesome-grpc-server',
|
42
|
+
memory: 128,
|
43
|
+
cpu: 256,
|
44
|
+
env: {
|
45
|
+
PORT: '50051',
|
46
|
+
},
|
47
|
+
secrets: [{
|
48
|
+
name: 'MESSAGE',
|
49
|
+
value_from: 'arn:aws:ssm:ap-northeast-1:012345678901:parameter/hako/hello-grpc/secret-message',
|
50
|
+
}],
|
51
|
+
port_mappings: [
|
52
|
+
{
|
53
|
+
container_port: 50051,
|
54
|
+
host_port: 0,
|
55
|
+
protocol: 'tcp',
|
56
|
+
},
|
57
|
+
],
|
58
|
+
},
|
59
|
+
scripts: [],
|
60
|
+
}
|
data/hako.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.bindir = 'exe'
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ['lib']
|
22
|
-
spec.required_ruby_version = '>= 2.
|
22
|
+
spec.required_ruby_version = '>= 2.5.0'
|
23
23
|
|
24
24
|
spec.add_dependency 'aws-sdk-applicationautoscaling'
|
25
25
|
spec.add_dependency 'aws-sdk-autoscaling'
|
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_dependency 'aws-sdk-ec2'
|
29
29
|
spec.add_dependency 'aws-sdk-ecs', '>= 1.54.0'
|
30
30
|
spec.add_dependency 'aws-sdk-elasticloadbalancing'
|
31
|
-
spec.add_dependency 'aws-sdk-elasticloadbalancingv2'
|
31
|
+
spec.add_dependency 'aws-sdk-elasticloadbalancingv2', '>= 1.54.0'
|
32
32
|
spec.add_dependency 'aws-sdk-s3'
|
33
33
|
spec.add_dependency 'aws-sdk-servicediscovery'
|
34
34
|
spec.add_dependency 'aws-sdk-sns'
|
data/lib/hako/commander.rb
CHANGED
@@ -18,7 +18,7 @@ module Hako
|
|
18
18
|
# @param [String, nil] tag
|
19
19
|
# @param [Boolean] dry_run
|
20
20
|
# @return [nil]
|
21
|
-
def deploy(force: false,
|
21
|
+
def deploy(tag:, timeout:, force: false, dry_run: false)
|
22
22
|
containers = load_containers(tag, dry_run: dry_run)
|
23
23
|
scripts = @app.definition.fetch('scripts', []).map { |config| load_script(config, dry_run: dry_run) }
|
24
24
|
volumes = @app.definition.fetch('volumes', {})
|
@@ -126,7 +126,7 @@ module Hako
|
|
126
126
|
# @param [Boolean] dry_run
|
127
127
|
# @param [Integer] timeout
|
128
128
|
# @return [Scheduler]
|
129
|
-
def load_scheduler(scheduler_definition, scripts, volumes: {}, force: false,
|
129
|
+
def load_scheduler(scheduler_definition, scripts, dry_run:, volumes: {}, force: false, timeout: nil)
|
130
130
|
Loader.new(Hako::Schedulers, 'hako/schedulers').load(scheduler_definition.fetch('type')).new(@app.id, scheduler_definition, volumes: volumes, scripts: scripts, force: force, dry_run: dry_run, timeout: timeout)
|
131
131
|
end
|
132
132
|
|
@@ -7,7 +7,7 @@ module Hako
|
|
7
7
|
class File < EnvProvider
|
8
8
|
# @param [Pathname] root_path
|
9
9
|
# @param [Hash<String, Object>] options
|
10
|
-
def initialize(root_path, options)
|
10
|
+
def initialize(root_path, options) # rubocop:disable Lint/MissingSuper
|
11
11
|
unless options['path']
|
12
12
|
validation_error!('path must be set')
|
13
13
|
end
|
@@ -8,7 +8,7 @@ module Hako
|
|
8
8
|
class Yaml < EnvProvider
|
9
9
|
# @param [Pathname] root_path
|
10
10
|
# @param [Hash<String, Object>] options
|
11
|
-
def initialize(root_path, options)
|
11
|
+
def initialize(root_path, options) # rubocop:disable Lint/MissingSuper
|
12
12
|
unless options['path']
|
13
13
|
validation_error!('path must be set')
|
14
14
|
end
|
data/lib/hako/schedulers/ecs.rb
CHANGED
@@ -515,7 +515,8 @@ module Hako
|
|
515
515
|
if actual_definition.requires_compatibilities != @requires_compatibilities
|
516
516
|
return true
|
517
517
|
end
|
518
|
-
|
518
|
+
|
519
|
+
actual_tags_set = Set.new(actual_tags.map { |t| { key: t.key, value: t.value } })
|
519
520
|
tags_set = Set.new(@tags)
|
520
521
|
if actual_tags_set != tags_set
|
521
522
|
return true
|
@@ -576,38 +577,36 @@ module Hako
|
|
576
577
|
# @return [Array<Boolean, Aws::ECS::Types::TaskDefinition]
|
577
578
|
def register_task_definition_for_oneshot(definitions)
|
578
579
|
10.times do |i|
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
raise e
|
610
|
-
end
|
580
|
+
family = "#{@app_id}-oneshot"
|
581
|
+
current_task_definition = describe_task_definition(family)
|
582
|
+
if current_task_definition
|
583
|
+
current_tags = ecs_client.list_tags_for_resource(resource_arn: current_task_definition.task_definition_arn).tags
|
584
|
+
end
|
585
|
+
if task_definition_changed?(definitions, current_task_definition, current_tags)
|
586
|
+
new_task_definition = ecs_client.register_task_definition(
|
587
|
+
family: family,
|
588
|
+
task_role_arn: @task_role_arn,
|
589
|
+
execution_role_arn: @execution_role_arn,
|
590
|
+
network_mode: @network_mode,
|
591
|
+
container_definitions: definitions,
|
592
|
+
volumes: volumes_definition,
|
593
|
+
requires_compatibilities: @requires_compatibilities,
|
594
|
+
cpu: @cpu,
|
595
|
+
memory: @memory,
|
596
|
+
tags: @tags.empty? ? nil : @tags,
|
597
|
+
).task_definition
|
598
|
+
return [true, new_task_definition]
|
599
|
+
else
|
600
|
+
return [false, current_task_definition]
|
601
|
+
end
|
602
|
+
rescue Aws::ECS::Errors::ClientException => e
|
603
|
+
if e.message.include?('Too many concurrent attempts to create a new revision of the specified family')
|
604
|
+
Hako.logger.error(e.message)
|
605
|
+
interval = 2**i + rand(0.0..10.0)
|
606
|
+
Hako.logger.error("Retrying register_task_definition_for_oneshot after #{interval} seconds")
|
607
|
+
sleep(interval)
|
608
|
+
else
|
609
|
+
raise e
|
611
610
|
end
|
612
611
|
end
|
613
612
|
raise Error.new('Unable to register task definition for oneshot due to too many client errors')
|
@@ -162,9 +162,7 @@ module Hako
|
|
162
162
|
end
|
163
163
|
|
164
164
|
class Policy
|
165
|
-
attr_reader :policy_type
|
166
|
-
attr_reader :alarms, :cooldown, :adjustment_type, :scaling_adjustment, :metric_interval_lower_bound, :metric_interval_upper_bound, :metric_aggregation_type
|
167
|
-
attr_reader :target_value, :predefined_metric_type, :scale_out_cooldown, :scale_in_cooldown, :disable_scale_in
|
165
|
+
attr_reader :policy_type, :alarms, :cooldown, :adjustment_type, :scaling_adjustment, :metric_interval_lower_bound, :metric_interval_upper_bound, :metric_aggregation_type, :target_value, :predefined_metric_type, :scale_out_cooldown, :scale_in_cooldown, :disable_scale_in
|
168
166
|
|
169
167
|
# @param [Hash] options
|
170
168
|
def initialize(options)
|
@@ -89,13 +89,22 @@ module Hako
|
|
89
89
|
target_type: @elb_v2_config.fetch('target_type', nil),
|
90
90
|
).target_groups[0]
|
91
91
|
else
|
92
|
+
matcher =
|
93
|
+
if @elb_v2_config.key?('matcher')
|
94
|
+
{
|
95
|
+
http_code: @elb_v2_config.fetch('matcher')['http_code'],
|
96
|
+
grpc_code: @elb_v2_config.fetch('matcher')['grpc_code'],
|
97
|
+
}
|
98
|
+
end
|
92
99
|
elb_client.create_target_group(
|
93
100
|
name: target_group_name,
|
94
101
|
port: 80,
|
95
102
|
protocol: 'HTTP',
|
103
|
+
protocol_version: @elb_v2_config.fetch('protocol_version', 'HTTP1'),
|
96
104
|
vpc_id: @elb_v2_config.fetch('vpc_id'),
|
97
105
|
health_check_path: @elb_v2_config.fetch('health_check_path', nil),
|
98
106
|
target_type: @elb_v2_config.fetch('target_type', nil),
|
107
|
+
matcher: matcher,
|
99
108
|
).target_groups[0]
|
100
109
|
end
|
101
110
|
|
@@ -10,7 +10,7 @@ module Hako
|
|
10
10
|
class NginxFront < Script
|
11
11
|
S3Config = Struct.new(:region, :bucket, :prefix) do
|
12
12
|
# @param [Hash] options
|
13
|
-
def initialize(options)
|
13
|
+
def initialize(options) # rubocop:disable Lint/MissingSuper
|
14
14
|
self.region = options.fetch('region')
|
15
15
|
self.bucket = options.fetch('bucket')
|
16
16
|
self.prefix = options.fetch('prefix', nil)
|
data/lib/hako/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hako
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kohei Suzuki
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-applicationautoscaling
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 1.54.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 1.54.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: aws-sdk-s3
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -321,6 +321,7 @@ files:
|
|
321
321
|
- examples/hello-cap-add-app.jsonnet
|
322
322
|
- examples/hello-fargate-batch.jsonnet
|
323
323
|
- examples/hello-fargate.jsonnet
|
324
|
+
- examples/hello-grpc.jsonnet
|
324
325
|
- examples/hello-internal-nlb.jsonnet
|
325
326
|
- examples/hello-lb-v2.jsonnet
|
326
327
|
- examples/hello-lb.jsonnet
|
@@ -382,7 +383,7 @@ homepage: https://github.com/eagletmt/hako
|
|
382
383
|
licenses:
|
383
384
|
- MIT
|
384
385
|
metadata: {}
|
385
|
-
post_install_message:
|
386
|
+
post_install_message:
|
386
387
|
rdoc_options: []
|
387
388
|
require_paths:
|
388
389
|
- lib
|
@@ -390,15 +391,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
390
391
|
requirements:
|
391
392
|
- - ">="
|
392
393
|
- !ruby/object:Gem::Version
|
393
|
-
version: 2.
|
394
|
+
version: 2.5.0
|
394
395
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
395
396
|
requirements:
|
396
397
|
- - ">="
|
397
398
|
- !ruby/object:Gem::Version
|
398
399
|
version: '0'
|
399
400
|
requirements: []
|
400
|
-
rubygems_version: 3.1.
|
401
|
-
signing_key:
|
401
|
+
rubygems_version: 3.1.4
|
402
|
+
signing_key:
|
402
403
|
specification_version: 4
|
403
404
|
summary: Deploy Docker container
|
404
405
|
test_files: []
|