kubeclient 4.0.0 → 4.1.0

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.

Potentially problematic release.


This version of kubeclient might be problematic. Click here for more details.

Files changed (39) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +11 -1
  3. data/README.md +18 -0
  4. data/RELEASING.md +40 -40
  5. data/lib/kubeclient/common.rb +57 -22
  6. data/lib/kubeclient/entity_list.rb +7 -2
  7. data/lib/kubeclient/version.rb +1 -1
  8. data/test/config/allinone.kubeconfig +3 -3
  9. data/test/config/external-ca.pem +14 -14
  10. data/test/config/external-cert.pem +17 -17
  11. data/test/config/external-key.rsa +25 -25
  12. data/test/json/config.istio.io_api_resource_list.json +679 -0
  13. data/test/json/created_security_context_constraint.json +65 -0
  14. data/test/json/pods_1.json +265 -0
  15. data/test/json/pods_2.json +102 -0
  16. data/test/json/pods_410.json +9 -0
  17. data/test/json/security.openshift.io_api_resource_list.json +69 -0
  18. data/test/json/security_context_constraint_list.json +375 -0
  19. data/test/test_common.rb +21 -2
  20. data/test/test_component_status.rb +1 -2
  21. data/test/test_config.rb +4 -4
  22. data/test/test_endpoint.rb +27 -8
  23. data/test/test_helper.rb +5 -0
  24. data/test/test_kubeclient.rb +4 -9
  25. data/test/test_limit_range.rb +1 -3
  26. data/test/test_missing_methods.rb +30 -4
  27. data/test/test_namespace.rb +3 -6
  28. data/test/test_node.rb +2 -4
  29. data/test/test_persistent_volume.rb +1 -2
  30. data/test/test_persistent_volume_claim.rb +1 -3
  31. data/test/test_pod.rb +54 -2
  32. data/test/test_replication_controller.rb +2 -7
  33. data/test/test_resource_quota.rb +1 -3
  34. data/test/test_secret.rb +3 -12
  35. data/test/test_security_context_constraint.rb +62 -0
  36. data/test/test_service.rb +10 -31
  37. data/test/test_service_account.rb +1 -3
  38. data/test/test_watch.rb +7 -16
  39. metadata +19 -3
@@ -0,0 +1,375 @@
1
+ {
2
+ "kind": "SecurityContextConstraintsList",
3
+ "apiVersion": "security.openshift.io/v1",
4
+ "metadata": {
5
+ "selfLink": "/apis/security.openshift.io/v1/securitycontextconstraints",
6
+ "resourceVersion": "5751"
7
+ },
8
+ "items": [
9
+ {
10
+ "metadata": {
11
+ "name": "anyuid",
12
+ "selfLink": "/apis/security.openshift.io/v1/securitycontextconstraints/anyuid",
13
+ "uid": "12ba8540-ef00-11e8-b4c0-68f728fac3ab",
14
+ "resourceVersion": "71",
15
+ "creationTimestamp": "2018-11-23T09:13:42Z",
16
+ "annotations": {
17
+ "kubernetes.io/description": "anyuid provides all features of the restricted SCC but allows users to run with any UID and any GID."
18
+ }
19
+ },
20
+ "priority": 10,
21
+ "allowPrivilegedContainer": false,
22
+ "defaultAddCapabilities": null,
23
+ "requiredDropCapabilities": [
24
+ "MKNOD"
25
+ ],
26
+ "allowedCapabilities": null,
27
+ "allowHostDirVolumePlugin": false,
28
+ "volumes": [
29
+ "configMap",
30
+ "downwardAPI",
31
+ "emptyDir",
32
+ "persistentVolumeClaim",
33
+ "projected",
34
+ "secret"
35
+ ],
36
+ "allowedFlexVolumes": null,
37
+ "allowHostNetwork": false,
38
+ "allowHostPorts": false,
39
+ "allowHostPID": false,
40
+ "allowHostIPC": false,
41
+ "seLinuxContext": {
42
+ "type": "MustRunAs"
43
+ },
44
+ "runAsUser": {
45
+ "type": "RunAsAny"
46
+ },
47
+ "supplementalGroups": {
48
+ "type": "RunAsAny"
49
+ },
50
+ "fsGroup": {
51
+ "type": "RunAsAny"
52
+ },
53
+ "readOnlyRootFilesystem": false,
54
+ "users": [],
55
+ "groups": [
56
+ "system:cluster-admins"
57
+ ]
58
+ },
59
+ {
60
+ "metadata": {
61
+ "name": "hostaccess",
62
+ "selfLink": "/apis/security.openshift.io/v1/securitycontextconstraints/hostaccess",
63
+ "uid": "12b5b3a2-ef00-11e8-b4c0-68f728fac3ab",
64
+ "resourceVersion": "69",
65
+ "creationTimestamp": "2018-11-23T09:13:42Z",
66
+ "annotations": {
67
+ "kubernetes.io/description": "hostaccess allows access to all host namespaces but still requires pods to be run with a UID and SELinux context that are allocated to the namespace. WARNING: this SCC allows host access to namespaces, file systems, and PIDS. It should only be used by trusted pods. Grant with caution."
68
+ }
69
+ },
70
+ "priority": null,
71
+ "allowPrivilegedContainer": false,
72
+ "defaultAddCapabilities": null,
73
+ "requiredDropCapabilities": [
74
+ "KILL",
75
+ "MKNOD",
76
+ "SETUID",
77
+ "SETGID"
78
+ ],
79
+ "allowedCapabilities": null,
80
+ "allowHostDirVolumePlugin": true,
81
+ "volumes": [
82
+ "configMap",
83
+ "downwardAPI",
84
+ "emptyDir",
85
+ "hostPath",
86
+ "persistentVolumeClaim",
87
+ "projected",
88
+ "secret"
89
+ ],
90
+ "allowedFlexVolumes": null,
91
+ "allowHostNetwork": true,
92
+ "allowHostPorts": true,
93
+ "allowHostPID": true,
94
+ "allowHostIPC": true,
95
+ "seLinuxContext": {
96
+ "type": "MustRunAs"
97
+ },
98
+ "runAsUser": {
99
+ "type": "MustRunAsRange"
100
+ },
101
+ "supplementalGroups": {
102
+ "type": "RunAsAny"
103
+ },
104
+ "fsGroup": {
105
+ "type": "MustRunAs"
106
+ },
107
+ "readOnlyRootFilesystem": false,
108
+ "users": [],
109
+ "groups": []
110
+ },
111
+ {
112
+ "metadata": {
113
+ "name": "hostmount-anyuid",
114
+ "selfLink": "/apis/security.openshift.io/v1/securitycontextconstraints/hostmount-anyuid",
115
+ "uid": "12b512c0-ef00-11e8-b4c0-68f728fac3ab",
116
+ "resourceVersion": "68",
117
+ "creationTimestamp": "2018-11-23T09:13:42Z",
118
+ "annotations": {
119
+ "kubernetes.io/description": "hostmount-anyuid provides all the features of the restricted SCC but allows host mounts and any UID by a pod. This is primarily used by the persistent volume recycler. WARNING: this SCC allows host file system access as any UID, including UID 0. Grant with caution."
120
+ }
121
+ },
122
+ "priority": null,
123
+ "allowPrivilegedContainer": false,
124
+ "defaultAddCapabilities": null,
125
+ "requiredDropCapabilities": [
126
+ "MKNOD"
127
+ ],
128
+ "allowedCapabilities": null,
129
+ "allowHostDirVolumePlugin": true,
130
+ "volumes": [
131
+ "configMap",
132
+ "downwardAPI",
133
+ "emptyDir",
134
+ "hostPath",
135
+ "nfs",
136
+ "persistentVolumeClaim",
137
+ "projected",
138
+ "secret"
139
+ ],
140
+ "allowedFlexVolumes": null,
141
+ "allowHostNetwork": false,
142
+ "allowHostPorts": false,
143
+ "allowHostPID": false,
144
+ "allowHostIPC": false,
145
+ "seLinuxContext": {
146
+ "type": "MustRunAs"
147
+ },
148
+ "runAsUser": {
149
+ "type": "RunAsAny"
150
+ },
151
+ "supplementalGroups": {
152
+ "type": "RunAsAny"
153
+ },
154
+ "fsGroup": {
155
+ "type": "RunAsAny"
156
+ },
157
+ "readOnlyRootFilesystem": false,
158
+ "users": [
159
+ "system:serviceaccount:openshift-infra:pv-recycler-controller"
160
+ ],
161
+ "groups": []
162
+ },
163
+ {
164
+ "metadata": {
165
+ "name": "hostnetwork",
166
+ "selfLink": "/apis/security.openshift.io/v1/securitycontextconstraints/hostnetwork",
167
+ "uid": "12bb0984-ef00-11e8-b4c0-68f728fac3ab",
168
+ "resourceVersion": "72",
169
+ "creationTimestamp": "2018-11-23T09:13:42Z",
170
+ "annotations": {
171
+ "kubernetes.io/description": "hostnetwork allows using host networking and host ports but still requires pods to be run with a UID and SELinux context that are allocated to the namespace."
172
+ }
173
+ },
174
+ "priority": null,
175
+ "allowPrivilegedContainer": false,
176
+ "defaultAddCapabilities": null,
177
+ "requiredDropCapabilities": [
178
+ "KILL",
179
+ "MKNOD",
180
+ "SETUID",
181
+ "SETGID"
182
+ ],
183
+ "allowedCapabilities": null,
184
+ "allowHostDirVolumePlugin": false,
185
+ "volumes": [
186
+ "configMap",
187
+ "downwardAPI",
188
+ "emptyDir",
189
+ "persistentVolumeClaim",
190
+ "projected",
191
+ "secret"
192
+ ],
193
+ "allowedFlexVolumes": null,
194
+ "allowHostNetwork": true,
195
+ "allowHostPorts": true,
196
+ "allowHostPID": false,
197
+ "allowHostIPC": false,
198
+ "seLinuxContext": {
199
+ "type": "MustRunAs"
200
+ },
201
+ "runAsUser": {
202
+ "type": "MustRunAsRange"
203
+ },
204
+ "supplementalGroups": {
205
+ "type": "MustRunAs"
206
+ },
207
+ "fsGroup": {
208
+ "type": "MustRunAs"
209
+ },
210
+ "readOnlyRootFilesystem": false,
211
+ "users": [],
212
+ "groups": []
213
+ },
214
+ {
215
+ "metadata": {
216
+ "name": "nonroot",
217
+ "selfLink": "/apis/security.openshift.io/v1/securitycontextconstraints/nonroot",
218
+ "uid": "12b37c59-ef00-11e8-b4c0-68f728fac3ab",
219
+ "resourceVersion": "67",
220
+ "creationTimestamp": "2018-11-23T09:13:42Z",
221
+ "annotations": {
222
+ "kubernetes.io/description": "nonroot provides all features of the restricted SCC but allows users to run with any non-root UID. The user must specify the UID or it must be specified on the by the manifest of the container runtime."
223
+ }
224
+ },
225
+ "priority": null,
226
+ "allowPrivilegedContainer": false,
227
+ "defaultAddCapabilities": null,
228
+ "requiredDropCapabilities": [
229
+ "KILL",
230
+ "MKNOD",
231
+ "SETUID",
232
+ "SETGID"
233
+ ],
234
+ "allowedCapabilities": null,
235
+ "allowHostDirVolumePlugin": false,
236
+ "volumes": [
237
+ "configMap",
238
+ "downwardAPI",
239
+ "emptyDir",
240
+ "persistentVolumeClaim",
241
+ "projected",
242
+ "secret"
243
+ ],
244
+ "allowedFlexVolumes": null,
245
+ "allowHostNetwork": false,
246
+ "allowHostPorts": false,
247
+ "allowHostPID": false,
248
+ "allowHostIPC": false,
249
+ "seLinuxContext": {
250
+ "type": "MustRunAs"
251
+ },
252
+ "runAsUser": {
253
+ "type": "MustRunAsNonRoot"
254
+ },
255
+ "supplementalGroups": {
256
+ "type": "RunAsAny"
257
+ },
258
+ "fsGroup": {
259
+ "type": "RunAsAny"
260
+ },
261
+ "readOnlyRootFilesystem": false,
262
+ "users": [],
263
+ "groups": []
264
+ },
265
+ {
266
+ "metadata": {
267
+ "name": "privileged",
268
+ "selfLink": "/apis/security.openshift.io/v1/securitycontextconstraints/privileged",
269
+ "uid": "12b18f4a-ef00-11e8-b4c0-68f728fac3ab",
270
+ "resourceVersion": "300",
271
+ "creationTimestamp": "2018-11-23T09:13:42Z",
272
+ "annotations": {
273
+ "kubernetes.io/description": "privileged allows access to all privileged and host features and the ability to run as any user, any group, any fsGroup, and with any SELinux context. WARNING: this is the most relaxed SCC and should be used only for cluster administration. Grant with caution."
274
+ }
275
+ },
276
+ "priority": null,
277
+ "allowPrivilegedContainer": true,
278
+ "defaultAddCapabilities": null,
279
+ "requiredDropCapabilities": null,
280
+ "allowedCapabilities": [
281
+ "*"
282
+ ],
283
+ "allowHostDirVolumePlugin": true,
284
+ "volumes": [
285
+ "*"
286
+ ],
287
+ "allowedFlexVolumes": null,
288
+ "allowHostNetwork": true,
289
+ "allowHostPorts": true,
290
+ "allowHostPID": true,
291
+ "allowHostIPC": true,
292
+ "seLinuxContext": {
293
+ "type": "RunAsAny"
294
+ },
295
+ "runAsUser": {
296
+ "type": "RunAsAny"
297
+ },
298
+ "supplementalGroups": {
299
+ "type": "RunAsAny"
300
+ },
301
+ "fsGroup": {
302
+ "type": "RunAsAny"
303
+ },
304
+ "readOnlyRootFilesystem": false,
305
+ "users": [
306
+ "system:admin",
307
+ "system:serviceaccount:openshift-infra:build-controller",
308
+ "system:serviceaccount:default:pvinstaller",
309
+ "system:serviceaccount:default:registry",
310
+ "system:serviceaccount:default:router"
311
+ ],
312
+ "groups": [
313
+ "system:cluster-admins",
314
+ "system:nodes",
315
+ "system:masters"
316
+ ],
317
+ "seccompProfiles": [
318
+ "*"
319
+ ]
320
+ },
321
+ {
322
+ "metadata": {
323
+ "name": "restricted",
324
+ "selfLink": "/apis/security.openshift.io/v1/securitycontextconstraints/restricted",
325
+ "uid": "12b9a842-ef00-11e8-b4c0-68f728fac3ab",
326
+ "resourceVersion": "70",
327
+ "creationTimestamp": "2018-11-23T09:13:42Z",
328
+ "annotations": {
329
+ "kubernetes.io/description": "restricted denies access to all host features and requires pods to be run with a UID, and SELinux context that are allocated to the namespace. This is the most restrictive SCC and it is used by default for authenticated users."
330
+ }
331
+ },
332
+ "priority": null,
333
+ "allowPrivilegedContainer": false,
334
+ "defaultAddCapabilities": null,
335
+ "requiredDropCapabilities": [
336
+ "KILL",
337
+ "MKNOD",
338
+ "SETUID",
339
+ "SETGID"
340
+ ],
341
+ "allowedCapabilities": null,
342
+ "allowHostDirVolumePlugin": false,
343
+ "volumes": [
344
+ "configMap",
345
+ "downwardAPI",
346
+ "emptyDir",
347
+ "persistentVolumeClaim",
348
+ "projected",
349
+ "secret"
350
+ ],
351
+ "allowedFlexVolumes": null,
352
+ "allowHostNetwork": false,
353
+ "allowHostPorts": false,
354
+ "allowHostPID": false,
355
+ "allowHostIPC": false,
356
+ "seLinuxContext": {
357
+ "type": "MustRunAs"
358
+ },
359
+ "runAsUser": {
360
+ "type": "MustRunAsRange"
361
+ },
362
+ "supplementalGroups": {
363
+ "type": "RunAsAny"
364
+ },
365
+ "fsGroup": {
366
+ "type": "MustRunAs"
367
+ },
368
+ "readOnlyRootFilesystem": false,
369
+ "users": [],
370
+ "groups": [
371
+ "system:authenticated"
372
+ ]
373
+ }
374
+ ]
375
+ }
@@ -1,3 +1,4 @@
1
+
1
2
  require_relative 'test_helper'
2
3
 
3
4
  # Unit tests for the common module
@@ -33,8 +34,26 @@ class CommonTest < MiniTest::Test
33
34
  BuildConfig build_config
34
35
  Image image
35
36
  ImageStream image_stream
36
- ].each_slice(2) do |singular, plural|
37
- assert_equal(Kubeclient::ClientMixin.underscore_entity(singular), plural)
37
+ dogstatsd dogstatsd
38
+ lowerCamelUPPERCase lower_camel_uppercase
39
+ HTTPAPISpecBinding httpapispec_binding
40
+ APIGroup apigroup
41
+ APIGroupList apigroup_list
42
+ APIResourceList apiresource_list
43
+ APIService apiservice
44
+ APIServiceList apiservice_list
45
+ APIVersions apiversions
46
+ OAuthAccessToken oauth_access_token
47
+ OAuthAccessTokenList oauth_access_token_list
48
+ OAuthAuthorizeToken oauth_authorize_token
49
+ OAuthAuthorizeTokenList oauth_authorize_token_list
50
+ OAuthClient oauth_client
51
+ OAuthClientAuthorization oauth_client_authorization
52
+ OAuthClientAuthorizationList oauth_client_authorization_list
53
+ OAuthClientList oauth_client_list
54
+ ].each_slice(2) do |kind, expected_underscore|
55
+ underscore = Kubeclient::ClientMixin.underscore_entity(kind)
56
+ assert_equal(underscore, expected_underscore)
38
57
  end
39
58
  end
40
59
 
@@ -3,10 +3,9 @@ require_relative 'test_helper'
3
3
  # ComponentStatus tests
4
4
  class TestComponentStatus < MiniTest::Test
5
5
  def test_get_from_json_v3
6
+ stub_core_api_list
6
7
  stub_request(:get, %r{/componentstatuses})
7
8
  .to_return(body: open_test_file('component_status.json'), status: 200)
8
- stub_request(:get, %r{/api/v1$})
9
- .to_return(body: open_test_file('core_api_resource_list.json'), status: 200)
10
9
 
11
10
  client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
12
11
  component_status = client.get_component_status('etcd-0', 'default')
@@ -91,10 +91,10 @@ class KubeclientConfigTest < MiniTest::Test
91
91
  #
92
92
  # At the time of this writing the files to be updated are:
93
93
  #
94
- # test/config/allinone.kubeconfig
95
- # test/config/external-ca.pem
96
- # test/config/external-cert.pem
97
- # test/config/external-key.rsa
94
+ # cp openshift.local.config/master/admin.kubeconfig test/config/allinone.kubeconfig
95
+ # cp openshift.local.config/master/ca.crt test/config/external-ca.pem
96
+ # cp openshift.local.config/master/admin.crt test/config/external-cert.pem
97
+ # cp openshift.local.config/master/admin.key test/config/external-key.rsa
98
98
  assert(context.ssl_options[:cert_store].verify(context.ssl_options[:client_cert]))
99
99
  else
100
100
  assert_equal(OpenSSL::SSL::VERIFY_NONE, context.ssl_options[:verify_ssl])
@@ -1,15 +1,12 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- # Endpoint entity tests
3
+ # kind: 'Endpoints' entity tests.
4
+ # This is one of the unusual `kind`s that are already plural (https://github.com/kubernetes/kubernetes/issues/8115).
5
+ # We force singular in method names like 'create_endpoint',
6
+ # but `kind` should remain plural as in kubernetes.
4
7
  class TestEndpoint < MiniTest::Test
5
8
  def test_create_endpoint
6
- stub_request(:get, %r{/api/v1$})
7
- .to_return(
8
- body: open_test_file('core_api_resource_list.json'),
9
- status: 200
10
- )
11
-
12
- client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
9
+ stub_core_api_list
13
10
  testing_ep = Kubeclient::Resource.new
14
11
  testing_ep.metadata = {}
15
12
  testing_ep.metadata.name = 'myendpoint'
@@ -29,7 +26,29 @@ class TestEndpoint < MiniTest::Test
29
26
  .with(body: req_body)
30
27
  .to_return(body: open_test_file('created_endpoint.json'), status: 201)
31
28
 
29
+ client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
32
30
  created_ep = client.create_endpoint(testing_ep)
33
31
  assert_equal('Endpoints', created_ep.kind)
32
+ assert_equal('v1', created_ep.apiVersion)
33
+
34
+ client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1', as: :parsed_symbolized)
35
+ created_ep = client.create_endpoint(testing_ep)
36
+ assert_equal('Endpoints', created_ep[:kind])
37
+ assert_equal('v1', created_ep[:apiVersion])
38
+ end
39
+
40
+ def test_get_endpoints
41
+ stub_core_api_list
42
+ stub_request(:get, %r{/endpoints})
43
+ .to_return(body: open_test_file('endpoint_list.json'), status: 200)
44
+ client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
45
+
46
+ collection = client.get_endpoints(as: :parsed_symbolized)
47
+ assert_equal('EndpointsList', collection[:kind])
48
+ assert_equal('v1', collection[:apiVersion])
49
+
50
+ # Stripping of 'List' in collection.kind RecursiveOpenStruct mode only is historic.
51
+ collection = client.get_endpoints
52
+ assert_equal('Endpoints', collection.kind)
34
53
  end
35
54
  end