gclouder 0.1.13 → 0.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ebf2e74c77329fd25f72de4e0b98868203dde63
|
4
|
+
data.tar.gz: 9177c204fae1466ceccf232c2c3213dfabc01438
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 411b55ad710b8614d253a215cd7cd6417c4551bec15f2388de5bf56a0405ea1976b3a52b6ec5bd8779e38b639007d4ba3db7225975ec85ecff125461002f2f50
|
7
|
+
data.tar.gz: 164ae2f92206253ee8fdf7d6af54c070a5de5b5a8b7764456576d691d552ffc4a783a14b3a3378301b97af1e441aca5af380f6bab8bfa4632d1bb161f5f8f58c
|
@@ -17,7 +17,16 @@ machine_type:
|
|
17
17
|
num_nodes:
|
18
18
|
type: String
|
19
19
|
required: false
|
20
|
-
default:
|
20
|
+
default: 1
|
21
|
+
enable_autoscaling:
|
22
|
+
type: Boolean
|
23
|
+
required: false
|
24
|
+
min_nodes:
|
25
|
+
type: Integer
|
26
|
+
required: false
|
27
|
+
max_nodes:
|
28
|
+
type: Integer
|
29
|
+
required: false
|
21
30
|
scopes:
|
22
31
|
type: Array
|
23
32
|
required: false
|
@@ -37,9 +37,12 @@ module GClouder
|
|
37
37
|
|
38
38
|
[
|
39
39
|
"disk_size",
|
40
|
+
"enable_autoscaling",
|
40
41
|
"enable_cloud_endpoints",
|
41
42
|
"image_type",
|
42
43
|
"machine_type",
|
44
|
+
"max_nodes",
|
45
|
+
"min_nodes",
|
43
46
|
"num_nodes",
|
44
47
|
"scopes",
|
45
48
|
"zone",
|
@@ -55,6 +58,12 @@ module GClouder
|
|
55
58
|
"zone",
|
56
59
|
"node_pool",
|
57
60
|
]
|
61
|
+
when :autoscale_cluster
|
62
|
+
[
|
63
|
+
"enable_autoscaling",
|
64
|
+
"max_nodes",
|
65
|
+
"min_nodes",
|
66
|
+
]
|
58
67
|
else
|
59
68
|
raise StandardError, "invalid context supplied when querying config object: #{context}"
|
60
69
|
end
|
@@ -40,7 +40,8 @@ module GClouder
|
|
40
40
|
info cluster["name"], heading: true, indent: 3
|
41
41
|
cluster["node_pools"].each do |pool|
|
42
42
|
NodePool.create(cluster, pool)
|
43
|
-
NodePool.resize(cluster, pool)
|
43
|
+
NodePool.resize(cluster, pool)
|
44
|
+
NodePool.autoscale(cluster, pool)
|
44
45
|
end
|
45
46
|
end
|
46
47
|
end
|
@@ -142,6 +143,7 @@ module GClouder
|
|
142
143
|
end
|
143
144
|
|
144
145
|
def self.resize(cluster, pool)
|
146
|
+
return if !pool["num_nodes"] or pool["enable_autoscaling"]
|
145
147
|
config = pool.context(:resize_cluster)
|
146
148
|
zone = pool["zone"]
|
147
149
|
|
@@ -170,6 +172,26 @@ module GClouder
|
|
170
172
|
end
|
171
173
|
end
|
172
174
|
|
175
|
+
def self.autoscale(cluster, pool)
|
176
|
+
return if !pool["enable_autoscaling"]
|
177
|
+
|
178
|
+
if !check_exists?(cluster["name"], pool["name"], pool["zone"])
|
179
|
+
info "skipping autoscale for non-existant cluster/nodepool: #{cluster["name"]}/#{pool["name"]}", indent: 5
|
180
|
+
return
|
181
|
+
end
|
182
|
+
|
183
|
+
autoscaling = gcloud("container node-pools list --cluster #{cluster["name"]} --zone #{cluster["zone"]} | jq '.[] | select(.name == \"#{pool["name"]}\") | .autoscaling'", force: true)
|
184
|
+
if pool["min_nodes"] != autoscaling["minNodeCount"] or pool["max_nodes"] != autoscaling["maxNodeCount"]
|
185
|
+
config = pool.context(:autoscale_cluster)
|
186
|
+
parameters = hash_to_args(config)
|
187
|
+
|
188
|
+
add "Updating autoscale constraints: Min: #{autoscaling["minNodeCount"]} -> #{pool["min_nodes"]} : Max: #{autoscaling["maxNodeCount"]} -> #{pool["max_nodes"]}", indent: 5
|
189
|
+
gcloud("container clusters update #{cluster["name"]} --node-pool #{pool["name"]} #{parameters} --zone #{cluster["zone"]}")
|
190
|
+
else
|
191
|
+
true
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
173
195
|
def self.calculate_number_of_zones(pool)
|
174
196
|
pool.key?("additional_zones") ? (pool["additional_zones"].count + 1) : 1
|
175
197
|
end
|
data/lib/gclouder/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gclouder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Wilson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-08-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: trollop
|