kubeclient 4.9.1 → 4.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/actions.yml +43 -0
- data/CHANGELOG.md +65 -0
- data/README.md +6 -0
- data/kubeclient.gemspec +7 -3
- data/lib/kubeclient/common.rb +31 -19
- data/lib/kubeclient/config.rb +22 -10
- data/lib/kubeclient/version.rb +1 -1
- data/lib/kubeclient/watch_stream.rb +1 -0
- metadata +40 -218
- data/.travis.yml +0 -29
- data/test/cassettes/kubernetes_guestbook.yml +0 -879
- data/test/config/allinone.kubeconfig +0 -20
- data/test/config/execauth.kubeconfig +0 -62
- data/test/config/external-ca.pem +0 -18
- data/test/config/external-cert.pem +0 -19
- data/test/config/external-key.rsa +0 -27
- data/test/config/external.kubeconfig +0 -20
- data/test/config/gcpauth.kubeconfig +0 -22
- data/test/config/gcpcmdauth.kubeconfig +0 -26
- data/test/config/nouser.kubeconfig +0 -16
- data/test/config/oidcauth.kubeconfig +0 -25
- data/test/config/timestamps.kubeconfig +0 -25
- data/test/config/userauth.kubeconfig +0 -28
- data/test/json/bindings_list.json +0 -10
- data/test/json/component_status.json +0 -17
- data/test/json/component_status_list.json +0 -52
- data/test/json/config.istio.io_api_resource_list.json +0 -679
- data/test/json/config_map_list.json +0 -9
- data/test/json/core_api_resource_list.json +0 -181
- data/test/json/core_api_resource_list_without_kind.json +0 -129
- data/test/json/core_oapi_resource_list_without_kind.json +0 -197
- data/test/json/created_endpoint.json +0 -28
- data/test/json/created_namespace.json +0 -20
- data/test/json/created_secret.json +0 -16
- data/test/json/created_security_context_constraint.json +0 -65
- data/test/json/created_service.json +0 -31
- data/test/json/empty_pod_list.json +0 -9
- data/test/json/endpoint_list.json +0 -48
- data/test/json/entity_list.json +0 -56
- data/test/json/event_list.json +0 -35
- data/test/json/extensions_v1beta1_api_resource_list.json +0 -217
- data/test/json/limit_range.json +0 -23
- data/test/json/limit_range_list.json +0 -31
- data/test/json/namespace.json +0 -13
- data/test/json/namespace_exception.json +0 -8
- data/test/json/namespace_list.json +0 -32
- data/test/json/node.json +0 -29
- data/test/json/node_list.json +0 -37
- data/test/json/node_notice.json +0 -160
- data/test/json/persistent_volume.json +0 -37
- data/test/json/persistent_volume_claim.json +0 -32
- data/test/json/persistent_volume_claim_list.json +0 -40
- data/test/json/persistent_volume_claims_nil_items.json +0 -8
- data/test/json/persistent_volume_list.json +0 -45
- data/test/json/pod.json +0 -92
- data/test/json/pod_list.json +0 -79
- data/test/json/pod_template_list.json +0 -9
- data/test/json/pods_1.json +0 -265
- data/test/json/pods_2.json +0 -102
- data/test/json/pods_410.json +0 -9
- data/test/json/processed_template.json +0 -27
- data/test/json/replication_controller.json +0 -57
- data/test/json/replication_controller_list.json +0 -66
- data/test/json/resource_quota.json +0 -46
- data/test/json/resource_quota_list.json +0 -54
- data/test/json/secret_list.json +0 -44
- data/test/json/security.openshift.io_api_resource_list.json +0 -69
- data/test/json/security_context_constraint_list.json +0 -375
- data/test/json/service.json +0 -33
- data/test/json/service_account.json +0 -25
- data/test/json/service_account_list.json +0 -82
- data/test/json/service_illegal_json_404.json +0 -1
- data/test/json/service_json_patch.json +0 -26
- data/test/json/service_list.json +0 -97
- data/test/json/service_merge_patch.json +0 -26
- data/test/json/service_patch.json +0 -25
- data/test/json/service_update.json +0 -22
- data/test/json/template.json +0 -27
- data/test/json/template.openshift.io_api_resource_list.json +0 -75
- data/test/json/template_list.json +0 -35
- data/test/json/versions_list.json +0 -6
- data/test/json/watch_stream.json +0 -3
- data/test/test_common.rb +0 -95
- data/test/test_common_url_handling.rb +0 -160
- data/test/test_component_status.rb +0 -29
- data/test/test_config.rb +0 -222
- data/test/test_endpoint.rb +0 -54
- data/test/test_exec_credentials.rb +0 -225
- data/test/test_gcp_command_credentials.rb +0 -27
- data/test/test_google_application_default_credentials.rb +0 -15
- data/test/test_guestbook_go.rb +0 -235
- data/test/test_helper.rb +0 -18
- data/test/test_kubeclient.rb +0 -881
- data/test/test_limit_range.rb +0 -25
- data/test/test_missing_methods.rb +0 -80
- data/test/test_namespace.rb +0 -59
- data/test/test_node.rb +0 -70
- data/test/test_oidc_auth_provider.rb +0 -103
- data/test/test_persistent_volume.rb +0 -29
- data/test/test_persistent_volume_claim.rb +0 -28
- data/test/test_pod.rb +0 -81
- data/test/test_pod_log.rb +0 -157
- data/test/test_process_template.rb +0 -80
- data/test/test_replication_controller.rb +0 -47
- data/test/test_resource_list_without_kind.rb +0 -78
- data/test/test_resource_quota.rb +0 -23
- data/test/test_secret.rb +0 -62
- data/test/test_security_context_constraint.rb +0 -62
- data/test/test_service.rb +0 -357
- data/test/test_service_account.rb +0 -26
- data/test/test_watch.rb +0 -195
- data/test/txt/pod_log.txt +0 -6
- data/test/valid_token_file +0 -1
data/test/test_guestbook_go.rb
DELETED
@@ -1,235 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
require 'vcr'
|
3
|
-
|
4
|
-
# creation of google's example of guest book
|
5
|
-
class CreateGuestbookGo < MiniTest::Test
|
6
|
-
def test_create_guestbook_entities
|
7
|
-
VCR.configure do |c|
|
8
|
-
c.cassette_library_dir = 'test/cassettes'
|
9
|
-
c.hook_into(:webmock)
|
10
|
-
end
|
11
|
-
|
12
|
-
# WebMock.allow_net_connect!
|
13
|
-
VCR.use_cassette('kubernetes_guestbook') do # , record: :new_episodes) do
|
14
|
-
client = Kubeclient::Client.new('http://10.35.0.23:8080/api/', 'v1')
|
15
|
-
|
16
|
-
testing_ns = Kubeclient::Resource.new
|
17
|
-
testing_ns.metadata = {}
|
18
|
-
testing_ns.metadata.name = 'kubeclient-ns'
|
19
|
-
|
20
|
-
# delete in case they existed before so creation can be tested
|
21
|
-
delete_namespace(client, testing_ns.metadata.name)
|
22
|
-
delete_services(
|
23
|
-
client, testing_ns.metadata.name,
|
24
|
-
['guestbook', 'redis-master', 'redis-slave']
|
25
|
-
)
|
26
|
-
delete_replication_controllers(
|
27
|
-
client, testing_ns.metadata.name,
|
28
|
-
['guestbook', 'redis-master', 'redis-slave']
|
29
|
-
)
|
30
|
-
|
31
|
-
client.create_namespace(testing_ns)
|
32
|
-
services = create_services(client, testing_ns.metadata.name)
|
33
|
-
replicators = create_replication_controllers(client, testing_ns.metadata.name)
|
34
|
-
|
35
|
-
get_namespaces(client)
|
36
|
-
get_services(client, testing_ns.metadata.name)
|
37
|
-
get_replication_controllers(client, testing_ns.metadata.name)
|
38
|
-
|
39
|
-
delete_services(client, testing_ns.metadata.name, services)
|
40
|
-
delete_replication_controllers(client, testing_ns.metadata.name, replicators)
|
41
|
-
|
42
|
-
client.delete_namespace(testing_ns.metadata.name)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def delete_namespace(client, namespace_name)
|
47
|
-
client.delete_namespace(namespace_name)
|
48
|
-
rescue Kubeclient::ResourceNotFoundError => exception
|
49
|
-
assert_equal(404, exception.error_code)
|
50
|
-
end
|
51
|
-
|
52
|
-
def get_namespaces(client)
|
53
|
-
namespaces = client.get_namespaces
|
54
|
-
assert(true, namespaces.size > 2)
|
55
|
-
end
|
56
|
-
|
57
|
-
def get_services(client, ns)
|
58
|
-
retrieved_services = client.get_services(namespace: ns)
|
59
|
-
assert_equal(3, retrieved_services.size)
|
60
|
-
end
|
61
|
-
|
62
|
-
def get_replication_controllers(client, ns)
|
63
|
-
retrieved_replicators = client.get_replication_controllers(namespace: ns)
|
64
|
-
assert_equal(3, retrieved_replicators.size)
|
65
|
-
end
|
66
|
-
|
67
|
-
def create_services(client, ns)
|
68
|
-
guestbook_service = client.create_service(guestbook_service(ns))
|
69
|
-
redis_service = client.create_service(redis_service(ns))
|
70
|
-
redis_slave_service = client.create_service(redis_slave_service(ns))
|
71
|
-
[guestbook_service, redis_service, redis_slave_service]
|
72
|
-
end
|
73
|
-
|
74
|
-
def create_replication_controllers(client, namespace)
|
75
|
-
rc = client.create_replication_controller(guestbook_rc(namespace))
|
76
|
-
rc2 = client.create_replication_controller(redis_master_rc(namespace))
|
77
|
-
rc3 = client.create_replication_controller(redis_slave_rc(namespace))
|
78
|
-
[rc, rc2, rc3]
|
79
|
-
end
|
80
|
-
|
81
|
-
def delete_services(client, namespace, services)
|
82
|
-
# if the entity is not found, no need to fail the test
|
83
|
-
services.each do |service|
|
84
|
-
begin
|
85
|
-
if service.instance_of?(Kubeclient::Resource)
|
86
|
-
client.delete_service(service.metadata.name, namespace)
|
87
|
-
else
|
88
|
-
# it's just a string - service name
|
89
|
-
client.delete_service(service, namespace)
|
90
|
-
end
|
91
|
-
rescue Kubeclient::ResourceNotFoundError => exception
|
92
|
-
assert_equal(404, exception.error_code)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def delete_replication_controllers(client, namespace, replication_controllers)
|
98
|
-
# if the entity is not found, no need to fail the test
|
99
|
-
replication_controllers.each do |rc|
|
100
|
-
begin
|
101
|
-
if rc.instance_of?(Kubeclient::Resource)
|
102
|
-
client.delete_replication_controller(rc.metadata.name, namespace)
|
103
|
-
else
|
104
|
-
# it's just a string - rc name
|
105
|
-
client.delete_replication_controller(rc, namespace)
|
106
|
-
end
|
107
|
-
rescue Kubeclient::ResourceNotFoundError => exception
|
108
|
-
assert_equal(404, exception.error_code)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
private
|
114
|
-
|
115
|
-
def construct_base_rc(namespace)
|
116
|
-
rc = Kubeclient::Resource.new
|
117
|
-
rc.metadata = {}
|
118
|
-
rc.metadata.namespace = namespace
|
119
|
-
rc.metadata.labels = {}
|
120
|
-
rc.spec = {}
|
121
|
-
rc.spec.selector = {}
|
122
|
-
rc.spec.template = {}
|
123
|
-
rc.spec.template.metadata = {}
|
124
|
-
rc.spec.template.spec = {}
|
125
|
-
rc.spec.template.metadata.labels = {}
|
126
|
-
rc
|
127
|
-
end
|
128
|
-
|
129
|
-
def redis_master_rc(namespace)
|
130
|
-
rc = construct_base_rc(namespace)
|
131
|
-
rc.metadata.name = 'redis-master'
|
132
|
-
rc.metadata.labels.app = 'redis'
|
133
|
-
rc.metadata.labels.role = 'master'
|
134
|
-
rc.spec.replicas = 1
|
135
|
-
rc.spec.selector.app = 'redis'
|
136
|
-
rc.spec.selector.role = 'master'
|
137
|
-
rc.spec.template.metadata.labels.app = 'redis'
|
138
|
-
rc.spec.template.metadata.labels.role = 'master'
|
139
|
-
rc.spec.template.spec.containers = [{
|
140
|
-
'name' => 'redis-master',
|
141
|
-
'image' => 'redis',
|
142
|
-
'ports' => [{
|
143
|
-
'name' => 'redis-server',
|
144
|
-
'containerPort' => 6379
|
145
|
-
}]
|
146
|
-
}]
|
147
|
-
rc
|
148
|
-
end
|
149
|
-
|
150
|
-
def redis_slave_rc(namespace)
|
151
|
-
rc = construct_base_rc(namespace)
|
152
|
-
rc.metadata.name = 'redis-slave'
|
153
|
-
rc.metadata.labels.app = 'redis'
|
154
|
-
rc.metadata.labels.role = 'slave'
|
155
|
-
rc.spec.replicas = 2
|
156
|
-
rc.spec.selector.app = 'redis'
|
157
|
-
rc.spec.selector.role = 'slave'
|
158
|
-
rc.spec.template.metadata.labels.app = 'redis'
|
159
|
-
rc.spec.template.metadata.labels.role = 'slave'
|
160
|
-
rc.spec.template.spec.containers = [{
|
161
|
-
'name' => 'redis-slave',
|
162
|
-
'image' => 'kubernetes/redis-slave:v2',
|
163
|
-
'ports' => [{
|
164
|
-
'name' => 'redis-server',
|
165
|
-
'containerPort' => 6379
|
166
|
-
}]
|
167
|
-
}]
|
168
|
-
rc
|
169
|
-
end
|
170
|
-
|
171
|
-
def guestbook_rc(namespace)
|
172
|
-
rc = construct_base_rc(namespace)
|
173
|
-
rc.metadata.name = 'guestbook'
|
174
|
-
rc.metadata.labels.app = 'guestbook'
|
175
|
-
rc.metadata.labels.role = 'slave'
|
176
|
-
rc.spec.replicas = 3
|
177
|
-
rc.spec.selector.app = 'guestbook'
|
178
|
-
rc.spec.template.metadata.labels.app = 'guestbook'
|
179
|
-
rc.spec.template.spec.containers = [
|
180
|
-
{
|
181
|
-
'name' => 'guestbook',
|
182
|
-
'image' => 'kubernetes/guestbook:v2',
|
183
|
-
'ports' => [
|
184
|
-
{
|
185
|
-
'name' => 'http-server',
|
186
|
-
'containerPort' => 3000
|
187
|
-
}
|
188
|
-
]
|
189
|
-
}
|
190
|
-
]
|
191
|
-
rc
|
192
|
-
end
|
193
|
-
|
194
|
-
def base_service(namespace)
|
195
|
-
our_service = Kubeclient::Resource.new
|
196
|
-
our_service.metadata = {}
|
197
|
-
our_service.metadata.namespace = namespace
|
198
|
-
our_service.metadata.labels = {}
|
199
|
-
our_service.spec = {}
|
200
|
-
our_service.spec.selector = {}
|
201
|
-
our_service
|
202
|
-
end
|
203
|
-
|
204
|
-
def redis_slave_service(namespace)
|
205
|
-
our_service = base_service(namespace)
|
206
|
-
our_service.metadata.name = 'redis-slave'
|
207
|
-
our_service.metadata.labels.app = 'redis'
|
208
|
-
our_service.metadata.labels.role = 'slave'
|
209
|
-
our_service.spec.ports = [{ 'port' => 6379, 'targetPort' => 'redis-server' }]
|
210
|
-
our_service.spec.selector.app = 'redis'
|
211
|
-
our_service.spec.selector.role = 'slave'
|
212
|
-
our_service
|
213
|
-
end
|
214
|
-
|
215
|
-
def redis_service(namespace)
|
216
|
-
our_service = base_service(namespace)
|
217
|
-
our_service.metadata.name = 'redis-master'
|
218
|
-
our_service.metadata.labels.app = 'redis'
|
219
|
-
our_service.metadata.labels.role = 'master'
|
220
|
-
our_service.spec.ports = [{ 'port' => 6379, 'targetPort' => 'redis-server' }]
|
221
|
-
our_service.spec.selector.app = 'redis'
|
222
|
-
our_service.spec.selector.role = 'master'
|
223
|
-
our_service
|
224
|
-
end
|
225
|
-
|
226
|
-
def guestbook_service(namespace)
|
227
|
-
our_service = base_service(namespace)
|
228
|
-
our_service.metadata.name = 'guestbook'
|
229
|
-
our_service.metadata.labels.name = 'guestbook'
|
230
|
-
our_service.spec.ports = [{ 'port' => 3000, 'targetPort' => 'http-server' }]
|
231
|
-
our_service.spec.selector.app = 'guestbook'
|
232
|
-
our_service.type = 'LoadBalancer'
|
233
|
-
our_service
|
234
|
-
end
|
235
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
require 'minitest/autorun'
|
3
|
-
require 'minitest/rg'
|
4
|
-
require 'webmock/minitest'
|
5
|
-
require 'mocha/minitest'
|
6
|
-
require 'json'
|
7
|
-
require 'kubeclient'
|
8
|
-
|
9
|
-
# Assumes test files will be in a subdirectory with the same name as the
|
10
|
-
# file suffix. e.g. a file named foo.json would be a "json" subdirectory.
|
11
|
-
def open_test_file(name)
|
12
|
-
File.new(File.join(File.dirname(__FILE__), name.split('.').last, name))
|
13
|
-
end
|
14
|
-
|
15
|
-
def stub_core_api_list
|
16
|
-
stub_request(:get, %r{/api/v1$})
|
17
|
-
.to_return(body: open_test_file('core_api_resource_list.json'), status: 200)
|
18
|
-
end
|