Module: Pods
- Includes:
- Generic
- Included in:
- RubyKubernetesController::Client, Utilities
- Defined in:
- lib/ruby-kubernetes-controller/pods.rb
Instance Method Summary collapse
-
#create_new_pod(namespace, config) ⇒ Object
Create new Pod.
-
#delete_pod(namespace, pod_name, options = '') ⇒ Object
Delete existing Pod.
-
#get_all_namespaced_pods(namespace) ⇒ Object
Get all existing Pods in Namespace.
-
#get_all_namespaced_pods_with_field_selector(namespace, selector) ⇒ Object
Get all existing Pods in Namespace with field selector.
-
#get_all_namespaced_pods_with_label_selector(namespace, selector) ⇒ Object
Get all existing Pods in Namespace with label selector.
-
#get_all_pods ⇒ Object
Get all Pods.
-
#get_single_namespaced_pod(namespace, pod_name) ⇒ Object
Get single Pod in Namespace.
-
#patch_pod(namespace, pod_name, patch) ⇒ Object
Patch existing Pod.
-
#update_namespaced_pod(namespace, pod_name, update) ⇒ Object
Update existing Pod in Namespace.
Methods included from Generic
#check_valid_json, #prepareGenericRequest, #prepareGenericRequestOptions, #prepareURI, #prepareURIWithParams, #yaml_file_to_json
Instance Method Details
#create_new_pod(namespace, config) ⇒ Object
Create new Pod
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ruby-kubernetes-controller/pods.rb', line 12 def create_new_pod(namespace, config) extension = "/api/v1/namespaces/#{namespace}/pods" uri = prepareURI(@endpoint, extension) request = prepareGenericRequest(uri, @bearer_token, "POST") request.content_type = "application/json" if @yaml request.body = yaml_file_to_json(config) else request.body = config end = prepareGenericRequestOptions(@ssl, uri) begin response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end return response.body rescue Errno::ECONNREFUSED raise "Connection for host #{uri.hostname} refused" end end |
#delete_pod(namespace, pod_name, options = '') ⇒ Object
Delete existing Pod
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/ruby-kubernetes-controller/pods.rb', line 201 def delete_pod(namespace, pod_name, = '') extension = "/api/v1/namespaces/#{namespace}/pods/#{pod_name}" uri = prepareURI(@endpoint, extension) request = prepareGenericRequest(uri, @bearer_token, "DELETE") request.content_type = "application/json" if @yaml request.body = yaml_file_to_json() else request.body = end = prepareGenericRequestOptions(@ssl, uri) begin response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end return response.body rescue Errno::ECONNREFUSED raise "Connection for host #{uri.hostname} refused" end end |
#get_all_namespaced_pods(namespace) ⇒ Object
Get all existing Pods in Namespace
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/ruby-kubernetes-controller/pods.rb', line 61 def get_all_namespaced_pods(namespace) extension = "/api/v1/namespaces/#{namespace}/pods" uri = prepareURI(@endpoint, extension) request = prepareGenericRequest(uri, @bearer_token, "GET") = prepareGenericRequestOptions(@ssl, uri) begin response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end return response.body rescue Errno::ECONNREFUSED raise "Connection for host #{uri.hostname} refused" end end |
#get_all_namespaced_pods_with_field_selector(namespace, selector) ⇒ Object
Get all existing Pods in Namespace with field selector
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/ruby-kubernetes-controller/pods.rb', line 82 def get_all_namespaced_pods_with_field_selector(namespace, selector) extension = "/api/v1/namespaces/#{namespace}/pods" params = { :fieldSelector => "#{selector}" } uri = prepareURIWithParams(@endpoint, extension, params) puts(uri) request = prepareGenericRequest(uri, @bearer_token, "GET") = prepareGenericRequestOptions(@ssl, uri) begin response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end return response.body rescue Errno::ECONNREFUSED raise "Connection for host #{uri.hostname} refused" end end |
#get_all_namespaced_pods_with_label_selector(namespace, selector) ⇒ Object
Get all existing Pods in Namespace with label selector
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/ruby-kubernetes-controller/pods.rb', line 107 def get_all_namespaced_pods_with_label_selector(namespace, selector) extension = "/api/v1/namespaces/#{namespace}/pods" params = { :labelSelector => "#{selector}" } uri = prepareURIWithParams(@endpoint, extension, params) request = prepareGenericRequest(uri, @bearer_token, "GET") = prepareGenericRequestOptions(@ssl, uri) begin response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end return response.body rescue Errno::ECONNREFUSED raise "Connection for host #{uri.hostname} refused" end end |
#get_all_pods ⇒ Object
Get all Pods
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ruby-kubernetes-controller/pods.rb', line 40 def get_all_pods extension = "/api/v1/pods" uri = prepareURI(@endpoint, extension) request = prepareGenericRequest(uri, @bearer_token, "GET") = prepareGenericRequestOptions(@ssl, uri) begin response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end return response.body rescue Errno::ECONNREFUSED raise "Connection for host #{uri.hostname} refused" end end |
#get_single_namespaced_pod(namespace, pod_name) ⇒ Object
Get single Pod in Namespace
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/ruby-kubernetes-controller/pods.rb', line 130 def get_single_namespaced_pod(namespace, pod_name) extension = "/api/v1/namespaces/#{namespace}/pods/#{pod_name}" uri = prepareURI(@endpoint, extension) request = prepareGenericRequest(uri, @bearer_token, "GET") = prepareGenericRequestOptions(@ssl, uri) begin response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end return response.body rescue Errno::ECONNREFUSED raise "Connection for host #{uri.hostname} refused" end end |
#patch_pod(namespace, pod_name, patch) ⇒ Object
Patch existing Pod
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/ruby-kubernetes-controller/pods.rb', line 178 def patch_pod(namespace, pod_name, patch) extension = "/api/v1/namespaces/#{namespace}/pods/#{pod_name}" uri = prepareURI(@endpoint, extension) request = prepareGenericRequest(uri, @bearer_token, "PATCH") request.content_type = "application/json-patch+json" request.body = patch = prepareGenericRequestOptions(@ssl, uri) begin response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end return response.body rescue Errno::ECONNREFUSED raise "Connection for host #{uri.hostname} refused" end end |
#update_namespaced_pod(namespace, pod_name, update) ⇒ Object
Update existing Pod in Namespace
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/ruby-kubernetes-controller/pods.rb', line 150 def update_namespaced_pod(namespace, pod_name, update) extension = "/api/v1/namespaces/#{namespace}/pods/#{pod_name}" uri = prepareURI(@endpoint, extension) request = prepareGenericRequest(uri, @bearer_token, "PUT") request.content_type = "application/json" if @yaml request.body = yaml_file_to_json(update) else request.body = update end = prepareGenericRequestOptions(@ssl, uri) begin response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end return response.body rescue Errno::ECONNREFUSED raise "Connection for host #{uri.hostname} refused" end end |