seira 0.1.2 → 0.1.3
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/seira.rb +18 -2
- data/lib/seira/app.rb +14 -3
- data/lib/seira/cluster.rb +4 -1
- data/lib/seira/db.rb +10 -1
- data/lib/seira/memcached.rb +10 -1
- data/lib/seira/pods.rb +10 -1
- data/lib/seira/proxy.rb +2 -0
- data/lib/seira/redis.rb +12 -3
- data/lib/seira/secrets.rb +11 -2
- data/lib/seira/setup.rb +2 -0
- data/lib/seira/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 669843ecfb6cfb054f7be793690a37584566cc73
|
4
|
+
data.tar.gz: 9889f757784af3d0ad4634ffd4c211c5abb9799f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ef7516626cf358152b97b9eece4dbd5e1466ad773ff6ee21960cab59fc9bba3be27bbe5b23ba4f7d7d8524e2aa009e633e0069aaf21ff90db106617c4e2e9de
|
7
|
+
data.tar.gz: 2fb02399b82c25635a4d969306ec50ab1aeb3b514aa029d7e9a1bf4dbe60b510eeead7008b83a7a83eb35d58a8a3be50d29b63caca3b4629b850bdb8bcffd372
|
data/lib/seira.rb
CHANGED
@@ -42,7 +42,9 @@ module Seira
|
|
42
42
|
|
43
43
|
# The cluster and proxy command are not specific to any app, so that
|
44
44
|
# arg is not in the ARGV array and should be skipped over
|
45
|
-
if ARGV[
|
45
|
+
if ARGV[0] == 'help'
|
46
|
+
@category = reversed_args.pop
|
47
|
+
elsif ARGV[1] == 'cluster'
|
46
48
|
cluster = reversed_args.pop
|
47
49
|
@category = reversed_args.pop
|
48
50
|
@action = reversed_args.pop
|
@@ -65,7 +67,10 @@ module Seira
|
|
65
67
|
end
|
66
68
|
|
67
69
|
def run
|
68
|
-
if category == '
|
70
|
+
if category == 'help'
|
71
|
+
run_base_help
|
72
|
+
exit(0)
|
73
|
+
elsif category == 'setup'
|
69
74
|
Seira::Setup.new(arg: cluster, settings: settings).run
|
70
75
|
exit(0)
|
71
76
|
end
|
@@ -123,5 +128,16 @@ module Seira
|
|
123
128
|
def simple_cluster_change?
|
124
129
|
app.nil? && category.nil? # Special case where user is simply changing environments
|
125
130
|
end
|
131
|
+
|
132
|
+
def run_base_help
|
133
|
+
puts 'Seira is a library for managing Kubernetes as a PaaS.'
|
134
|
+
puts 'All commands take the following form: `seira <cluster-name> <app-name> <category> <action> <args...>`'
|
135
|
+
puts 'For example, `seira staging foo-app secrets list`'
|
136
|
+
puts "Possible categories: \n\n"
|
137
|
+
CATEGORIES.each do |key, klass|
|
138
|
+
puts "#{key}: #{klass::SUMMARY}"
|
139
|
+
end
|
140
|
+
puts "\nTo get more help for a specific category, run `seira <cluster-name> <app-name> <category> help` command"
|
141
|
+
end
|
126
142
|
end
|
127
143
|
end
|
data/lib/seira/app.rb
CHANGED
@@ -6,7 +6,8 @@ require 'fileutils'
|
|
6
6
|
# seira staging specs app bootstrap
|
7
7
|
module Seira
|
8
8
|
class App
|
9
|
-
VALID_ACTIONS = %w[bootstrap apply
|
9
|
+
VALID_ACTIONS = %w[help bootstrap apply restart scale].freeze
|
10
|
+
SUMMARY = "Bootstrap, scale, configure, restart, your apps.".freeze
|
10
11
|
|
11
12
|
attr_reader :app, :action, :args, :context
|
12
13
|
|
@@ -19,12 +20,12 @@ module Seira
|
|
19
20
|
|
20
21
|
def run
|
21
22
|
case action
|
23
|
+
when 'help'
|
24
|
+
run_help
|
22
25
|
when 'bootstrap'
|
23
26
|
run_bootstrap
|
24
27
|
when 'apply'
|
25
28
|
run_apply
|
26
|
-
when 'upgrade'
|
27
|
-
run_upgrade
|
28
29
|
when 'restart'
|
29
30
|
run_restart
|
30
31
|
when 'scale'
|
@@ -34,6 +35,16 @@ module Seira
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
38
|
+
def run_help
|
39
|
+
puts SUMMARY
|
40
|
+
puts "\n\n"
|
41
|
+
puts "Possible actions:\n\n"
|
42
|
+
puts "bootstrap: Create new app with main secret, cloudsql secret, and gcr secret in the new namespace."
|
43
|
+
puts "apply: Apply the configuration in kubernetes/<cluster-name>/<app-name> using REVISION environment variable to find/replace REVISION in the YAML."
|
44
|
+
puts "restart: TODO."
|
45
|
+
puts "scale: Scales the given tier deployment to the specified number of instances."
|
46
|
+
end
|
47
|
+
|
37
48
|
def run_restart
|
38
49
|
# TODO
|
39
50
|
end
|
data/lib/seira/cluster.rb
CHANGED
@@ -5,7 +5,8 @@ require 'fileutils'
|
|
5
5
|
# Example usages:
|
6
6
|
module Seira
|
7
7
|
class Cluster
|
8
|
-
VALID_ACTIONS = %w[bootstrap].freeze
|
8
|
+
VALID_ACTIONS = %w[help bootstrap].freeze
|
9
|
+
SUMMARY = "For managing whole clusters.".freeze
|
9
10
|
|
10
11
|
attr_reader :action, :args, :context, :settings
|
11
12
|
|
@@ -18,6 +19,8 @@ module Seira
|
|
18
19
|
|
19
20
|
def run
|
20
21
|
case action
|
22
|
+
when 'help'
|
23
|
+
run_help
|
21
24
|
when 'bootstrap'
|
22
25
|
run_bootstrap
|
23
26
|
else
|
data/lib/seira/db.rb
CHANGED
@@ -2,7 +2,8 @@ require 'securerandom'
|
|
2
2
|
|
3
3
|
module Seira
|
4
4
|
class Db
|
5
|
-
VALID_ACTIONS = %w[create delete list].freeze
|
5
|
+
VALID_ACTIONS = %w[help create delete list].freeze
|
6
|
+
SUMMARY = "Manage your Cloud SQL Postgres databases.".freeze
|
6
7
|
|
7
8
|
attr_reader :app, :action, :args, :context
|
8
9
|
|
@@ -15,6 +16,8 @@ module Seira
|
|
15
16
|
|
16
17
|
def run
|
17
18
|
case action
|
19
|
+
when 'help'
|
20
|
+
run_help
|
18
21
|
when 'create'
|
19
22
|
run_create
|
20
23
|
when 'delete'
|
@@ -28,6 +31,12 @@ module Seira
|
|
28
31
|
|
29
32
|
private
|
30
33
|
|
34
|
+
def run_help
|
35
|
+
puts SUMMARY
|
36
|
+
puts "\n\n"
|
37
|
+
puts "TODO"
|
38
|
+
end
|
39
|
+
|
31
40
|
def run_create
|
32
41
|
# We allow overriding the version, so you could specify a mysql version but much of the
|
33
42
|
# below assumes postgres for now
|
data/lib/seira/memcached.rb
CHANGED
@@ -3,7 +3,8 @@ require 'base64'
|
|
3
3
|
|
4
4
|
module Seira
|
5
5
|
class Memcached
|
6
|
-
VALID_ACTIONS = %w[list status credentials create delete].freeze
|
6
|
+
VALID_ACTIONS = %w[help list status credentials create delete].freeze
|
7
|
+
SUMMARY = "Manage your Helm Memcached instances.".freeze
|
7
8
|
|
8
9
|
attr_reader :app, :action, :args, :context
|
9
10
|
|
@@ -17,6 +18,8 @@ module Seira
|
|
17
18
|
# TODO: logs, upgrades?, backups, restores, CLI connection
|
18
19
|
def run
|
19
20
|
case action
|
21
|
+
when 'help'
|
22
|
+
run_help
|
20
23
|
when 'list'
|
21
24
|
run_list
|
22
25
|
when 'status'
|
@@ -34,6 +37,12 @@ module Seira
|
|
34
37
|
|
35
38
|
private
|
36
39
|
|
40
|
+
def run_help
|
41
|
+
puts SUMMARY
|
42
|
+
puts "\n\n"
|
43
|
+
puts "TODO"
|
44
|
+
end
|
45
|
+
|
37
46
|
def run_list
|
38
47
|
puts existing_instances
|
39
48
|
end
|
data/lib/seira/pods.rb
CHANGED
@@ -2,7 +2,8 @@ require 'json'
|
|
2
2
|
|
3
3
|
module Seira
|
4
4
|
class Pods
|
5
|
-
VALID_ACTIONS = %w[list delete logs top run connect].freeze
|
5
|
+
VALID_ACTIONS = %w[help list delete logs top run connect].freeze
|
6
|
+
SUMMARY = "Manage your application's pods.".freeze
|
6
7
|
|
7
8
|
attr_reader :app, :action, :args, :pod_name, :context
|
8
9
|
|
@@ -16,6 +17,8 @@ module Seira
|
|
16
17
|
|
17
18
|
def run
|
18
19
|
case action
|
20
|
+
when 'help'
|
21
|
+
run_help
|
19
22
|
when 'list'
|
20
23
|
run_list
|
21
24
|
when 'delete'
|
@@ -35,6 +38,12 @@ module Seira
|
|
35
38
|
|
36
39
|
private
|
37
40
|
|
41
|
+
def run_help
|
42
|
+
puts SUMMARY
|
43
|
+
puts "\n\n"
|
44
|
+
puts "TODO"
|
45
|
+
end
|
46
|
+
|
38
47
|
def run_list
|
39
48
|
puts `kubectl get pods --namespace=#{app} -o wide`
|
40
49
|
end
|
data/lib/seira/proxy.rb
CHANGED
data/lib/seira/redis.rb
CHANGED
@@ -3,7 +3,8 @@ require 'base64'
|
|
3
3
|
|
4
4
|
module Seira
|
5
5
|
class Redis
|
6
|
-
VALID_ACTIONS = %w[list status credentials create delete].freeze
|
6
|
+
VALID_ACTIONS = %w[help list status credentials create delete].freeze
|
7
|
+
SUMMARY = "Manage your Helm Redis instances.".freeze
|
7
8
|
|
8
9
|
attr_reader :app, :action, :args, :context
|
9
10
|
|
@@ -17,6 +18,8 @@ module Seira
|
|
17
18
|
# TODO: logs, upgrades?, backups, restores, CLI connection
|
18
19
|
def run
|
19
20
|
case action
|
21
|
+
when 'help'
|
22
|
+
run_help
|
20
23
|
when 'list'
|
21
24
|
run_list
|
22
25
|
when 'status'
|
@@ -34,6 +37,12 @@ module Seira
|
|
34
37
|
|
35
38
|
private
|
36
39
|
|
40
|
+
def run_help
|
41
|
+
puts SUMMARY
|
42
|
+
puts "\n\n"
|
43
|
+
puts "TODO"
|
44
|
+
end
|
45
|
+
|
37
46
|
def run_list
|
38
47
|
puts existing_instances
|
39
48
|
end
|
@@ -115,7 +124,7 @@ module Seira
|
|
115
124
|
|
116
125
|
file_name = write_config(values)
|
117
126
|
unique_name = Seira::Random.unique_name(existing_instances)
|
118
|
-
name = "#{app}-#{unique_name}"
|
127
|
+
name = "#{app}-redis-#{unique_name}"
|
119
128
|
puts `helm install --namespace #{app} --name #{name} --wait -f #{file_name} stable/redis`
|
120
129
|
|
121
130
|
File.delete(file_name)
|
@@ -126,7 +135,7 @@ module Seira
|
|
126
135
|
end
|
127
136
|
|
128
137
|
def run_delete
|
129
|
-
to_delete = "#{app}-#{args[0]}"
|
138
|
+
to_delete = "#{app}-redis-#{args[0]}"
|
130
139
|
|
131
140
|
exit(1) unless HighLine.agree("Are you sure you want to delete #{to_delete}? If any apps are using this redis instance, they will break.")
|
132
141
|
|
data/lib/seira/secrets.rb
CHANGED
@@ -8,8 +8,9 @@ require 'base64'
|
|
8
8
|
# TODO: Can we avoid writing to disk completely and instead pipe in raw json?
|
9
9
|
module Seira
|
10
10
|
class Secrets
|
11
|
-
VALID_ACTIONS = %w[get set unset list list-decoded create-pgbouncer-secret].freeze
|
11
|
+
VALID_ACTIONS = %w[help get set unset list list-decoded create-pgbouncer-secret].freeze
|
12
12
|
PGBOUNCER_SECRETS_NAME = 'pgbouncer-secrets'.freeze
|
13
|
+
SUMMARY = "Manage your application's secrets and environment variables.".freeze
|
13
14
|
|
14
15
|
attr_reader :app, :action, :args, :context
|
15
16
|
|
@@ -22,6 +23,8 @@ module Seira
|
|
22
23
|
|
23
24
|
def run
|
24
25
|
case action
|
26
|
+
when 'help'
|
27
|
+
run_help
|
25
28
|
when 'get'
|
26
29
|
validate_single_key
|
27
30
|
run_get
|
@@ -64,6 +67,12 @@ module Seira
|
|
64
67
|
|
65
68
|
private
|
66
69
|
|
70
|
+
def run_help
|
71
|
+
puts SUMMARY
|
72
|
+
puts "\n\n"
|
73
|
+
puts "TODO"
|
74
|
+
end
|
75
|
+
|
67
76
|
def validate_single_key
|
68
77
|
if key.nil? || key.strip == ""
|
69
78
|
puts "Please specify a key in all caps and with underscores"
|
@@ -114,7 +123,7 @@ module Seira
|
|
114
123
|
def run_create_pgbouncer_secret
|
115
124
|
db_user = args[0]
|
116
125
|
db_password = args[1]
|
117
|
-
|
126
|
+
puts `kubectl create secret generic #{PGBOUNCER_SECRETS_NAME} --namespace #{app} --from-literal=DB_USER=#{db_user} --from-literal=DB_PASSWORD=#{db_password}`
|
118
127
|
end
|
119
128
|
|
120
129
|
# In the normal case the secret we are updating is just main_secret_name,
|
data/lib/seira/setup.rb
CHANGED
data/lib/seira/version.rb
CHANGED