kubeclient 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of kubeclient might be problematic. Click here for more details.
- checksums.yaml +8 -8
- data/README.md +9 -9
- data/lib/kubeclient.rb +14 -5
- data/lib/kubeclient/version.rb +1 -1
- data/test/node_test.rb +20 -2
- data/test/pod_test.rb +17 -1
- data/test/replication_controller_test.rb +19 -1
- data/test/service_test.rb +27 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTU4ZWFlNzhiODQ2M2ViM2JiNjJhOGYyMWUzMDVmZGI1MzU1ZjcxYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Nzg4ZTc2OTlhOGVjZTZjN2MzYWU1ZWZlYTZhMmU5MDQwNTM3MDI2NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDE4OTkyNmE4NjIwMDVjM2QyOGI3YmE4MTU0ODllMDFlZTU4NGMyNzA3OWY2
|
10
|
+
N2EzMGY3OGZhNGQ4MTk1OWM2NDY5MWNhMWRlY2E4MTNjZjQ4NmI3NjVjMWJi
|
11
|
+
OTliYjZlZGUyMWU1MDQzNWY2MGRlMjI1Y2RhMGE1NDBiMWQzYzk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWE1OGYzYTdjNTYyYzAxMDNmOTk0YTdmNzA5NGE0OGYwODI2MGZkMGVjYTgx
|
14
|
+
YTI0OGEzM2QxNmRhMTA0OWY5OTZkMjU0OWZmMjY4NDAyMzI0N2EzZGZmZDUw
|
15
|
+
OTBjOGNjZjAxYjdmMmU1NjY1NjU5YTYzYjQ4NWU5ZWMyNWZlMzY=
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
A Ruby client for Kubernetes REST api.
|
4
4
|
The client supports GET, POST, PUT, DELETE on pods, services and replication controllers.
|
5
5
|
Also, GET and DELETE is supported for nodes.
|
6
|
-
The client currently supports Kubernetes REST api version v1beta1.
|
6
|
+
The client currently supports Kubernetes REST api version v1beta1 and v1beta3.
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
@@ -23,15 +23,13 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
## Usage
|
25
25
|
|
26
|
-
Please note that all the properties in json objects
|
27
|
-
are converted to ruby style in the client (and converted back to k8s side
|
28
|
-
before sent to k8s).
|
29
|
-
So, containerPort on k8s side is container_port in the client.
|
30
|
-
resourceVersion --> resource_version
|
31
|
-
|
32
26
|
Initialize the client: <br>
|
33
27
|
`client = Kubeclient::Client.new 'http://localhost:8080/api/' , "v1beta1"`
|
34
28
|
|
29
|
+
or for the v3:
|
30
|
+
|
31
|
+
`client = Kubeclient::Client.new 'http://localhost:8080/api/' , "v1beta3"`
|
32
|
+
|
35
33
|
Examples:
|
36
34
|
|
37
35
|
1. Get all pods (and respectively: get_services, get_nodes, get_replication_controllers)
|
@@ -53,12 +51,13 @@ Input parameter - id (string) specifying service id, pod id, replication control
|
|
53
51
|
<br>
|
54
52
|
|
55
53
|
4. Create a service (and respectively: create_pod pod_object, create_replication_controller rc_obj) <br>
|
56
|
-
Input parameter - object of type Service, Pod, ReplicationController
|
54
|
+
Input parameter - object of type Service, Pod, ReplicationController. <br>
|
55
|
+
The below example is for v1beta1
|
57
56
|
<br>
|
58
57
|
`service = Service.new` <br>
|
59
58
|
`service.id = "redis-master"`<br>
|
60
59
|
`service.port = 6379`<br>
|
61
|
-
`service.
|
60
|
+
`service.containerPort = "redis-server"`<br>
|
62
61
|
`service.selector = {}`<br>
|
63
62
|
`service.selector.name = "redis"`<br>
|
64
63
|
`service.selector.role = "master"`<br>
|
@@ -67,6 +66,7 @@ Input parameter - object of type Service, Pod, ReplicationController
|
|
67
66
|
|
68
67
|
5. Update entity (update pod, service, replication controller) <br>
|
69
68
|
Input parameter - object of type Service, Pod, ReplicationController <br>
|
69
|
+
The below example is for v1beta1 <br>
|
70
70
|
`client.update_service service1`
|
71
71
|
<br>
|
72
72
|
|
data/lib/kubeclient.rb
CHANGED
@@ -35,6 +35,15 @@ module Kubeclient
|
|
35
35
|
entity.classify.constantize.new(hash)
|
36
36
|
end
|
37
37
|
|
38
|
+
def get_resource_name(entity)
|
39
|
+
if @api_version == "v1beta1"
|
40
|
+
entity_name = entity.pluralize.camelize(:lower)
|
41
|
+
else
|
42
|
+
entity_name = entity.pluralize.downcase
|
43
|
+
end
|
44
|
+
entity_name
|
45
|
+
end
|
46
|
+
|
38
47
|
|
39
48
|
public
|
40
49
|
|
@@ -45,7 +54,7 @@ module Kubeclient
|
|
45
54
|
#todo labels support
|
46
55
|
#todo namespace support?
|
47
56
|
begin
|
48
|
-
response = rest_client[entity
|
57
|
+
response = rest_client[get_resource_name(entity)].get # nil, labels
|
49
58
|
rescue RestClient::Exception => e
|
50
59
|
exception = KubeException.new(e.http_code, JSON.parse(e.response)['message'] )
|
51
60
|
raise exception
|
@@ -59,7 +68,7 @@ module Kubeclient
|
|
59
68
|
#get a single entity of a specific type by id
|
60
69
|
define_method("get_#{entity.underscore}") do |id|
|
61
70
|
begin
|
62
|
-
response = rest_client[entity
|
71
|
+
response = rest_client[get_resource_name(entity)+"/#{id}"].get
|
63
72
|
rescue RestClient::Exception => e
|
64
73
|
exception = KubeException.new(e.http_code, JSON.parse(e.response)['message'] )
|
65
74
|
raise exception
|
@@ -70,7 +79,7 @@ module Kubeclient
|
|
70
79
|
|
71
80
|
define_method("delete_#{entity.underscore}") do |id|
|
72
81
|
begin
|
73
|
-
rest_client[entity
|
82
|
+
rest_client[get_resource_name(entity)+"/" +id].delete
|
74
83
|
rescue RestClient::Exception => e
|
75
84
|
exception = KubeException.new(e.http_code, JSON.parse(e.response)['message'] )
|
76
85
|
raise exception
|
@@ -82,7 +91,7 @@ module Kubeclient
|
|
82
91
|
#to_hash should be called because of issue #9 in recursive open struct
|
83
92
|
hash = entity_config.to_hash
|
84
93
|
begin
|
85
|
-
rest_client[entity
|
94
|
+
rest_client[get_resource_name(entity)].post(hash.to_json)
|
86
95
|
rescue RestClient::Exception => e
|
87
96
|
exception = KubeException.new(e.http_code, JSON.parse(e.response)['message'] )
|
88
97
|
raise exception
|
@@ -96,7 +105,7 @@ module Kubeclient
|
|
96
105
|
#temporary solution to delete id till this issue is solved: https://github.com/GoogleCloudPlatform/kubernetes/issues/3085
|
97
106
|
hash.delete(:id)
|
98
107
|
begin
|
99
|
-
rest_client[entity
|
108
|
+
rest_client[get_resource_name(entity)+"/#{id}"].put(hash.to_json)
|
100
109
|
rescue RestClient::Exception => e
|
101
110
|
exception = KubeException.new(e.http_code, JSON.parse(e.response)['message'] )
|
102
111
|
raise exception
|
data/lib/kubeclient/version.rb
CHANGED
data/test/node_test.rb
CHANGED
@@ -5,7 +5,7 @@ require 'json'
|
|
5
5
|
require './lib/kubeclient'
|
6
6
|
|
7
7
|
class NodeTest < MiniTest::Test
|
8
|
-
def
|
8
|
+
def test_get_from_json_v1
|
9
9
|
json_response = "{\n \"kind\": \"Node\",\n \"id\": \"127.0.0.1\",\n \"uid\": \"b0ddfa00-8b5b-11e4-a8c4-3c970e4a436a\",\n \"creationTimestamp\": \"2014-12-24T12:57:45+02:00\",\n \"selfLink\": \"/api/v1beta1/nodes/127.0.0.1\",\n \"resourceVersion\": 7,\n \"apiVersion\": \"v1beta1\",\n \"resources\": {\n \"capacity\": {\n \"cpu\": 1000,\n \"memory\": 3221225472\n }\n }\n}"
|
10
10
|
|
11
11
|
stub_request(:get, /.*nodes*/).
|
@@ -15,7 +15,6 @@ class NodeTest < MiniTest::Test
|
|
15
15
|
node = client.get_node "127.0.0.1"
|
16
16
|
|
17
17
|
assert_instance_of(Node,node)
|
18
|
-
#checking that creationTimestamp was renamed properly
|
19
18
|
assert_respond_to(node, "creationTimestamp")
|
20
19
|
assert_respond_to(node, "uid")
|
21
20
|
assert_respond_to(node, "id")
|
@@ -27,4 +26,23 @@ class NodeTest < MiniTest::Test
|
|
27
26
|
assert_equal 1000, node.resources.capacity.cpu
|
28
27
|
end
|
29
28
|
|
29
|
+
def test_get_from_json_v3
|
30
|
+
json_response = "{\n \"kind\": \"Node\",\n \"apiVersion\": \"v1beta3\",\n \"metadata\": {\n \"name\": \"127.0.0.1\",\n \"selfLink\": \"/api/v1beta3/nodes/127.0.0.1\",\n \"uid\": \"01018013-a231-11e4-a36b-3c970e4a436a\",\n \"resourceVersion\": \"7\",\n \"creationTimestamp\": \"2015-01-22T14:20:08+02:00\"\n },\n \"spec\": {\n \"capacity\": {\n \"cpu\": \"1\",\n \"memory\": \"3Gi\"\n }\n },\n \"status\": {\n \"hostIP\": \"127.0.0.1\",\n \"conditions\": [\n {\n \"kind\": \"Ready\",\n \"status\": \"Full\",\n \"lastTransitionTime\": null\n }\n ]\n }\n}"
|
31
|
+
|
32
|
+
stub_request(:get, /.*nodes*/).
|
33
|
+
to_return(:body => json_response, :status => 200)
|
34
|
+
|
35
|
+
client = Kubeclient::Client.new 'http://localhost:8080/api/' , "v1beta3"
|
36
|
+
node = client.get_node "127.0.0.1"
|
37
|
+
|
38
|
+
assert_instance_of(Node,node)
|
39
|
+
|
40
|
+
assert_equal("01018013-a231-11e4-a36b-3c970e4a436a", node.metadata.uid)
|
41
|
+
assert_equal("127.0.0.1", node.metadata.name)
|
42
|
+
assert_equal("7", node.metadata.resourceVersion)
|
43
|
+
assert_equal("v1beta3", node.apiVersion)
|
44
|
+
assert_equal("2015-01-22T14:20:08+02:00", node.metadata.creationTimestamp)
|
45
|
+
|
46
|
+
end
|
47
|
+
|
30
48
|
end
|
data/test/pod_test.rb
CHANGED
@@ -6,7 +6,7 @@ require './lib/kubeclient'
|
|
6
6
|
|
7
7
|
class PodTest < MiniTest::Test
|
8
8
|
|
9
|
-
def
|
9
|
+
def test_get_from_json_v1
|
10
10
|
json_response = " { \"apiVersion\": \"v1beta1\",\n \"kind\": \"Pod\", \n \"id\": \"redis-master-pod\", \n \"desiredState\": { \"manifest\": { \"version\": \"v1beta1\", \"id\": \"redis-master-pod\", \n
|
11
11
|
\"containers\": [{ \"name\": \"redis-master\", \"image\": \"gurpartap/redis\", \"ports\": [{ \"name\": \"redis-server\", \"containerPort\": 6379 }] }] } }, \"labels\": { \"name\": \"redis\", \"role\": \"master\" } }"
|
12
12
|
|
@@ -21,4 +21,20 @@ class PodTest < MiniTest::Test
|
|
21
21
|
assert_equal("redis-master",pod.desiredState.manifest.containers[0]['name'])
|
22
22
|
end
|
23
23
|
|
24
|
+
def test_get_from_json_v3
|
25
|
+
json_response = "{\n \"kind\": \"Pod\",\n \"apiVersion\": \"v1beta3\",\n \"metadata\": {\n \"name\": \"redis-master3\",\n \"namespace\": \"default\",\n \"selfLink\": \"/api/v1beta3/pods/redis-master3?namespace=default\",\n \"uid\": \"a344023f-a23c-11e4-a36b-3c970e4a436a\",\n \"resourceVersion\": \"9\",\n \"creationTimestamp\": \"2015-01-22T15:43:24+02:00\",\n \"labels\": {\n \"name\": \"redis-master\"\n }\n },\n \"spec\": {\n \"volumes\": null,\n \"containers\": [\n {\n \"name\": \"master\",\n \"image\": \"dockerfile/redis\",\n \"ports\": [\n {\n \"hostPort\": 6379,\n \"containerPort\": 6379,\n \"protocol\": \"TCP\"\n }\n ],\n \"memory\": \"0\",\n \"cpu\": \"100m\",\n \"imagePullPolicy\": \"\"\n },\n {\n \"name\": \"php-redis\",\n \"image\": \"kubernetes/example-guestbook-php-redis\",\n \"ports\": [\n {\n \"hostPort\": 8000,\n \"containerPort\": 80,\n \"protocol\": \"TCP\"\n }\n ],\n \"memory\": \"50000000\",\n \"cpu\": \"100m\",\n \"imagePullPolicy\": \"\"\n }\n ],\n \"restartPolicy\": {\n \"always\": {}\n },\n \"dnsPolicy\": \"ClusterFirst\"\n },\n \"status\": {\n \"phase\": \"Running\",\n \"host\": \"127.0.0.1\",\n \"podIP\": \"172.17.0.2\",\n \"info\": {\n \"master\": {\n \"state\": {\n \"running\": {\n \"startedAt\": \"2015-01-22T13:43:29Z\"\n }\n },
|
26
|
+
\n \"restartCount\": 0,\n \"containerID\": \"docker://87458d9a12f9dc9a01b52c1eee5f09cf48939380271c0eaf31af298ce67b125e\",\n \"image\": \"dockerfile/redis\"\n },\n \"net\": {\n \"state\": {\n \"running\": {\n \"startedAt\": \"2015-01-22T13:43:27Z\"\n }\n },\n \"restartCount\": 0,\n \"containerID\": \"docker://3bb5ced1f831322d370f70b58137e1dd41216c2960b7a99394542b5230cbd259\",\n \"podIP\": \"172.17.0.2\",\n \"image\": \"kubernetes/pause:latest\"\n },\n \"php-redis\": {\n \"state\": {\n \"running\": {\n \"startedAt\": \"2015-01-22T13:43:31Z\"\n }\n },\n \"restartCount\": 0,\n \"containerID\": \"docker://5f08685c0a7a5c974d438a52c6560d72bb0aae7e805d2a34302b9b460f1297c7\",\n \"image\": \"kubernetes/example-guestbook-php-redis\"\n }\n }\n }\n}"
|
27
|
+
|
28
|
+
stub_request(:get, /.*pods*/).
|
29
|
+
to_return(:body => json_response, :status => 200)
|
30
|
+
|
31
|
+
client = Kubeclient::Client.new 'http://localhost:8080/api/' , "v1beta3"
|
32
|
+
pod = client.get_pod "redis-master-pod"
|
33
|
+
|
34
|
+
assert_instance_of(Pod,pod)
|
35
|
+
assert_equal("redis-master3",pod.metadata.name)
|
36
|
+
assert_equal("dockerfile/redis",pod.spec.containers[0]["image"])
|
37
|
+
|
38
|
+
end
|
39
|
+
|
24
40
|
end
|
@@ -6,7 +6,7 @@ require 'json'
|
|
6
6
|
|
7
7
|
class ReplicationControllerTest < MiniTest::Test
|
8
8
|
|
9
|
-
def
|
9
|
+
def test_get_from_json_v1
|
10
10
|
json_response = "{\n \"kind\": \"ReplicationController\",\n \"id\": \"frontendController\",\n \"uid\": \"f4e5966c-8eb2-11e4-a6e7-3c970e4a436a\",\n \"creationTimestamp\": \"2014-12-28T18:59:59+02:00\",\n \"selfLink\": \"/api/v1beta1/replicationControllers/frontendController?namespace=default\",\n \"resourceVersion\": 11,\n \"apiVersion\": \"v1beta1\",\n \"namespace\": \"default\",\n \"desiredState\": {\n \"replicas\": 3,\n \"replicaSelector\": {\n \"name\": \"frontend\"\n },\n \"podTemplate\": {\n \"desiredState\": {\n \"manifest\": {\n \"version\": \"v1beta2\",\n \"id\": \"\",\n \"volumes\": null,\n \"containers\": [\n {\n \"name\": \"php-redis\",\n \"image\": \"brendanburns/php-redis\",\n \"ports\": [\n {\n \"hostPort\": 8000,\n \"containerPort\": 80,\n \"protocol\": \"TCP\"\n }\n ],\n \"imagePullPolicy\": \"\"\n }\n ],\n \"restartPolicy\": {\n \"always\": {}\n }\n }\n },\n \"labels\": {\n \"name\": \"frontend\"\n }\n }\n },\n \"currentState\": {\n \"replicas\": 3,\n \"podTemplate\": {\n \"desiredState\": {\n \"manifest\": {\n \"version\": \"\",\n \"id\": \"\",\n \"volumes\": null,\n \"containers\": null,\n \"restartPolicy\": {}\n }\n }\n }\n },\n \"labels\": {\n \"name\": \"frontend\"\n }\n}"
|
11
11
|
stub_request(:get, /.*replicationControllers*/).
|
12
12
|
to_return(:body => json_response, :status => 200)
|
@@ -24,4 +24,22 @@ class ReplicationControllerTest < MiniTest::Test
|
|
24
24
|
#hence it can significantly impact the design of the client. to be revisited after beta v3 api is released.
|
25
25
|
assert_equal("php-redis",rc.desiredState.podTemplate.desiredState.manifest.containers[0]['name'])
|
26
26
|
end
|
27
|
+
|
28
|
+
def test_get_from_json_v3
|
29
|
+
json_response = "{\n \"kind\": \"ReplicationController\",\n \"apiVersion\": \"v1beta3\",\n \"metadata\": {\n \"name\": \"guestbook-controller\",\n \"namespace\": \"default\",\n \"selfLink\": \"/api/v1beta3/replicationcontrollers/guestbook-controller?namespace=default\",\n \"uid\": \"c71aa4c0-a240-11e4-a265-3c970e4a436a\",\n \"resourceVersion\": \"8\",\n \"creationTimestamp\": \"2015-01-22T16:13:02+02:00\",\n \"labels\": {\n \"name\": \"guestbook\"\n }\n },\n \"spec\": {\n \"replicas\": 3,\n \"selector\": {\n \"name\": \"guestbook\"\n },\n \"template\": {\n \"metadata\": {\n \"creationTimestamp\": null,\n \"labels\": {\n \"name\": \"guestbook\"\n }\n },\n \"spec\": {\n \"volumes\": null,\n \"containers\": [\n {\n \"name\": \"guestbook\",\n \"image\": \"kubernetes/guestbook\",\n \"ports\": [\n {\n \"name\": \"http-server\",\n \"containerPort\": 3000,\n \"protocol\": \"TCP\"\n }\n ],\n \"memory\": \"0\",\n \"cpu\": \"0m\",\n \"imagePullPolicy\": \"\"\n }\n ],\n \"restartPolicy\": {\n \"always\": {}\n },\n \"dnsPolicy\": \"ClusterFirst\"\n }\n }\n },\n \"status\": {\n \"replicas\": 3\n }\n}"
|
30
|
+
|
31
|
+
stub_request(:get, /.*replicationcontrollers*/).
|
32
|
+
to_return(:body => json_response, :status => 200)
|
33
|
+
|
34
|
+
client = Kubeclient::Client.new 'http://localhost:8080/api/' , "v1beta3"
|
35
|
+
rc = client.get_replication_controller "frontendController"
|
36
|
+
|
37
|
+
assert_instance_of(ReplicationController,rc)
|
38
|
+
assert_equal("guestbook-controller",rc.metadata.name)
|
39
|
+
assert_equal("c71aa4c0-a240-11e4-a265-3c970e4a436a",rc.metadata.uid)
|
40
|
+
assert_equal("default",rc.metadata.namespace)
|
41
|
+
assert_equal(3,rc.spec.replicas)
|
42
|
+
assert_equal("guestbook",rc.spec.selector.name)
|
43
|
+
end
|
44
|
+
|
27
45
|
end
|
data/test/service_test.rb
CHANGED
@@ -5,8 +5,7 @@ require 'json'
|
|
5
5
|
require './lib/kubeclient'
|
6
6
|
|
7
7
|
class ServiceTest < MiniTest::Test
|
8
|
-
def
|
9
|
-
# creation of the entity from json as if it was read from the server REST api
|
8
|
+
def test_get_from_json_v1
|
10
9
|
mock = Service.new({"kind"=>"Service", "id"=>"redis-service", "uid"=>"fb01a69c-8ae2-11e4-acc5-3c970e4a436a", "namespace"=>"default", "port"=>80, "protocol"=>"TCP", "labels"=>{"component"=>"apiserver", "provider"=>"kubernetes"}, "selector"=>nil, "creation_timestamp"=>"2014-12-23T22:33:40+02:00", "self_link"=>"/api/v1beta1/services/kubernetes-ro?namespace=default", "resource_version"=>4, "api_version"=>"v1beta1", "container_port"=>0, "portal_ip"=>"10.0.0.54"})
|
11
10
|
|
12
11
|
assert_equal 'redis-service', mock.id
|
@@ -31,7 +30,7 @@ class ServiceTest < MiniTest::Test
|
|
31
30
|
end
|
32
31
|
|
33
32
|
|
34
|
-
def
|
33
|
+
def test_conversion_from_json_v1
|
35
34
|
json_response = "{\n \"kind\": \"Service\",\n \"id\": \"redisslave\",\n \"uid\": \"6a022e83-8ea7-11e4-a6e7-3c970e4a436a\",\n \"creationTimestamp\": \"2014-12-28T17:37:21+02:00\",\n \"selfLink\": \"/api/v1beta1/services/redisslave?namespace=default\",\n \"resourceVersion\": 8,\n \"apiVersion\": \"v1beta1\",\n \"namespace\": \"default\",\n \"port\": 10001,\n \"protocol\": \"TCP\",\n \"labels\": {\n \"name\": \"redisslave\"\n },\n \"selector\": {\n \"name\": \"redisslave\"\n },\n \"containerPort\": 6379,\n \"portalIP\": \"10.0.0.248\"\n}"
|
36
35
|
|
37
36
|
stub_request(:get, /.*services*/).
|
@@ -55,6 +54,31 @@ class ServiceTest < MiniTest::Test
|
|
55
54
|
|
56
55
|
end
|
57
56
|
|
57
|
+
def test_conversion_from_json_v3
|
58
|
+
json_response = "{\n \"kind\": \"Service\",\n \"apiVersion\": \"v1beta3\",\n \"metadata\": {\n \"name\": \"kubernetes-ro\",\n \"namespace\": \"default\",\n \"selfLink\": \"/api/v1beta3/services/kubernetes-ro?namespace=default\",\n \"uid\": \"ffb153db-a230-11e4-a36b-3c970e4a436a\",\n \"resourceVersion\": \"4\",\n \"creationTimestamp\": \"2015-01-22T14:20:05+02:00\",\n \"labels\": {\n \"component\": \"apiserver\",\n \"provider\": \"kubernetes\"\n }\n },\n \"spec\": {\n \"port\": 80,\n \"protocol\": \"TCP\",\n \"selector\": null,\n \"portalIP\": \"10.0.0.154\",\n \"containerPort\": 0,\n \"sessionAffinity\": \"None\"\n },\n \"status\": {}\n}"
|
59
|
+
|
60
|
+
|
61
|
+
stub_request(:get, /.*services*/).
|
62
|
+
to_return(:body => json_response, :status => 200)
|
63
|
+
|
64
|
+
client = Kubeclient::Client.new 'http://localhost:8080/api/' , "v1beta3"
|
65
|
+
service = client.get_service "redisslave"
|
66
|
+
|
67
|
+
assert_instance_of(Service,service)
|
68
|
+
#checking that creationTimestamp was renamed properly
|
69
|
+
assert_equal("2015-01-22T14:20:05+02:00",service.metadata.creationTimestamp)
|
70
|
+
assert_equal("ffb153db-a230-11e4-a36b-3c970e4a436a",service.metadata.uid)
|
71
|
+
assert_equal("kubernetes-ro",service.metadata.name)
|
72
|
+
assert_equal("4",service.metadata.resourceVersion)
|
73
|
+
assert_equal("v1beta3",service.apiVersion)
|
74
|
+
assert_equal("10.0.0.154",service.spec.portalIP)
|
75
|
+
assert_equal(0,service.spec.containerPort)
|
76
|
+
assert_equal("TCP",service.spec.protocol)
|
77
|
+
assert_equal(80,service.spec.port)
|
78
|
+
assert_equal("default",service.metadata.namespace)
|
79
|
+
|
80
|
+
end
|
81
|
+
|
58
82
|
def test_delete_service
|
59
83
|
our_service = Service.new
|
60
84
|
our_service.id = 'redis-service'
|