rhea 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +165 -2
- data/app/assets/javascripts/rhea/application.js +2 -0
- data/app/assets/javascripts/rhea/main.js +3 -0
- data/app/assets/javascripts/vendor/jquery-1.11.3.js +10351 -0
- data/app/assets/stylesheets/rhea/application.css.sass +1 -0
- data/app/assets/stylesheets/rhea/layout.css.sass +31 -0
- data/app/controllers/rhea/base_controller.rb +26 -0
- data/app/controllers/rhea/commands_controller.rb +168 -0
- data/app/controllers/rhea/events_controller.rb +8 -0
- data/app/controllers/rhea/nodes_controller.rb +7 -0
- data/app/controllers/rhea/system_services_controller.rb +7 -0
- data/app/helpers/rhea/helper.rb +42 -0
- data/app/views/rhea/command_types/_list.html.haml +5 -0
- data/app/views/rhea/commands/_form.html.haml +22 -0
- data/app/views/rhea/commands/_table.html.haml +51 -0
- data/app/views/rhea/commands/index.html.haml +51 -0
- data/app/views/rhea/errors/index.html.haml +2 -0
- data/app/views/rhea/events/index.html.haml +24 -0
- data/app/views/rhea/layouts/application.html.haml +35 -0
- data/app/views/rhea/nodes/index.html.haml +29 -0
- data/app/views/rhea/system_services/index.html.haml +2 -0
- data/config/routes.rb +21 -0
- data/docs/commands.gif +0 -0
- data/docs/commands.mov +0 -0
- data/docs/events.png +0 -0
- data/docs/logo.png +0 -0
- data/docs/nodes.png +0 -0
- data/fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_All/_perform/an_existing_rc/returns_the_rc.yml +197 -0
- data/fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Delete/_perform/an_existing_rc/deletes_the_rc.yml +163 -0
- data/fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Export/_perform/an_existing_rc/returns_the_data.yml +197 -0
- data/fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Get/_perform/an_existing_rc/gets_the_rc.yml +196 -0
- data/fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Import/_perform/no_existing_rcs/creates_the_rcs.yml +197 -0
- data/fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Redeploy/_perform/an_existing_rc/redeploys_the_rc.yml +424 -0
- data/fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Reschedule/_perform/an_existing_rc/reschedules_the_rc.yml +421 -0
- data/fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Scale/_perform/no_existing_rc/creates_an_rc.yml +165 -0
- data/lib/rhea.rb +15 -1
- data/lib/rhea/command.rb +35 -0
- data/lib/rhea/command_type.rb +35 -0
- data/lib/rhea/engine.rb +16 -0
- data/lib/rhea/kubernetes.rb +5 -0
- data/lib/rhea/kubernetes/api.rb +15 -0
- data/lib/rhea/kubernetes/commands/all.rb +16 -0
- data/lib/rhea/kubernetes/commands/base.rb +28 -0
- data/lib/rhea/kubernetes/commands/delete.rb +18 -0
- data/lib/rhea/kubernetes/commands/export.rb +23 -0
- data/lib/rhea/kubernetes/commands/get.rb +18 -0
- data/lib/rhea/kubernetes/commands/import.rb +20 -0
- data/lib/rhea/kubernetes/commands/redeploy.rb +22 -0
- data/lib/rhea/kubernetes/commands/reschedule.rb +21 -0
- data/lib/rhea/kubernetes/commands/scale.rb +108 -0
- data/lib/rhea/kubernetes/configuration.rb +30 -0
- data/lib/rhea/kubernetes/events/recent.rb +23 -0
- data/lib/rhea/kubernetes/nodes/all.rb +45 -0
- data/lib/rhea/kubernetes/system_services.rb +22 -0
- data/lib/rhea/version.rb +1 -1
- data/rhea.gemspec +11 -3
- data/spec/lib/rhea/kubernetes/commands/all_spec.rb +29 -0
- data/spec/lib/rhea/kubernetes/commands/delete_spec.rb +22 -0
- data/spec/lib/rhea/kubernetes/commands/export_spec.rb +31 -0
- data/spec/lib/rhea/kubernetes/commands/get_spec.rb +28 -0
- data/spec/lib/rhea/kubernetes/commands/import_spec.rb +39 -0
- data/spec/lib/rhea/kubernetes/commands/redeploy_spec.rb +35 -0
- data/spec/lib/rhea/kubernetes/commands/reschedule_spec.rb +32 -0
- data/spec/lib/rhea/kubernetes/commands/scale_spec.rb +31 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/kubernetes_spec_helper.rb +43 -0
- data/spec/support/vcr.rb +9 -0
- metadata +170 -11
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rhea::Kubernetes::Commands::Reschedule, :vcr do
|
4
|
+
include KubernetesSpecHelper
|
5
|
+
|
6
|
+
before(:each) { delete_replication_controllers }
|
7
|
+
after(:each) { delete_replication_controllers }
|
8
|
+
|
9
|
+
describe '#perform' do
|
10
|
+
context 'an existing rc' do
|
11
|
+
let(:process_count) { 2 }
|
12
|
+
|
13
|
+
before :each do
|
14
|
+
Rhea::Kubernetes::Commands::Scale.new(expression: command_expression, process_count: process_count).perform
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'reschedules the rc' do
|
18
|
+
described_class.new(expression: command_expression).perform
|
19
|
+
replication_controller = Rhea::Kubernetes::Commands::Get.new(expression: command_expression).perform
|
20
|
+
expected_attributes = {
|
21
|
+
expression: command_expression,
|
22
|
+
image: kube_image,
|
23
|
+
process_count: process_count
|
24
|
+
}
|
25
|
+
expect(replication_controller.attributes).to include(expected_attributes)
|
26
|
+
|
27
|
+
expect(WebMock).to have_requested(:post, "#{kube_authed_api_url}replicationcontrollers")
|
28
|
+
expect(WebMock).to have_requested(:put, "#{kube_authed_api_url}replicationcontrollers/#{kube_replication_controller_name}").twice
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rhea::Kubernetes::Commands::Scale, :vcr do
|
4
|
+
include KubernetesSpecHelper
|
5
|
+
|
6
|
+
before(:each) { delete_replication_controllers }
|
7
|
+
after(:each) { delete_replication_controllers }
|
8
|
+
|
9
|
+
let(:process_count) { 2 }
|
10
|
+
|
11
|
+
describe '#perform' do
|
12
|
+
context 'no existing rc' do
|
13
|
+
it 'creates an rc' do
|
14
|
+
described_class.new(expression: command_expression, process_count: process_count).perform
|
15
|
+
matches = -> (request) do
|
16
|
+
data = ActiveSupport::JSON.decode(request.body)
|
17
|
+
container = data['spec']['template']['spec']['containers'][0]
|
18
|
+
expected_container = {
|
19
|
+
'command' => command_expression.split(' '),
|
20
|
+
'image' => kube_image,
|
21
|
+
'name' => kube_replication_controller_name,
|
22
|
+
'env' => kube_env_vars.map { |name, value| { 'name' => name, 'value' => value } }
|
23
|
+
}
|
24
|
+
hash_includes_hash?(container, expected_container)
|
25
|
+
end
|
26
|
+
url = "#{kube_authed_api_url}replicationcontrollers"
|
27
|
+
expect(WebMock).to have_requested(:post, url).with { |request| matches.call(request) }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
module KubernetesSpecHelper
|
2
|
+
extend RSpec::SharedContext
|
3
|
+
|
4
|
+
let(:kube_user) { 'vagrant' }
|
5
|
+
let(:kube_password) { 'vagrant' }
|
6
|
+
let(:kube_api_host) { 'kube.local' }
|
7
|
+
let(:kube_namespace) { 'default' }
|
8
|
+
let(:kube_authed_api_url) { "https://#{kube_user}:#{kube_password}@#{kube_api_host}/api/v1/namespaces/#{kube_namespace}/" }
|
9
|
+
let(:kube_env_vars) { { 'MY_ENV_VAR_NAME' => 'my_env_var_value' } }
|
10
|
+
let(:kube_image) { 'docker.local/myimage:latest' }
|
11
|
+
let(:kube_replication_controller_name) { 'rhea-7370-foo-bar' }
|
12
|
+
|
13
|
+
let(:command_expression) { 'foo -bar' }
|
14
|
+
|
15
|
+
before :each do
|
16
|
+
Rhea.configure do |config|
|
17
|
+
config.default_command_type_key = 'sidekiq'
|
18
|
+
config.env_vars = kube_env_vars
|
19
|
+
config.kube_api = {
|
20
|
+
options: {
|
21
|
+
auth_options: { user: kube_user, password: kube_password },
|
22
|
+
ssl_options: { verify_ssl: OpenSSL::SSL::VERIFY_NONE }
|
23
|
+
},
|
24
|
+
url: "https://#{kube_api_host}/api/"
|
25
|
+
}
|
26
|
+
config.default_image = kube_image
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete_replication_controllers
|
31
|
+
@api ||= Rhea::Kubernetes::Api.new
|
32
|
+
controllers = @api.get_replication_controllers
|
33
|
+
controllers.each do |controller|
|
34
|
+
name = controller.metadata.name
|
35
|
+
next unless name.start_with?('rhea-')
|
36
|
+
@api.delete_replication_controller(controller.metadata.name, kube_namespace)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def hash_includes_hash?(parent_hash, child_hash)
|
41
|
+
parent_hash.merge(child_hash) == parent_hash
|
42
|
+
end
|
43
|
+
end
|
data/spec/support/vcr.rb
ADDED
metadata
CHANGED
@@ -1,30 +1,128 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhea
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Benner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: kubeclient
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.3.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.3.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: haml
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: kaminari
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.16'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.16'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sass-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
13
69
|
- !ruby/object:Gem::Dependency
|
14
70
|
name: rspec
|
15
71
|
requirement: !ruby/object:Gem::Requirement
|
16
72
|
requirements:
|
17
|
-
- - "
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec-rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: vcr
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.9'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.9'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
18
116
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
117
|
+
version: '1.8'
|
20
118
|
type: :development
|
21
119
|
prerelease: false
|
22
120
|
version_requirements: !ruby/object:Gem::Requirement
|
23
121
|
requirements:
|
24
|
-
- - "
|
122
|
+
- - "~>"
|
25
123
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
description:
|
124
|
+
version: '1.8'
|
125
|
+
description: A web UI for managing a Kubernetes cluster
|
28
126
|
email:
|
29
127
|
- tombenner@gmail.com
|
30
128
|
executables: []
|
@@ -36,11 +134,73 @@ files:
|
|
36
134
|
- MIT-LICENSE
|
37
135
|
- README.md
|
38
136
|
- Rakefile
|
137
|
+
- app/assets/javascripts/rhea/application.js
|
138
|
+
- app/assets/javascripts/rhea/main.js
|
139
|
+
- app/assets/javascripts/vendor/jquery-1.11.3.js
|
140
|
+
- app/assets/stylesheets/rhea/application.css.sass
|
141
|
+
- app/assets/stylesheets/rhea/layout.css.sass
|
142
|
+
- app/controllers/rhea/base_controller.rb
|
143
|
+
- app/controllers/rhea/commands_controller.rb
|
144
|
+
- app/controllers/rhea/events_controller.rb
|
145
|
+
- app/controllers/rhea/nodes_controller.rb
|
146
|
+
- app/controllers/rhea/system_services_controller.rb
|
147
|
+
- app/helpers/rhea/helper.rb
|
148
|
+
- app/views/rhea/command_types/_list.html.haml
|
149
|
+
- app/views/rhea/commands/_form.html.haml
|
150
|
+
- app/views/rhea/commands/_table.html.haml
|
151
|
+
- app/views/rhea/commands/index.html.haml
|
152
|
+
- app/views/rhea/errors/index.html.haml
|
153
|
+
- app/views/rhea/events/index.html.haml
|
154
|
+
- app/views/rhea/layouts/application.html.haml
|
155
|
+
- app/views/rhea/nodes/index.html.haml
|
156
|
+
- app/views/rhea/system_services/index.html.haml
|
157
|
+
- config/routes.rb
|
158
|
+
- docs/commands.gif
|
159
|
+
- docs/commands.mov
|
160
|
+
- docs/events.png
|
161
|
+
- docs/logo.png
|
162
|
+
- docs/nodes.png
|
163
|
+
- fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_All/_perform/an_existing_rc/returns_the_rc.yml
|
164
|
+
- fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Delete/_perform/an_existing_rc/deletes_the_rc.yml
|
165
|
+
- fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Export/_perform/an_existing_rc/returns_the_data.yml
|
166
|
+
- fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Get/_perform/an_existing_rc/gets_the_rc.yml
|
167
|
+
- fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Import/_perform/no_existing_rcs/creates_the_rcs.yml
|
168
|
+
- fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Redeploy/_perform/an_existing_rc/redeploys_the_rc.yml
|
169
|
+
- fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Reschedule/_perform/an_existing_rc/reschedules_the_rc.yml
|
170
|
+
- fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Scale/_perform/no_existing_rc/creates_an_rc.yml
|
39
171
|
- lib/rhea.rb
|
172
|
+
- lib/rhea/command.rb
|
173
|
+
- lib/rhea/command_type.rb
|
174
|
+
- lib/rhea/engine.rb
|
175
|
+
- lib/rhea/kubernetes.rb
|
176
|
+
- lib/rhea/kubernetes/api.rb
|
177
|
+
- lib/rhea/kubernetes/commands/all.rb
|
178
|
+
- lib/rhea/kubernetes/commands/base.rb
|
179
|
+
- lib/rhea/kubernetes/commands/delete.rb
|
180
|
+
- lib/rhea/kubernetes/commands/export.rb
|
181
|
+
- lib/rhea/kubernetes/commands/get.rb
|
182
|
+
- lib/rhea/kubernetes/commands/import.rb
|
183
|
+
- lib/rhea/kubernetes/commands/redeploy.rb
|
184
|
+
- lib/rhea/kubernetes/commands/reschedule.rb
|
185
|
+
- lib/rhea/kubernetes/commands/scale.rb
|
186
|
+
- lib/rhea/kubernetes/configuration.rb
|
187
|
+
- lib/rhea/kubernetes/events/recent.rb
|
188
|
+
- lib/rhea/kubernetes/nodes/all.rb
|
189
|
+
- lib/rhea/kubernetes/system_services.rb
|
40
190
|
- lib/rhea/version.rb
|
41
191
|
- rhea.gemspec
|
192
|
+
- spec/lib/rhea/kubernetes/commands/all_spec.rb
|
193
|
+
- spec/lib/rhea/kubernetes/commands/delete_spec.rb
|
194
|
+
- spec/lib/rhea/kubernetes/commands/export_spec.rb
|
195
|
+
- spec/lib/rhea/kubernetes/commands/get_spec.rb
|
196
|
+
- spec/lib/rhea/kubernetes/commands/import_spec.rb
|
197
|
+
- spec/lib/rhea/kubernetes/commands/redeploy_spec.rb
|
198
|
+
- spec/lib/rhea/kubernetes/commands/reschedule_spec.rb
|
199
|
+
- spec/lib/rhea/kubernetes/commands/scale_spec.rb
|
42
200
|
- spec/spec_helper.rb
|
43
|
-
|
201
|
+
- spec/support/kubernetes_spec_helper.rb
|
202
|
+
- spec/support/vcr.rb
|
203
|
+
homepage: https://github.com/entelo/rhea
|
44
204
|
licenses:
|
45
205
|
- MIT
|
46
206
|
metadata: {}
|
@@ -60,9 +220,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
220
|
version: '0'
|
61
221
|
requirements: []
|
62
222
|
rubyforge_project:
|
63
|
-
rubygems_version: 2.4.
|
223
|
+
rubygems_version: 2.4.8
|
64
224
|
signing_key:
|
65
225
|
specification_version: 4
|
66
|
-
summary:
|
226
|
+
summary: A web UI for managing a Kubernetes cluster
|
67
227
|
test_files: []
|
68
|
-
has_rdoc:
|