seira 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/helpers.rb +9 -0
- data/lib/seira/db.rb +7 -10
- 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: 57d3df41212e06d4182e97edc51ff948019596f2063696fee21327f6d79e7820
|
4
|
+
data.tar.gz: a1530d5bfd8142524600d9e73e6346668a32ab9aef4326366e0d173be4850f94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2c2e1d7e7f52832046653fcca340d1cb30addecbb2325979b02a822d0a38757344216dc8cbc363fc8f02ec01905d57fecbe713e467c2fa59c40184b0783e392
|
7
|
+
data.tar.gz: 7a6cd149ff5338938ece13e6ff2c157c2e0145bf08f4af1974150f259765fc8fd2c5243f4780223799d02f2326626c0547a7062f63560afd942195dec8565003
|
data/README.md
CHANGED
@@ -83,6 +83,15 @@ seira:
|
|
83
83
|
|
84
84
|
This specification is read in and used to determine what `gcloud` context to use and what `kubectl` cluster to use when operating commands. For example, `seira internal` will connect to `org-internal` gcloud configuration and `gke_org-internal_us-central1-a_internal` kubectl cluster. For shorthand, `seira i` shorthand is specified as an alias.
|
85
85
|
|
86
|
+
### Application Configuration Files
|
87
|
+
|
88
|
+
Each app can also define configuration files. These files specify details that allow seira to execute commands with minimal user input, and declare aspects of the application. This file lives in the app folder with the name `.seira.app.yaml`. An example configuration file:
|
89
|
+
|
90
|
+
```
|
91
|
+
# The name of the sql instance as it shows in GCP Cloud SQL UI
|
92
|
+
primary_sql_instance: app-database-name
|
93
|
+
```
|
94
|
+
|
86
95
|
### Regions and Zones
|
87
96
|
|
88
97
|
All clusters should have a `region` option specified. For zonal clusters (clusters that are NOT regional) should also specify their `zone`.
|
data/lib/helpers.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
module Seira
|
2
4
|
class Helpers
|
3
5
|
include Seira::Commands
|
@@ -37,6 +39,13 @@ module Seira
|
|
37
39
|
Secrets.new(app: context[:app], action: 'get', args: [], context: context).get(key)
|
38
40
|
end
|
39
41
|
|
42
|
+
def get_seira_app_config(context:)
|
43
|
+
yaml_file_path = "kubernetes/#{context[:cluster]}/#{context[:app]}/.seira.app.yaml"
|
44
|
+
YAML.load_file(yaml_file_path)
|
45
|
+
rescue
|
46
|
+
fail "Failed to load the configuration file at #{yaml_file_path}. Please add configuration file and retry."
|
47
|
+
end
|
48
|
+
|
40
49
|
def get_current_replicas(deployment:, context:)
|
41
50
|
output = Seira::Commands.kubectl("get deployment #{deployment} -o json", context: context, return_output: true)
|
42
51
|
JSON.parse(output)['spec']['replicas']
|
data/lib/seira/db.rb
CHANGED
@@ -75,16 +75,8 @@ module Seira
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
# NOTE: Relies on the pgbouncer instance being named based on the db name, as is done in create command
|
79
78
|
def primary_instance
|
80
|
-
|
81
|
-
return nil unless database_url
|
82
|
-
|
83
|
-
primary_uri = URI.parse(database_url)
|
84
|
-
host = primary_uri.host
|
85
|
-
|
86
|
-
# Convert handshake-onyx-burmese-pgbouncer-service to handshake-onyx-burmese
|
87
|
-
host.gsub('-pgbouncer-service', '')
|
79
|
+
Seira::Helpers.get_seira_app_config(context: context)['primary_sql_instance']
|
88
80
|
end
|
89
81
|
|
90
82
|
private
|
@@ -331,10 +323,13 @@ module Seira
|
|
331
323
|
|
332
324
|
def run_psql
|
333
325
|
as_admin = false
|
326
|
+
instance_name = nil
|
334
327
|
|
335
328
|
args.each do |arg|
|
336
329
|
if arg == '--as-root-user'
|
337
330
|
as_admin = true
|
331
|
+
elsif arg.start_with? '--instance='
|
332
|
+
instance_name = arg.split('=')[1]
|
338
333
|
else
|
339
334
|
puts "Warning: Unrecognized argument '#{arg}'"
|
340
335
|
end
|
@@ -344,7 +339,7 @@ module Seira
|
|
344
339
|
puts "!! Warning !!! You are running as root PSQL user `postgres`. This super user account has full admin priveleges. Use with extreme care."
|
345
340
|
end
|
346
341
|
|
347
|
-
execute_db_command(nil, interactive: true, as_admin: as_admin)
|
342
|
+
execute_db_command(nil, interactive: true, instance_name: instance_name, as_admin: as_admin)
|
348
343
|
end
|
349
344
|
|
350
345
|
def run_table_sizes
|
@@ -488,6 +483,8 @@ module Seira
|
|
488
483
|
# TODO(josh): move pgbouncer naming logic here and in Create to a common location
|
489
484
|
instance_name ||= primary_instance
|
490
485
|
private_ip = Helpers.sql_ips(instance_name, context: context)[:private]
|
486
|
+
|
487
|
+
# NOTE: Relies on the pgbouncer instance being named based on the db name, as is done in create command
|
491
488
|
pgbouncer_tier ||= instance_name.gsub("#{app}-", '')
|
492
489
|
matching_pods = Helpers.fetch_pods(context: context, filters: { tier: pgbouncer_tier })
|
493
490
|
if matching_pods.empty?
|
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.7.
|
4
|
+
version: 0.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Ringwelski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|