seira 0.5.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +1 -17
- data/lib/seira.rb +0 -4
- data/lib/seira/setup.rb +0 -8
- data/lib/seira/version.rb +1 -1
- data/seira.gemspec +1 -1
- metadata +4 -6
- data/lib/seira/memcached.rb +0 -156
- data/lib/seira/redis.rb +0 -166
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71b3471104a2d2635ebd3a15c88f1fb07cf95bb9d7c230c5b88d9305baabe175
|
4
|
+
data.tar.gz: '09e0a3d5247ca115c10a41a96d645b59079558e3087203fcf53b78c79dc34fce'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cb60153ff12c3b0f17ca650460c9ecb6e874e1620da389ab491289609d25e4c279f040007b473facfaada905e1ab2f828327ae45a9ca966bfae43e5a1e074a0
|
7
|
+
data.tar.gz: c6f14cd0f516d281cbe81f1e0139c821a5e0299777a00b0896025a17c37bc718d6d825db30ebfcc1ba0580f3b92b774ee685483ea04bb1ee44bcfbcc6a3edf9b
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
An opinionated library for building applications on Kubernetes.
|
7
7
|
|
8
|
-
This library builds a framework for doing deployments, secrets management, managing
|
8
|
+
This library builds a framework for doing deployments, secrets management, managing and accessing pods, bootstraping new apps and clusters, and more. It makes decisions about how to run the apps and cluster to make managing the cluster easier.
|
9
9
|
|
10
10
|
The vision for Seira is to produce a CLI and set of guidelines that makes deploying apps on Kubernetes as easy as Heroku.
|
11
11
|
|
@@ -120,16 +120,6 @@ All functionality is targeted to be a platform on top of Kubernetes that has a H
|
|
120
120
|
* Pgbouncer yaml generation for all new instances
|
121
121
|
* Delete an instance
|
122
122
|
|
123
|
-
### Memcached
|
124
|
-
|
125
|
-
* List, delete memcached instances
|
126
|
-
* Create new memcached instances with configurable CPU and Memory using Helm.
|
127
|
-
|
128
|
-
### Redis
|
129
|
-
|
130
|
-
* List, delete Redis instances
|
131
|
-
* Create new Redis instances with configurable CPU and Memory using Helm.
|
132
|
-
|
133
123
|
### Pods
|
134
124
|
|
135
125
|
* List pods for a given app
|
@@ -183,13 +173,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/joinha
|
|
183
173
|
Future roadmap has plans for:
|
184
174
|
|
185
175
|
- Create CLI help commands and improve general CLI usability
|
186
|
-
- Cloud SQL Postgres Management (credentials, processes, diagnostics, psql, etc)
|
187
|
-
- Smooth application restarts, including such as after changing secrets
|
188
|
-
- Better redis and memcached production-level management
|
189
176
|
- More functionality for managing pods
|
190
|
-
- Maintenance page mode
|
191
|
-
- Quickly scaling up/down deployments
|
192
|
-
- SSL Certificate inspection and observability through kube-lego
|
193
177
|
- More seamless `seira setup` script
|
194
178
|
|
195
179
|
|
data/lib/seira.rb
CHANGED
@@ -9,13 +9,11 @@ require "seira/version"
|
|
9
9
|
require 'helpers'
|
10
10
|
require 'seira/app'
|
11
11
|
require 'seira/cluster'
|
12
|
-
require 'seira/memcached'
|
13
12
|
require 'seira/pods'
|
14
13
|
require 'seira/jobs'
|
15
14
|
require 'seira/proxy'
|
16
15
|
require 'seira/random'
|
17
16
|
require 'seira/db'
|
18
|
-
require 'seira/redis'
|
19
17
|
require 'seira/secrets'
|
20
18
|
require 'seira/settings'
|
21
19
|
require 'seira/setup'
|
@@ -33,8 +31,6 @@ module Seira
|
|
33
31
|
'pods' => Seira::Pods,
|
34
32
|
'jobs' => Seira::Jobs,
|
35
33
|
'db' => Seira::Db,
|
36
|
-
'redis' => Seira::Redis,
|
37
|
-
'memcached' => Seira::Memcached,
|
38
34
|
'app' => Seira::App,
|
39
35
|
'cluster' => Seira::Cluster,
|
40
36
|
'proxy' => Seira::Proxy,
|
data/lib/seira/setup.rb
CHANGED
@@ -121,14 +121,6 @@ module Seira
|
|
121
121
|
puts "Installing kubectl..."
|
122
122
|
system('gcloud components install kubectl')
|
123
123
|
end
|
124
|
-
|
125
|
-
puts "Making sure kubernetes-helm is installed..."
|
126
|
-
# Only ask for client version since server config may not yet be configured,
|
127
|
-
# and in some versions of Helm it hanged.
|
128
|
-
unless system('helm version --client &> /dev/null')
|
129
|
-
puts "Installing helm..."
|
130
|
-
system('brew install kubernetes-helm')
|
131
|
-
end
|
132
124
|
end
|
133
125
|
|
134
126
|
def run_status
|
data/lib/seira/version.rb
CHANGED
data/seira.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_runtime_dependency "highline"
|
24
24
|
spec.add_runtime_dependency "colorize"
|
25
25
|
|
26
|
-
spec.add_development_dependency "bundler", "~>
|
26
|
+
spec.add_development_dependency "bundler", "~> 2"
|
27
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
28
28
|
spec.add_development_dependency "rspec", "~> 3.0"
|
29
29
|
spec.add_development_dependency "rubocop", "0.54.0"
|
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.7
|
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-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,12 +127,10 @@ files:
|
|
127
127
|
- lib/seira/db/alter_proxyuser_roles.rb
|
128
128
|
- lib/seira/db/create.rb
|
129
129
|
- lib/seira/jobs.rb
|
130
|
-
- lib/seira/memcached.rb
|
131
130
|
- lib/seira/node_pools.rb
|
132
131
|
- lib/seira/pods.rb
|
133
132
|
- lib/seira/proxy.rb
|
134
133
|
- lib/seira/random.rb
|
135
|
-
- lib/seira/redis.rb
|
136
134
|
- lib/seira/secrets.rb
|
137
135
|
- lib/seira/settings.rb
|
138
136
|
- lib/seira/setup.rb
|
data/lib/seira/memcached.rb
DELETED
@@ -1,156 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'base64'
|
3
|
-
|
4
|
-
module Seira
|
5
|
-
class Memcached
|
6
|
-
VALID_ACTIONS = %w[help list status credentials create delete].freeze
|
7
|
-
SUMMARY = "Manage your Helm Memcached instances.".freeze
|
8
|
-
|
9
|
-
attr_reader :app, :action, :args, :context
|
10
|
-
|
11
|
-
def initialize(app:, action:, args:, context:)
|
12
|
-
@app = app
|
13
|
-
@action = action
|
14
|
-
@args = args
|
15
|
-
@context = context
|
16
|
-
end
|
17
|
-
|
18
|
-
# TODO: logs, upgrades?, backups, restores, CLI connection
|
19
|
-
def run
|
20
|
-
case action
|
21
|
-
when 'help'
|
22
|
-
run_help
|
23
|
-
when 'list'
|
24
|
-
run_list
|
25
|
-
when 'status'
|
26
|
-
run_status
|
27
|
-
when 'credentials'
|
28
|
-
run_credentials
|
29
|
-
when 'create'
|
30
|
-
run_create
|
31
|
-
when 'delete'
|
32
|
-
run_delete
|
33
|
-
else
|
34
|
-
fail "Unknown command encountered"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def run_help
|
41
|
-
puts SUMMARY
|
42
|
-
puts "\n\n"
|
43
|
-
puts "TODO"
|
44
|
-
end
|
45
|
-
|
46
|
-
def run_list
|
47
|
-
puts existing_instances
|
48
|
-
end
|
49
|
-
|
50
|
-
def run_status
|
51
|
-
puts `helm status #{app}-memcached-#{args[0]}`
|
52
|
-
end
|
53
|
-
|
54
|
-
def run_create
|
55
|
-
# Fairly beefy default compute because it's cheap and the longer we can defer upgrading the
|
56
|
-
# better. Go even higher for production apps.
|
57
|
-
# TODO: Enable metrics
|
58
|
-
values = {
|
59
|
-
resources: {
|
60
|
-
requests: {
|
61
|
-
memory: '500Mi',
|
62
|
-
cpu: '50m'
|
63
|
-
}
|
64
|
-
}
|
65
|
-
}
|
66
|
-
|
67
|
-
replica_count = 3 # The default
|
68
|
-
|
69
|
-
args.each do |arg|
|
70
|
-
puts "Applying arg #{arg} to values"
|
71
|
-
if arg.start_with?('--memory=')
|
72
|
-
values[:resources][:requests][:memory] = arg.split('=')[1]
|
73
|
-
elsif arg.start_with?('--cpu=')
|
74
|
-
values[:resources][:requests][:cpu] = arg.split('=')[1]
|
75
|
-
elsif arg.start_with?('--replicas=')
|
76
|
-
replica_count = arg.split('=')[1]
|
77
|
-
elsif arg.start_with?('--size=')
|
78
|
-
size = arg.split('=')[1]
|
79
|
-
case size
|
80
|
-
when '1'
|
81
|
-
values[:resources][:requests][:memory] = '100Mi'
|
82
|
-
values[:resources][:requests][:cpu] = '50m'
|
83
|
-
when '2'
|
84
|
-
values[:resources][:requests][:memory] = '250Mi'
|
85
|
-
values[:resources][:requests][:cpu] = '100m'
|
86
|
-
when '3'
|
87
|
-
values[:resources][:requests][:memory] = '500Mi'
|
88
|
-
values[:resources][:requests][:cpu] = '200m'
|
89
|
-
when '4'
|
90
|
-
values[:resources][:requests][:memory] = '1Gi'
|
91
|
-
values[:resources][:requests][:cpu] = '500m'
|
92
|
-
when '5'
|
93
|
-
values[:resources][:requests][:memory] = '2Gi'
|
94
|
-
values[:resources][:requests][:cpu] = '500m'
|
95
|
-
when '6'
|
96
|
-
values[:resources][:requests][:memory] = '5Gi'
|
97
|
-
values[:resources][:requests][:cpu] = '1'
|
98
|
-
when '7'
|
99
|
-
values[:resources][:requests][:memory] = '10Gi'
|
100
|
-
values[:resources][:requests][:cpu] = '2'
|
101
|
-
when '8'
|
102
|
-
values[:resources][:requests][:memory] = '50Gi'
|
103
|
-
values[:resources][:requests][:cpu] = '4'
|
104
|
-
else
|
105
|
-
fail "There is no size option '#{size}'"
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
# Make sure that pdbMinAvailable is always 1 less than total replica count
|
111
|
-
# so that we can properly cordon and drain a node.
|
112
|
-
values[:replicaCount] = replica_count
|
113
|
-
values[:pdbMinAvailable] = replica_count - 1
|
114
|
-
|
115
|
-
unique_name = Seira::Random.unique_name(existing_instances)
|
116
|
-
name = "#{app}-memcached-#{unique_name}"
|
117
|
-
|
118
|
-
Dir.mktmpdir do |dir|
|
119
|
-
file_name = write_config(dir: dir, values: values)
|
120
|
-
puts `helm install --namespace #{app} --name #{name} --wait -f #{file_name} stable/memcached`
|
121
|
-
end
|
122
|
-
|
123
|
-
puts "To get status: 'seira #{context[:cluster]} #{app} memcached status #{unique_name}'"
|
124
|
-
puts "Service URI for this memcached instance: 'memcached://#{name}-memcached:11211'."
|
125
|
-
end
|
126
|
-
|
127
|
-
def run_delete
|
128
|
-
to_delete = "#{app}-memcached-#{args[0]}"
|
129
|
-
|
130
|
-
exit(1) unless HighLine.agree("Are you sure you want to delete #{to_delete}? If any apps are using this memcached instance, they will break.")
|
131
|
-
|
132
|
-
if system("helm delete #{to_delete}")
|
133
|
-
puts "Successfully deleted #{to_delete}. Mistake and seeing errors now? You can rollback easily. Below is last 5 revisions of the now deleted resource."
|
134
|
-
history = `helm history --max 5 #{to_delete}`
|
135
|
-
puts history
|
136
|
-
last_revision = history.split("\n").last.split(" ").map(&:strip)[0]
|
137
|
-
puts "helm rollback #{to_delete} #{last_revision}"
|
138
|
-
puts "Docs: https://github.com/kubernetes/helm/blob/master/docs/helm/helm_rollback.md"
|
139
|
-
else
|
140
|
-
puts "Delete failed"
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
def write_config(dir:, values:)
|
145
|
-
file_name = "#{dir}/temp-memcached-config-#{Seira::Cluster.current_cluster}-#{app}.json"
|
146
|
-
File.open(file_name, "wb") do |f|
|
147
|
-
f.write(values.to_json)
|
148
|
-
end
|
149
|
-
file_name
|
150
|
-
end
|
151
|
-
|
152
|
-
def existing_instances
|
153
|
-
`helm list`.split("\n").select { |item| item.start_with?("#{app}-memcached") }.map { |name| name.gsub(/^#{app}-memcached-/, '') }
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
data/lib/seira/redis.rb
DELETED
@@ -1,166 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'base64'
|
3
|
-
|
4
|
-
module Seira
|
5
|
-
class Redis
|
6
|
-
VALID_ACTIONS = %w[help list status credentials create delete].freeze
|
7
|
-
SUMMARY = "Manage your Helm Redis instances.".freeze
|
8
|
-
|
9
|
-
attr_reader :app, :action, :args, :context
|
10
|
-
|
11
|
-
def initialize(app:, action:, args:, context:)
|
12
|
-
@app = app
|
13
|
-
@action = action
|
14
|
-
@args = args
|
15
|
-
@context = context
|
16
|
-
end
|
17
|
-
|
18
|
-
# TODO: logs, upgrades?, backups, restores, CLI connection
|
19
|
-
def run
|
20
|
-
case action
|
21
|
-
when 'help'
|
22
|
-
run_help
|
23
|
-
when 'list'
|
24
|
-
run_list
|
25
|
-
when 'status'
|
26
|
-
run_status
|
27
|
-
when 'credentials'
|
28
|
-
run_credentials
|
29
|
-
when 'create'
|
30
|
-
run_create
|
31
|
-
when 'delete'
|
32
|
-
run_delete
|
33
|
-
else
|
34
|
-
fail "Unknown command encountered"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def run_help
|
41
|
-
puts SUMMARY
|
42
|
-
puts "\n\n"
|
43
|
-
puts "TODO"
|
44
|
-
end
|
45
|
-
|
46
|
-
def run_list
|
47
|
-
puts existing_instances
|
48
|
-
end
|
49
|
-
|
50
|
-
def run_status
|
51
|
-
puts `helm status #{app}-redis-#{args[0]}`
|
52
|
-
end
|
53
|
-
|
54
|
-
def run_create
|
55
|
-
# Fairly beefy default compute because it's cheap and the longer we can defer upgrading the
|
56
|
-
# better. Go even higher for production apps.
|
57
|
-
# TODO: Enable metrics
|
58
|
-
values = {
|
59
|
-
persistence: {
|
60
|
-
size: '1Gi'
|
61
|
-
},
|
62
|
-
resources: {
|
63
|
-
requests: {
|
64
|
-
cpu: '50m',
|
65
|
-
memory: '50Mi'
|
66
|
-
}
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
# Redis is single-threaded, thus only one CPU is needed? Primary/replica
|
71
|
-
# is needed for further throughput
|
72
|
-
args.each do |arg|
|
73
|
-
puts "Applying arg #{arg} to values"
|
74
|
-
if arg.start_with?('--memory=')
|
75
|
-
values[:resources][:requests][:memory] = arg.split('=')[1]
|
76
|
-
elsif arg.start_with?('--volume=')
|
77
|
-
values[:persistence][:volume] = arg.split('=')[1]
|
78
|
-
elsif arg.start_with?('--cpu=')
|
79
|
-
values[:resources][:requests][:cpu] = arg.split('=')[1]
|
80
|
-
elsif arg.start_with?('--size=')
|
81
|
-
size = arg.split('=')[1]
|
82
|
-
case size
|
83
|
-
when '1'
|
84
|
-
values[:resources][:requests][:memory] = '50Mi'
|
85
|
-
values[:persistence][:size] = '1Gi'
|
86
|
-
values[:resources][:requests][:cpu] = '50m'
|
87
|
-
when '2'
|
88
|
-
values[:resources][:requests][:memory] = '100Mi'
|
89
|
-
values[:persistence][:size] = '1Gi'
|
90
|
-
values[:resources][:requests][:cpu] = '100m'
|
91
|
-
when '3'
|
92
|
-
values[:resources][:requests][:memory] = '250Mi'
|
93
|
-
values[:persistence][:size] = '1Gi'
|
94
|
-
values[:resources][:requests][:cpu] = '200m'
|
95
|
-
when '4'
|
96
|
-
values[:resources][:requests][:memory] = '500Mi'
|
97
|
-
values[:persistence][:size] = '1Gi'
|
98
|
-
values[:resources][:requests][:cpu] = '500m'
|
99
|
-
when '5'
|
100
|
-
values[:resources][:requests][:memory] = '1Gi'
|
101
|
-
values[:persistence][:size] = '5Gi'
|
102
|
-
values[:resources][:requests][:cpu] = '1'
|
103
|
-
when '6'
|
104
|
-
values[:resources][:requests][:memory] = '2Gi'
|
105
|
-
values[:persistence][:size] = '5Gi'
|
106
|
-
values[:resources][:requests][:cpu] = '1'
|
107
|
-
when '7'
|
108
|
-
values[:resources][:requests][:memory] = '5Gi'
|
109
|
-
values[:persistence][:size] = '5Gi'
|
110
|
-
values[:resources][:requests][:cpu] = '1'
|
111
|
-
when '8'
|
112
|
-
values[:resources][:requests][:memory] = '10Gi'
|
113
|
-
values[:persistence][:size] = '20Gi'
|
114
|
-
values[:resources][:requests][:cpu] = '1'
|
115
|
-
when '9'
|
116
|
-
values[:resources][:requests][:memory] = '20Gi'
|
117
|
-
values[:persistence][:size] = '40Gi'
|
118
|
-
values[:resources][:requests][:cpu] = '1'
|
119
|
-
else
|
120
|
-
fail "There is no size option '#{size}'"
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
Dir.mktmpdir do |dir|
|
126
|
-
file_name = write_config(dir: dir, values: values)
|
127
|
-
unique_name = Seira::Random.unique_name(existing_instances)
|
128
|
-
name = "#{app}-redis-#{unique_name}"
|
129
|
-
puts `helm install --namespace #{app} --name #{name} --wait -f #{file_name} stable/redis`
|
130
|
-
end
|
131
|
-
|
132
|
-
puts "To get status: 'seira #{context[:cluster]} #{app} redis status #{unique_name}'"
|
133
|
-
puts "To get credentials for storing in app secrets: 'seira #{context[:cluster]} #{app} redis credentials #{unique_name}'"
|
134
|
-
puts "Service URI for this Redis instance: 'redis://:<password goes here>@#{name}-redis:6379/0'."
|
135
|
-
end
|
136
|
-
|
137
|
-
def run_delete
|
138
|
-
to_delete = "#{app}-redis-#{args[0]}"
|
139
|
-
|
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.")
|
141
|
-
|
142
|
-
if system("helm delete #{to_delete}")
|
143
|
-
puts "Successfully deleted #{to_delete}. Mistake and seeing errors now? You can rollback easily. Below is last 5 revisions of the now deleted resource."
|
144
|
-
history = `helm history --max 5 #{to_delete}`
|
145
|
-
puts history
|
146
|
-
last_revision = history.split("\n").last.split(" ").map(&:strip)[0]
|
147
|
-
puts "helm rollback #{to_delete} #{last_revision}"
|
148
|
-
puts "Docs: https://github.com/kubernetes/helm/blob/master/docs/helm/helm_rollback.md"
|
149
|
-
else
|
150
|
-
puts "Delete failed"
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
def write_config(dir:, values:)
|
155
|
-
file_name = "#{dir}/temp-redis-config-#{Seira::Cluster.current_cluster}-#{app}.json"
|
156
|
-
File.open(file_name, "wb") do |f|
|
157
|
-
f.write(values.to_json)
|
158
|
-
end
|
159
|
-
file_name
|
160
|
-
end
|
161
|
-
|
162
|
-
def existing_instances
|
163
|
-
list = `helm list`.split("\n").select { |item| item.start_with?("#{app}-redis") }.map { |name| name.gsub(/^#{app}-redis-/, '') }
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|