kubr 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +33 -0
- data/README.md +44 -0
- data/kubr.gemspec +20 -0
- data/lib/core_ext/hash.rb +11 -0
- data/lib/kubr/client.rb +44 -0
- data/lib/kubr/configuration.rb +21 -0
- data/lib/kubr/version.rb +3 -0
- data/lib/kubr.rb +4 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 80eebaf14a1ba6039e9b5295c1a3894b99930c32
|
4
|
+
data.tar.gz: 8ad2b57fc256c63d376fa5f6538508457e5bb9e3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: edae0c1614584bb86dfcd1a6d5021db6b2ccb948a152260706ce6878d5bef206b53937bdc40aa850afd0658ddbb7b5cca8be2888d50956f0d17664bd587e4a6c
|
7
|
+
data.tar.gz: feb99400c64f60c64763cfd59f9023ac0108221b3a94216413c076b89859ddb4b830dcbbba92e74da9bcb1ce45893e0fe312591d0b0fde63ee1f70ad3f7e53a8
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
kubr (0.0.1)
|
5
|
+
activesupport
|
6
|
+
rest-client
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (4.1.5)
|
12
|
+
i18n (~> 0.6, >= 0.6.9)
|
13
|
+
json (~> 1.7, >= 1.7.7)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
thread_safe (~> 0.1)
|
16
|
+
tzinfo (~> 1.1)
|
17
|
+
i18n (0.7.0.beta1)
|
18
|
+
json (1.8.1)
|
19
|
+
mime-types (2.3)
|
20
|
+
minitest (5.4.1)
|
21
|
+
netrc (0.7.7)
|
22
|
+
rest-client (1.7.2)
|
23
|
+
mime-types (>= 1.16, < 3.0)
|
24
|
+
netrc (~> 0.7)
|
25
|
+
thread_safe (0.3.4)
|
26
|
+
tzinfo (1.2.2)
|
27
|
+
thread_safe (~> 0.1)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
kubr!
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
Kubr
|
2
|
+
=====
|
3
|
+
|
4
|
+
Ruby client for [Kubrnetes](https://github.com/GoogleCloudPlatform/Kubrnetes)
|
5
|
+
[REST API](http://cdn.rawgit.com/GoogleCloudPlatform/kubernetes/31a0daae3627c91bc96e1f02a6344cd76e294791/api/kubernetes.html)
|
6
|
+
|
7
|
+
Installation
|
8
|
+
------------
|
9
|
+
|
10
|
+
```
|
11
|
+
gem install Kubr
|
12
|
+
```
|
13
|
+
|
14
|
+
Usage
|
15
|
+
-----
|
16
|
+
|
17
|
+
```
|
18
|
+
require 'Kubr'
|
19
|
+
|
20
|
+
Kubr.configure do |config|
|
21
|
+
config.url = 'https://130.211.56.93/api/v1beta1'
|
22
|
+
config.username = 'admin'
|
23
|
+
config.password = 'hv9tgLhKdej3HAHE'
|
24
|
+
end
|
25
|
+
|
26
|
+
cl = Kubr::Client.new
|
27
|
+
pods = cl.list_pods
|
28
|
+
|
29
|
+
pod = {
|
30
|
+
:desiredState => {
|
31
|
+
:manifest => {
|
32
|
+
:version => 'v1beta1',
|
33
|
+
:containers => [
|
34
|
+
{
|
35
|
+
:name => 'aytest2',
|
36
|
+
:image => 'dockerfile/nginx',
|
37
|
+
}
|
38
|
+
]
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
cl.create_pod pod
|
44
|
+
```
|
data/kubr.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require './lib/Kubr/version.rb'
|
2
|
+
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'kubr'
|
6
|
+
s.version = Kubr::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ['Andriy Yurchuk']
|
9
|
+
s.email = ['ayurchuk@minuteware.net']
|
10
|
+
s.homepage = 'https://github.com/Ch00k/kubr'
|
11
|
+
s.summary = 'Kubrnetes REST API client'
|
12
|
+
s.description = 'Ruby wrapper over Kubrnetes REST API'
|
13
|
+
s.license = 'MIT'
|
14
|
+
|
15
|
+
s.add_dependency 'rest-client'
|
16
|
+
s.add_dependency 'activesupport'
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.require_path = 'lib'
|
20
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'active_support/core_ext'
|
2
|
+
|
3
|
+
|
4
|
+
class Hash
|
5
|
+
def recursively_symbolize_keys!
|
6
|
+
symbolize_keys!
|
7
|
+
values.each { |h| h.recursively_symbolize_keys! if h.is_a?(Hash) }
|
8
|
+
values.select { |v| v.is_a?(Array) }.flatten.each{|h| h.recursively_symbolize_keys! if h.is_a?(Hash) }
|
9
|
+
self
|
10
|
+
end
|
11
|
+
end
|
data/lib/kubr/client.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'rest-client'
|
3
|
+
require 'active_support/inflector'
|
4
|
+
|
5
|
+
module Kubr
|
6
|
+
class Client
|
7
|
+
def initialize
|
8
|
+
Kubr.configuration ||= Kubr::Configuration.new
|
9
|
+
@cl = RestClient::Resource.new(Kubr.configuration.url,
|
10
|
+
:user => Kubr.configuration.username,
|
11
|
+
:password => Kubr.configuration.password,
|
12
|
+
:verify_ssl => OpenSSL::SSL::VERIFY_NONE)
|
13
|
+
end
|
14
|
+
|
15
|
+
def send_request(method, path, body=nil)
|
16
|
+
args = [method]
|
17
|
+
args << body.to_json if body
|
18
|
+
process_response @cl[path].send(*args)
|
19
|
+
end
|
20
|
+
|
21
|
+
def process_response(response)
|
22
|
+
JSON.parse(response).recursively_symbolize_keys!
|
23
|
+
end
|
24
|
+
|
25
|
+
['pod', 'service', 'replicationController'].each do |entity|
|
26
|
+
define_method "list_#{entity.underscore.pluralize}" do
|
27
|
+
response = send_request :get, entity.pluralize
|
28
|
+
response[:items]
|
29
|
+
end
|
30
|
+
|
31
|
+
define_method "create_#{entity.underscore}" do |config|
|
32
|
+
send_request :post, entity.pluralize, config
|
33
|
+
end
|
34
|
+
|
35
|
+
define_method "update_#{entity.underscore}" do |config|
|
36
|
+
send_request :put, entity.pluralize, config
|
37
|
+
end
|
38
|
+
|
39
|
+
define_method "delete_#{entity.underscore}" do |id|
|
40
|
+
send_request :delete, "#{entity.pluralize}/#{id}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Kubr
|
2
|
+
class Configuration
|
3
|
+
|
4
|
+
attr_accessor :url, :username, :password
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@url = ''
|
8
|
+
@username = ''
|
9
|
+
@password = ''
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class << self
|
14
|
+
attr_accessor :configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.configure
|
18
|
+
self.configuration ||= Configuration.new
|
19
|
+
yield configuration
|
20
|
+
end
|
21
|
+
end
|
data/lib/kubr/version.rb
ADDED
data/lib/kubr.rb
ADDED
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kubr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andriy Yurchuk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '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'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Ruby wrapper over Kubrnetes REST API
|
42
|
+
email:
|
43
|
+
- ayurchuk@minuteware.net
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- README.md
|
52
|
+
- kubr.gemspec
|
53
|
+
- lib/core_ext/hash.rb
|
54
|
+
- lib/kubr.rb
|
55
|
+
- lib/kubr/client.rb
|
56
|
+
- lib/kubr/configuration.rb
|
57
|
+
- lib/kubr/version.rb
|
58
|
+
homepage: https://github.com/Ch00k/kubr
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.2.2
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Kubrnetes REST API client
|
82
|
+
test_files: []
|