awes_cli 0.0.21 → 0.0.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/build_app_image.rb +1 -1
- data/lib/deploy_app.rb +15 -3
- data/lib/deploy_config.rb +15 -3
- 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: f7841dbd0b1f58797c766eb6d4f594be7fc48d82db4dd45af2289e6db76fc6f8
|
4
|
+
data.tar.gz: 7945aa2ee989d87bcbf0fae9dd805bca650b96c44d55613af125b74bc030d67b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b983f65a6a2e93f5b1772b7eee2c5717a31ce0cbdf260e3ef06735510707e2b566b0d868fc2770347beef78f0aa700993e22ff770576b97e628f4d90f0d2df0
|
7
|
+
data.tar.gz: 68d2f56049b52715de0c20f204ad224ade0b560db65fe65bb9b4e0ef6de80f9b73ca23f01d2d6212dd70706199c1487589b37ed8807f77eb1ea6759943edf34a
|
data/lib/build_app_image.rb
CHANGED
data/lib/deploy_app.rb
CHANGED
@@ -2,11 +2,13 @@
|
|
2
2
|
require 'optparse'
|
3
3
|
|
4
4
|
class DeployApp
|
5
|
+
attr_accessor :workload_hash
|
6
|
+
|
5
7
|
def main
|
6
8
|
options = get_options
|
7
9
|
take_approval(options)
|
8
10
|
|
9
|
-
gcr_url = "gcr.io/#{options[:project_id]}/#{options[:image_repo] || options[:app_name]}"
|
11
|
+
gcr_url = "asia.gcr.io/#{options[:project_id]}/#{options[:image_repo] || options[:app_name]}"
|
10
12
|
|
11
13
|
if(!options[:image_tag].nil?)
|
12
14
|
image_url = validate_image_tag_exists?(gcr_url, options[:image_tag])
|
@@ -129,11 +131,21 @@ class DeployApp
|
|
129
131
|
"--project #{options[:project_id]} "
|
130
132
|
)
|
131
133
|
|
134
|
+
self.workload_hash = fetch_worload_yaml(options[:app_name], options[:namespace])
|
135
|
+
throw "Workload does not exists name: #{option[:app_name]} namespace: #{option[:namespace]}" if workload_hash.nil?
|
136
|
+
|
132
137
|
app_name = options[:app_name]
|
133
|
-
shell_cmd("kubectl set image
|
138
|
+
shell_cmd("kubectl set image #{workload_hash['kind']} #{app_name} #{app_name}=#{image_url} -n #{options[:namespace]}")
|
134
139
|
|
135
|
-
shell_cmd("kubectl rollout status
|
140
|
+
shell_cmd("kubectl rollout status #{workload_hash['kind']} #{app_name} -n #{options[:namespace]}")
|
136
141
|
|
137
142
|
shell_cmd("gcloud container images add-tag --quiet #{image_url} #{gcr_url}:current")
|
138
143
|
end
|
144
|
+
|
145
|
+
def fetch_worload_yaml(app_name, namespace)
|
146
|
+
json_deploy = `kubectl get deployment -n #{namespace} #{app_name} -o json`
|
147
|
+
return JSON.parse(json_deploy) if(json_deploy != "")
|
148
|
+
json_statefulset = `kubectl get statefulset -n #{namespace} #{app_name} -o json`
|
149
|
+
return JSON.parse(json_statefulset) if(json_statefulset != "")
|
150
|
+
end
|
139
151
|
end
|
data/lib/deploy_config.rb
CHANGED
@@ -6,6 +6,8 @@ require 'yaml'
|
|
6
6
|
require 'fileutils'
|
7
7
|
|
8
8
|
class DeployConfig
|
9
|
+
attr_accessor :workload_hash
|
10
|
+
|
9
11
|
def main
|
10
12
|
options = get_options
|
11
13
|
|
@@ -162,7 +164,7 @@ class DeployConfig
|
|
162
164
|
yaml_file.gsub!(/\$#{env_key}\s*$/, "'#{env_val}'")
|
163
165
|
end
|
164
166
|
|
165
|
-
gcr_url = "gcr.io/#{options[:project_id]}/#{options[:image_repo] || options[:app_name]}"
|
167
|
+
gcr_url = "asia.gcr.io/#{options[:project_id]}/#{options[:image_repo] || options[:app_name]}"
|
166
168
|
opt_image_url = options[:image_tag] && "#{gcr_url}:#{options[:image_tag]}"
|
167
169
|
|
168
170
|
image_url = "#{gcr_url}:current"
|
@@ -183,7 +185,9 @@ class DeployConfig
|
|
183
185
|
|
184
186
|
shell_cmd("kubectl apply -f ./tmp/final.yaml")
|
185
187
|
|
186
|
-
|
188
|
+
self.workload_hash = fetch_worload_yaml(options[:app_name], options[:namespace])
|
189
|
+
|
190
|
+
shell_cmd("kubectl rollout status #{workload_hash['kind']}/#{options[:app_name]} -n #{options[:namespace]}")
|
187
191
|
end
|
188
192
|
|
189
193
|
def override_envs(options)
|
@@ -215,7 +219,8 @@ class DeployConfig
|
|
215
219
|
end
|
216
220
|
|
217
221
|
def app_container_spec(app_name, namespace)
|
218
|
-
|
222
|
+
return nil if workload_hash.nil?
|
223
|
+
deploy_containers = `kubectl get #{workload_hash['kind']} -n #{namespace} #{app_name} --output=jsonpath={.spec.template.spec.containers}`
|
219
224
|
return nil if deploy_containers == ''
|
220
225
|
JSON.parse(deploy_containers, symbolize_names: true).find { |container| container[:name] == app_name }
|
221
226
|
end
|
@@ -229,4 +234,11 @@ class DeployConfig
|
|
229
234
|
|
230
235
|
env_export_cmd
|
231
236
|
end
|
237
|
+
|
238
|
+
def fetch_worload_yaml(app_name, namespace)
|
239
|
+
json_deploy = `kubectl get deployment -n #{namespace} #{app_name} -o json`
|
240
|
+
return JSON.parse(json_deploy) if(json_deploy != "")
|
241
|
+
json_statefulset = `kubectl get statefulset -n #{namespace} #{app_name} -o json`
|
242
|
+
return JSON.parse(json_statefulset) if(json_statefulset != "")
|
243
|
+
end
|
232
244
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awes_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Umar Siddiqui
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ather cli tool
|
14
14
|
email: umar.siddiqui@atherenergy.com
|