ruby-kubernetes-controller 0.2.3 → 0.2.4
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 367cf0c821db043996230dbbd4f934616906dd8630874807c8e45000d777c640
|
4
|
+
data.tar.gz: 40e5fae6ed73fedc968ade455f1a284fff4fff7fcb30cc846ea7781674ee5bc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f7bada708d34d21ba9a120ab9d58fbce8d68ce40232af815cf38b6d2d6485561680e8e03c2123d087c1436d7d3bf20000d510bea66eef396c51975287a79c7c
|
7
|
+
data.tar.gz: 31f582542b7a6e7d0a15196c254aca87b69411c740b1f812d3fed3f7d50b1b55ec3ed85e0be4d590eeddd000002b6530c4c177cb65fc1c0a90cd5d8019c1ad76
|
@@ -543,6 +543,38 @@ Before beginning, you must generate a bearer token for the Ruby Kubernetes Contr
|
|
543
543
|
puts client.get_all_namespaced_pods(namespace) # Returns JSON
|
544
544
|
```
|
545
545
|
|
546
|
+
#### Get Namespaced Pods With Field Selector
|
547
|
+
* List all existing Pods in Namespace that have a specific field selector
|
548
|
+
```ruby
|
549
|
+
require 'ruby-kubernetes-controller'
|
550
|
+
|
551
|
+
pod = "localhost"
|
552
|
+
bearer_token = "token"
|
553
|
+
ssl = false
|
554
|
+
|
555
|
+
client = ::RubyKubernetesController::Client.new(pod, bearer_token, ssl)
|
556
|
+
|
557
|
+
namespace = "default"
|
558
|
+
|
559
|
+
puts client.get_all_namespaced_pods_with_field_selector(namespace, field_selector) # Returns JSON
|
560
|
+
```
|
561
|
+
|
562
|
+
#### Get Namespaced Pods With Label Selector
|
563
|
+
* List all existing Pods in Namespace that have a specific label selector
|
564
|
+
```ruby
|
565
|
+
require 'ruby-kubernetes-controller'
|
566
|
+
|
567
|
+
pod = "localhost"
|
568
|
+
bearer_token = "token"
|
569
|
+
ssl = false
|
570
|
+
|
571
|
+
client = ::RubyKubernetesController::Client.new(pod, bearer_token, ssl)
|
572
|
+
|
573
|
+
namespace = "default"
|
574
|
+
|
575
|
+
puts client.get_all_namespaced_pods_with_label_selector(namespace, label_selector) # Returns JSON
|
576
|
+
```
|
577
|
+
|
546
578
|
#### Get Single Namespaced Pod
|
547
579
|
* Get details for single Pod in Namespace
|
548
580
|
```ruby
|
@@ -11,6 +11,14 @@ module Generic
|
|
11
11
|
URI.parse("https://#{endpoint}#{extension}")
|
12
12
|
end
|
13
13
|
|
14
|
+
# Create a URI Object with params
|
15
|
+
def prepareURIWithParams(endpoint, extension, params)
|
16
|
+
uri = URI.parse("https://#{endpoint}#{extension}")
|
17
|
+
uri.query = URI.encode_www_form(params)
|
18
|
+
|
19
|
+
uri
|
20
|
+
end
|
21
|
+
|
14
22
|
# Prepare a Generic Request Object
|
15
23
|
def prepareGenericRequest(uri, bearer_token, type)
|
16
24
|
if type == "GET"
|
@@ -78,6 +78,54 @@ module Pods
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
+
# Get all existing Pods in Namespace with field selector
|
82
|
+
def get_all_namespaced_pods_with_field_selector(namespace, selector)
|
83
|
+
extension = "/api/v1/namespaces/#{namespace}/pods"
|
84
|
+
|
85
|
+
params = { :fieldSelector => "#{selector}" }
|
86
|
+
|
87
|
+
uri = prepareURIWithParams(@endpoint, extension, params)
|
88
|
+
|
89
|
+
puts(uri)
|
90
|
+
|
91
|
+
request = prepareGenericRequest(uri, @bearer_token, "GET")
|
92
|
+
|
93
|
+
req_options = prepareGenericRequestOptions(@ssl, uri)
|
94
|
+
|
95
|
+
begin
|
96
|
+
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
97
|
+
http.request(request)
|
98
|
+
end
|
99
|
+
return response.body
|
100
|
+
|
101
|
+
rescue Errno::ECONNREFUSED
|
102
|
+
raise "Connection for host #{uri.hostname} refused"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# Get all existing Pods in Namespace with label selector
|
107
|
+
def get_all_namespaced_pods_with_label_selector(namespace, selector)
|
108
|
+
extension = "/api/v1/namespaces/#{namespace}/pods"
|
109
|
+
|
110
|
+
params = { :labelSelector => "#{selector}" }
|
111
|
+
|
112
|
+
uri = prepareURIWithParams(@endpoint, extension, params)
|
113
|
+
|
114
|
+
request = prepareGenericRequest(uri, @bearer_token, "GET")
|
115
|
+
|
116
|
+
req_options = prepareGenericRequestOptions(@ssl, uri)
|
117
|
+
|
118
|
+
begin
|
119
|
+
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
120
|
+
http.request(request)
|
121
|
+
end
|
122
|
+
return response.body
|
123
|
+
|
124
|
+
rescue Errno::ECONNREFUSED
|
125
|
+
raise "Connection for host #{uri.hostname} refused"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
81
129
|
# Get single Pod in Namespace
|
82
130
|
def get_single_namespaced_pod(namespace, pod_name)
|
83
131
|
extension = "/api/v1/namespaces/#{namespace}/pods/#{pod_name}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-kubernetes-controller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shivansh Vij (ShivanshVij)
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-07-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|