seira 0.5.3 → 0.5.5
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 +4 -4
- data/lib/helpers.rb +8 -0
- data/lib/seira.rb +8 -3
- data/lib/seira/db.rb +6 -3
- data/lib/seira/db/create.rb +1 -7
- data/lib/seira/node_pools.rb +3 -3
- data/lib/seira/settings.rb +8 -0
- data/lib/seira/version.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: 16a43b30639713b47c035cd97dbfc2392dedd8ffd85dd3f8d188fbdef0d9efd9
|
4
|
+
data.tar.gz: c11ee4d7151e0ae9dc068c2b91bee0bc4c00d184d688e7ddcab6a7872420f0ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26069ed21b7f53110b877a372867497e308e58a7e7239108caf7473d4d42d07fe548bddc80032b8ffec3f35268b35f4a372f839a2d979a7107869b0fc87b4ce9
|
7
|
+
data.tar.gz: 6e58dc0e409d35ed00de7bd3950afd98300f303f0e78644dd83134a9cfbf8c8ec6e3b6c9db0cf06e80ae0666e2e75da6b96ca41893d81bb8ea536bb35806e829
|
data/lib/helpers.rb
CHANGED
@@ -45,6 +45,14 @@ module Seira
|
|
45
45
|
rescue
|
46
46
|
'unknown'
|
47
47
|
end
|
48
|
+
|
49
|
+
def sql_ips(name, context:)
|
50
|
+
describe_command = "sql instances describe #{name}"
|
51
|
+
json = JSON.parse(Seira::Commands.gcloud(describe_command, context: context, format: :json))
|
52
|
+
private_ip = json['ipAddresses'].find { |address| address['type'] == 'PRIVATE' }['ipAddress']
|
53
|
+
public_ip = json['ipAddresses'].find { |address| address['type'] == 'PRIMARY' }['ipAddress']
|
54
|
+
{ private: private_ip, public: public_ip }
|
55
|
+
end
|
48
56
|
end
|
49
57
|
end
|
50
58
|
end
|
data/lib/seira.rb
CHANGED
@@ -56,6 +56,8 @@ module Seira
|
|
56
56
|
# arg is not in the ARGV array and should be skipped over
|
57
57
|
if ARGV[0] == 'help'
|
58
58
|
@category = reversed_args.pop
|
59
|
+
elsif ARGV[0] == 'version'
|
60
|
+
@category = reversed_args.pop
|
59
61
|
elsif ARGV[1] == 'cluster'
|
60
62
|
cluster = reversed_args.pop
|
61
63
|
@category = reversed_args.pop
|
@@ -100,6 +102,9 @@ module Seira
|
|
100
102
|
if category == 'help'
|
101
103
|
run_base_help
|
102
104
|
exit(0)
|
105
|
+
elsif category == 'version'
|
106
|
+
puts "Seira version: #{Seira::VERSION}"
|
107
|
+
exit(0)
|
103
108
|
elsif category == 'setup'
|
104
109
|
Seira::Setup.new(target: cluster, args: args, settings: settings).run
|
105
110
|
exit(0)
|
@@ -136,8 +141,8 @@ module Seira
|
|
136
141
|
cluster: cluster,
|
137
142
|
project: project,
|
138
143
|
settings: settings,
|
139
|
-
region: cluster
|
140
|
-
zone: cluster
|
144
|
+
region: settings.region_for_cluster(cluster),
|
145
|
+
zone: settings.zone_for_cluster(cluster),
|
141
146
|
app: app,
|
142
147
|
action: action,
|
143
148
|
args: args
|
@@ -151,7 +156,7 @@ module Seira
|
|
151
156
|
exit(1)
|
152
157
|
end
|
153
158
|
|
154
|
-
unless system("kubectl version > /dev/null 2>&1")
|
159
|
+
unless system("kubectl version -c > /dev/null 2>&1")
|
155
160
|
puts "Kubectl library not installed properly. Please install `kubectl` before using seira.".red
|
156
161
|
exit(1)
|
157
162
|
end
|
data/lib/seira/db.rb
CHANGED
@@ -245,7 +245,7 @@ module Seira
|
|
245
245
|
end
|
246
246
|
|
247
247
|
password = SecureRandom.urlsafe_base64(32)
|
248
|
-
if gcloud("sql users create #{user_name}
|
248
|
+
if gcloud("sql users create #{user_name} --instance=#{instance_name} --password=#{password}", context: context, format: :boolean)
|
249
249
|
puts "Created user '#{user_name}' with password #{password}"
|
250
250
|
else
|
251
251
|
puts "Failed to create user '#{user_name}'"
|
@@ -264,6 +264,8 @@ module Seira
|
|
264
264
|
GRANT SELECT ON ALL TABLES IN SCHEMA public TO #{user_name};
|
265
265
|
ALTER DEFAULT PRIVILEGES IN SCHEMA "public" GRANT SELECT ON TABLES TO #{user_name};
|
266
266
|
SQL
|
267
|
+
|
268
|
+
puts "Connecting"
|
267
269
|
execute_db_command(admin_commands, as_admin: true)
|
268
270
|
execute_db_command(database_commands)
|
269
271
|
end
|
@@ -412,6 +414,7 @@ module Seira
|
|
412
414
|
def execute_db_command(sql_command, as_admin: false, interactive: false, print: true)
|
413
415
|
# TODO(josh): move pgbouncer naming logic here and in Create to a common location
|
414
416
|
instance_name = primary_instance
|
417
|
+
private_ip = Helpers.sql_ips(instance_name, context: context)[:private]
|
415
418
|
tier = instance_name.gsub("#{app}-", '')
|
416
419
|
matching_pods = Helpers.fetch_pods(context: context, filters: { tier: tier })
|
417
420
|
if matching_pods.empty?
|
@@ -422,9 +425,9 @@ module Seira
|
|
422
425
|
psql_command =
|
423
426
|
if as_admin
|
424
427
|
root_password = Helpers.get_secret(context: context, key: "#{instance_name.tr('-', '_').upcase}_ROOT_PASSWORD")
|
425
|
-
"psql postgres://postgres:#{root_password}
|
428
|
+
"psql postgres://postgres:#{root_password}@#{private_ip}:5432"
|
426
429
|
else
|
427
|
-
|
430
|
+
"psql"
|
428
431
|
end
|
429
432
|
system_command = "kubectl exec #{pod_name} --namespace #{app}"
|
430
433
|
system_command += ' -ti' if interactive
|
data/lib/seira/db/create.rb
CHANGED
@@ -188,13 +188,7 @@ module Seira
|
|
188
188
|
end
|
189
189
|
|
190
190
|
def ips
|
191
|
-
@
|
192
|
-
describe_command = "sql instances describe #{name}"
|
193
|
-
json = JSON.parse(gcloud(describe_command, context: context, format: :json))
|
194
|
-
private_ip = json['ipAddresses'].find { |address| address['type'] == 'PRIVATE' }['ipAddress']
|
195
|
-
public_ip = json['ipAddresses'].find { |address| address['type'] == 'PRIMARY' }['ipAddress']
|
196
|
-
{ private: private_ip, public: public_ip }
|
197
|
-
end
|
191
|
+
@ips ||= Helpers.sql_ips(name, context: context)
|
198
192
|
end
|
199
193
|
|
200
194
|
def write_pgbouncer_yaml
|
data/lib/seira/node_pools.rb
CHANGED
@@ -58,7 +58,7 @@ module Seira
|
|
58
58
|
# TODO: Info about what is running on it?
|
59
59
|
# TODO: What information do we get in the json format we could include here?
|
60
60
|
def run_list
|
61
|
-
gcloud("container node-pools list --cluster #{context[:cluster]}", context: context, format: :boolean)
|
61
|
+
gcloud("container node-pools list --cluster #{context[:cluster]} --region=#{context[:region]}", context: context, format: :boolean)
|
62
62
|
end
|
63
63
|
|
64
64
|
def run_list_nodes
|
@@ -157,7 +157,7 @@ module Seira
|
|
157
157
|
|
158
158
|
exit(1) unless HighLine.agree "Node pool has successfully been cordoned and drained, and should be safe to delete. Continue deleting node pool #{node_pool_name}?"
|
159
159
|
|
160
|
-
if gcloud("container node-pools delete #{node_pool_name} --cluster #{context[:cluster]}", context: context, format: :boolean)
|
160
|
+
if gcloud("container node-pools delete #{node_pool_name} --cluster #{context[:cluster]} --region=#{context[:region]}", context: context, format: :boolean)
|
161
161
|
puts 'Node pool deleted successfully'
|
162
162
|
else
|
163
163
|
puts 'Failed to delete old pool'
|
@@ -167,7 +167,7 @@ module Seira
|
|
167
167
|
|
168
168
|
# TODO: Represent by a ruby object?
|
169
169
|
def node_pools
|
170
|
-
JSON.parse(gcloud("container node-pools list --cluster #{context[:cluster]}", context: context, format: :json))
|
170
|
+
JSON.parse(gcloud("container node-pools list --cluster #{context[:cluster]} --region=#{context[:region]}", context: context, format: :json))
|
171
171
|
end
|
172
172
|
|
173
173
|
def nodes_for_pool(pool_name)
|
data/lib/seira/settings.rb
CHANGED
@@ -56,6 +56,14 @@ module Seira
|
|
56
56
|
settings['seira']['clusters'][cluster]['project']
|
57
57
|
end
|
58
58
|
|
59
|
+
def region_for_cluster(cluster)
|
60
|
+
settings['seira']['clusters'][cluster]['region']
|
61
|
+
end
|
62
|
+
|
63
|
+
def zone_for_cluster(cluster)
|
64
|
+
settings['seira']['clusters'][cluster]['zone']
|
65
|
+
end
|
66
|
+
|
59
67
|
def expected_environment_variable_during_deploys
|
60
68
|
settings['seira']['expected_environment_variable_during_deploys']
|
61
69
|
end
|
data/lib/seira/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seira
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Ringwelski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|