kubernator 1.0.22__py3-none-any.whl → 1.0.23__py3-none-any.whl
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 kubernator might be problematic. Click here for more details.
- kubernator/__init__.py +1 -1
- kubernator/plugins/gke.py +105 -0
- kubernator/plugins/istio.py +23 -9
- kubernator/plugins/k8s.py +98 -50
- kubernator/plugins/k8s_api.py +7 -7
- kubernator/plugins/kubectl.py +36 -4
- kubernator/plugins/minikube.py +32 -2
- {kubernator-1.0.22.dist-info → kubernator-1.0.23.dist-info}/METADATA +1 -1
- {kubernator-1.0.22.dist-info → kubernator-1.0.23.dist-info}/RECORD +14 -13
- {kubernator-1.0.22.dist-info → kubernator-1.0.23.dist-info}/WHEEL +0 -0
- {kubernator-1.0.22.dist-info → kubernator-1.0.23.dist-info}/entry_points.txt +0 -0
- {kubernator-1.0.22.dist-info → kubernator-1.0.23.dist-info}/namespace_packages.txt +0 -0
- {kubernator-1.0.22.dist-info → kubernator-1.0.23.dist-info}/top_level.txt +0 -0
- {kubernator-1.0.22.dist-info → kubernator-1.0.23.dist-info}/zip-safe +0 -0
kubernator/__init__.py
CHANGED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright 2020 Express Systems USA, Inc
|
|
4
|
+
# Copyright 2025 Karellen, Inc.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
import logging
|
|
20
|
+
import os
|
|
21
|
+
import tempfile
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
from shutil import which
|
|
24
|
+
|
|
25
|
+
from kubernator.api import (KubernatorPlugin,
|
|
26
|
+
StripNL
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
logger = logging.getLogger("kubernator.gke")
|
|
30
|
+
proc_logger = logger.getChild("proc")
|
|
31
|
+
stdout_logger = StripNL(proc_logger.info)
|
|
32
|
+
stderr_logger = StripNL(proc_logger.warning)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class GkePlugin(KubernatorPlugin):
|
|
36
|
+
logger = logger
|
|
37
|
+
|
|
38
|
+
_name = "gke"
|
|
39
|
+
|
|
40
|
+
def __init__(self):
|
|
41
|
+
self.context = None
|
|
42
|
+
self.kubeconfig_dir = tempfile.TemporaryDirectory()
|
|
43
|
+
self.name = None
|
|
44
|
+
self.region = None
|
|
45
|
+
self.project = None
|
|
46
|
+
self.gcloud_file = None
|
|
47
|
+
|
|
48
|
+
super().__init__()
|
|
49
|
+
|
|
50
|
+
def set_context(self, context):
|
|
51
|
+
self.context = context
|
|
52
|
+
|
|
53
|
+
def register(self, *, name=None, region=None, project=None):
|
|
54
|
+
context = self.context
|
|
55
|
+
|
|
56
|
+
if not name:
|
|
57
|
+
raise ValueError("`name` is required")
|
|
58
|
+
if not region:
|
|
59
|
+
raise ValueError("`region` is required")
|
|
60
|
+
if not project:
|
|
61
|
+
raise ValueError("`project` is required")
|
|
62
|
+
|
|
63
|
+
self.name = name
|
|
64
|
+
self.region = region
|
|
65
|
+
self.project = project
|
|
66
|
+
|
|
67
|
+
# Use current version
|
|
68
|
+
gcloud_file = which("gcloud")
|
|
69
|
+
if not gcloud_file:
|
|
70
|
+
raise RuntimeError("`gcloud` cannot be found")
|
|
71
|
+
logger.debug("Found gcloud in %r", gcloud_file)
|
|
72
|
+
self.gcloud_file = gcloud_file
|
|
73
|
+
|
|
74
|
+
context.app.register_plugin("kubeconfig")
|
|
75
|
+
|
|
76
|
+
context.globals.gke = dict(kubeconfig=str(Path(self.kubeconfig_dir.name) / "config"),
|
|
77
|
+
name=name,
|
|
78
|
+
region=region,
|
|
79
|
+
project=project,
|
|
80
|
+
gcloud_file=gcloud_file
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
def handle_init(self):
|
|
84
|
+
context = self.context
|
|
85
|
+
|
|
86
|
+
env = dict(os.environ)
|
|
87
|
+
env["KUBECONFIG"] = str(context.gke.kubeconfig)
|
|
88
|
+
self.context.app.run([context.gke.gcloud_file, "components", "install", "gke-gcloud-auth-plugin"],
|
|
89
|
+
stdout_logger,
|
|
90
|
+
stderr_logger).wait()
|
|
91
|
+
self.context.app.run([context.gke.gcloud_file, "container", "clusters", "get-credentials",
|
|
92
|
+
context.gke.name,
|
|
93
|
+
"--region", context.gke.region,
|
|
94
|
+
"--project", context.gke.project],
|
|
95
|
+
stdout_logger,
|
|
96
|
+
stderr_logger,
|
|
97
|
+
env=env).wait()
|
|
98
|
+
|
|
99
|
+
context.kubeconfig.set(context.gke.kubeconfig)
|
|
100
|
+
|
|
101
|
+
def handle_shutdown(self):
|
|
102
|
+
self.kubeconfig_dir.cleanup()
|
|
103
|
+
|
|
104
|
+
def __repr__(self):
|
|
105
|
+
return "GKE Plugin"
|
kubernator/plugins/istio.py
CHANGED
|
@@ -25,6 +25,7 @@ from pathlib import Path
|
|
|
25
25
|
from shutil import which
|
|
26
26
|
|
|
27
27
|
import yaml
|
|
28
|
+
|
|
28
29
|
from kubernator.api import (KubernatorPlugin, scan_dir,
|
|
29
30
|
TemplateEngine,
|
|
30
31
|
load_remote_file,
|
|
@@ -34,6 +35,7 @@ from kubernator.api import (KubernatorPlugin, scan_dir,
|
|
|
34
35
|
get_golang_os,
|
|
35
36
|
get_golang_machine,
|
|
36
37
|
prepend_os_path, jp, load_file)
|
|
38
|
+
from kubernator.plugins.k8s import api_exc_normalize_body, api_exc_format_body
|
|
37
39
|
from kubernator.plugins.k8s_api import K8SResourcePluginMixin
|
|
38
40
|
|
|
39
41
|
logger = logging.getLogger("kubernator.istio")
|
|
@@ -277,11 +279,17 @@ class IstioPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
277
279
|
try:
|
|
278
280
|
res.delete(dry_run=dry_run)
|
|
279
281
|
except ApiException as e:
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
skip =
|
|
283
|
-
|
|
282
|
+
api_exc_normalize_body(e)
|
|
283
|
+
try:
|
|
284
|
+
skip = False
|
|
285
|
+
if e.status == 404 and missing_ok:
|
|
286
|
+
skip = True
|
|
287
|
+
if not skip:
|
|
288
|
+
raise
|
|
289
|
+
except ApiException as e:
|
|
290
|
+
api_exc_format_body(e)
|
|
284
291
|
raise
|
|
292
|
+
|
|
285
293
|
return res
|
|
286
294
|
|
|
287
295
|
def _create_resource_internal(self, manifest, dry_run=True, exists_ok=False):
|
|
@@ -297,12 +305,18 @@ class IstioPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
297
305
|
res.create(dry_run=dry_run)
|
|
298
306
|
except ApiException as e:
|
|
299
307
|
skip = False
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
if status
|
|
303
|
-
|
|
304
|
-
|
|
308
|
+
api_exc_normalize_body(e)
|
|
309
|
+
try:
|
|
310
|
+
if e.status == 409:
|
|
311
|
+
status = e.body
|
|
312
|
+
if status["reason"] == "AlreadyExists" and exists_ok:
|
|
313
|
+
skip = True
|
|
314
|
+
if not skip:
|
|
315
|
+
raise
|
|
316
|
+
except ApiException as e:
|
|
317
|
+
api_exc_format_body(e)
|
|
305
318
|
raise
|
|
319
|
+
|
|
306
320
|
return res
|
|
307
321
|
|
|
308
322
|
def _install(self, operators_file, dry_run):
|
kubernator/plugins/k8s.py
CHANGED
|
@@ -30,6 +30,7 @@ from typing import Iterable, Callable, Sequence
|
|
|
30
30
|
|
|
31
31
|
import jsonpatch
|
|
32
32
|
import yaml
|
|
33
|
+
from kubernetes.client import ApiException
|
|
33
34
|
|
|
34
35
|
from kubernator.api import (KubernatorPlugin,
|
|
35
36
|
Globs,
|
|
@@ -39,7 +40,8 @@ from kubernator.api import (KubernatorPlugin,
|
|
|
39
40
|
load_remote_file,
|
|
40
41
|
StripNL,
|
|
41
42
|
install_python_k8s_client,
|
|
42
|
-
TemplateEngine
|
|
43
|
+
TemplateEngine,
|
|
44
|
+
sleep)
|
|
43
45
|
from kubernator.merge import extract_merge_instructions, apply_merge_instructions
|
|
44
46
|
from kubernator.plugins.k8s_api import (K8SResourcePluginMixin,
|
|
45
47
|
K8SResource,
|
|
@@ -82,6 +84,21 @@ def normalize_pkg_version(v: str):
|
|
|
82
84
|
return tuple(map(int, v_split))
|
|
83
85
|
|
|
84
86
|
|
|
87
|
+
def api_exc_normalize_body(e: "ApiException"):
|
|
88
|
+
if e.headers and "content-type" in e.headers:
|
|
89
|
+
content_type = e.headers["content-type"]
|
|
90
|
+
if content_type == "application/json" or content_type.endswith("+json"):
|
|
91
|
+
e.body = json.loads(e.body)
|
|
92
|
+
elif (content_type in ("application/yaml", "application/x-yaml", "text/yaml",
|
|
93
|
+
"text/x-yaml") or content_type.endswith("+yaml")):
|
|
94
|
+
e.body = yaml.safe_load(e.body)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def api_exc_format_body(e: ApiException):
|
|
98
|
+
if not isinstance(e.body, (str, bytes)):
|
|
99
|
+
e.body = json.dumps(e.body, indent=4)
|
|
100
|
+
|
|
101
|
+
|
|
85
102
|
class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
86
103
|
logger = logger
|
|
87
104
|
|
|
@@ -120,6 +137,8 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
120
137
|
("apps", "StatefulSet"): K8SPropagationPolicy.ORPHAN,
|
|
121
138
|
("apps", "Deployment"): K8SPropagationPolicy.ORPHAN,
|
|
122
139
|
("storage.k8s.io", "StorageClass"): K8SPropagationPolicy.ORPHAN,
|
|
140
|
+
(None, "Pod"): K8SPropagationPolicy.BACKGROUND,
|
|
141
|
+
("batch", "Job"): K8SPropagationPolicy.ORPHAN,
|
|
123
142
|
},
|
|
124
143
|
default_includes=Globs(["*.yaml", "*.yml"], True),
|
|
125
144
|
default_excludes=Globs([".*"], True),
|
|
@@ -137,6 +156,7 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
137
156
|
field_validation=field_validation,
|
|
138
157
|
field_validation_warn_fatal=field_validation_warn_fatal,
|
|
139
158
|
field_validation_warnings=0,
|
|
159
|
+
conflict_retry_delay=0.3,
|
|
140
160
|
_k8s=self,
|
|
141
161
|
)
|
|
142
162
|
context.k8s = dict(default_includes=Globs(context.globals.k8s.default_includes),
|
|
@@ -199,7 +219,7 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
199
219
|
|
|
200
220
|
k8s.client = self._setup_k8s_client()
|
|
201
221
|
version = client.VersionApi(k8s.client).get_code()
|
|
202
|
-
if "-eks-" in version.git_version:
|
|
222
|
+
if "-eks-" or "-gke" in version.git_version:
|
|
203
223
|
git_version = version.git_version.split("-")[0]
|
|
204
224
|
else:
|
|
205
225
|
git_version = version.git_version
|
|
@@ -409,8 +429,8 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
409
429
|
|
|
410
430
|
def handle_400_strict_validation_error(e: ApiException):
|
|
411
431
|
if e.status == 400:
|
|
412
|
-
|
|
413
|
-
|
|
432
|
+
# Assumes the body has been parsed
|
|
433
|
+
status = e.body
|
|
414
434
|
if status["status"] == "Failure":
|
|
415
435
|
if FIELD_VALIDATION_STRICT_MARKER in status["message"]:
|
|
416
436
|
message = status["message"]
|
|
@@ -425,18 +445,31 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
425
445
|
resource, resource.source, status["message"])
|
|
426
446
|
raise e from None
|
|
427
447
|
|
|
428
|
-
def create(exists_ok=False):
|
|
448
|
+
def create(exists_ok=False, wait_for_delete=False):
|
|
429
449
|
logger.info("Creating resource %s%s%s", resource, status_msg,
|
|
430
450
|
" (ignoring existing)" if exists_ok else "")
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
451
|
+
while True:
|
|
452
|
+
try:
|
|
453
|
+
create_func()
|
|
454
|
+
return
|
|
455
|
+
except ApiException as __e:
|
|
456
|
+
api_exc_normalize_body(__e)
|
|
457
|
+
try:
|
|
458
|
+
if exists_ok or wait_for_delete:
|
|
459
|
+
if __e.status == 409:
|
|
460
|
+
status = __e.body
|
|
461
|
+
if status["reason"] == "AlreadyExists":
|
|
462
|
+
if wait_for_delete:
|
|
463
|
+
sleep(self.context.k8s.conflict_retry_delay)
|
|
464
|
+
logger.info("Retry creating resource %s%s%s", resource, status_msg,
|
|
465
|
+
" (ignoring existing)" if exists_ok else "")
|
|
466
|
+
continue
|
|
467
|
+
else:
|
|
468
|
+
return
|
|
469
|
+
raise
|
|
470
|
+
except ApiException as ___e:
|
|
471
|
+
api_exc_format_body(___e)
|
|
472
|
+
raise
|
|
440
473
|
|
|
441
474
|
merge_instrs, normalized_manifest = extract_merge_instructions(resource.manifest, resource)
|
|
442
475
|
if merge_instrs:
|
|
@@ -450,15 +483,20 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
450
483
|
remote_resource = resource.get()
|
|
451
484
|
logger.trace("Current resource %s: %s", resource, remote_resource)
|
|
452
485
|
except ApiException as e:
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
486
|
+
api_exc_normalize_body(e)
|
|
487
|
+
try:
|
|
488
|
+
if e.status == 404:
|
|
489
|
+
try:
|
|
490
|
+
create()
|
|
491
|
+
return 1, 0, 0
|
|
492
|
+
except ApiException as e:
|
|
493
|
+
api_exc_normalize_body(e)
|
|
494
|
+
if not handle_400_strict_validation_error(e):
|
|
495
|
+
raise
|
|
496
|
+
else:
|
|
497
|
+
raise
|
|
498
|
+
except ApiException as _e:
|
|
499
|
+
api_exc_format_body(_e)
|
|
462
500
|
raise
|
|
463
501
|
else:
|
|
464
502
|
logger.trace("Attempting to retrieve a normalized patch for resource %s: %s", resource, normalized_manifest)
|
|
@@ -468,34 +506,44 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
468
506
|
dry_run=True,
|
|
469
507
|
force=True)
|
|
470
508
|
except ApiException as e:
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
509
|
+
try:
|
|
510
|
+
api_exc_normalize_body(e)
|
|
511
|
+
|
|
512
|
+
if e.status == 422:
|
|
513
|
+
status = e.body
|
|
514
|
+
# Assumes the body has been unmarshalled
|
|
515
|
+
details = status["details"]
|
|
516
|
+
immutable_key = details.get("group"), details["kind"]
|
|
517
|
+
|
|
518
|
+
try:
|
|
519
|
+
propagation_policy = self.context.k8s.immutable_changes[immutable_key]
|
|
520
|
+
except KeyError:
|
|
521
|
+
raise e from None
|
|
522
|
+
else:
|
|
523
|
+
for cause in details["causes"]:
|
|
524
|
+
if (
|
|
525
|
+
cause["reason"] == "FieldValueInvalid" and
|
|
526
|
+
"field is immutable" in cause["message"]
|
|
527
|
+
or
|
|
528
|
+
cause["reason"] == "FieldValueForbidden" and
|
|
529
|
+
("Forbidden: updates to" in cause["message"]
|
|
530
|
+
or
|
|
531
|
+
"Forbidden: pod updates" in cause["message"])
|
|
532
|
+
):
|
|
533
|
+
logger.info("Deleting resource %s (cascade %s)%s", resource,
|
|
534
|
+
propagation_policy.policy,
|
|
535
|
+
status_msg)
|
|
536
|
+
delete_func(propagation_policy=propagation_policy)
|
|
537
|
+
create(exists_ok=dry_run, wait_for_delete=not dry_run)
|
|
538
|
+
return 1, 0, 1
|
|
539
|
+
raise
|
|
480
540
|
else:
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
"Forbidden: updates to" in cause["message"]
|
|
488
|
-
):
|
|
489
|
-
logger.info("Deleting resource %s (cascade %s)%s", resource,
|
|
490
|
-
propagation_policy.policy,
|
|
491
|
-
status_msg)
|
|
492
|
-
delete_func(propagation_policy=propagation_policy)
|
|
493
|
-
create(exists_ok=dry_run)
|
|
494
|
-
return 1, 0, 1
|
|
495
|
-
raise
|
|
496
|
-
else:
|
|
497
|
-
if not handle_400_strict_validation_error(e):
|
|
498
|
-
raise
|
|
541
|
+
if not handle_400_strict_validation_error(e):
|
|
542
|
+
raise
|
|
543
|
+
except ApiException as _e:
|
|
544
|
+
api_exc_format_body(_e)
|
|
545
|
+
raise
|
|
546
|
+
|
|
499
547
|
else:
|
|
500
548
|
logger.trace("Merged resource %s: %s", resource, merged_resource)
|
|
501
549
|
if merge_instrs:
|
kubernator/plugins/k8s_api.py
CHANGED
|
@@ -116,22 +116,22 @@ k8s_format_checker = FormatChecker()
|
|
|
116
116
|
|
|
117
117
|
@k8s_format_checker.checks("int32")
|
|
118
118
|
def check_int32(value):
|
|
119
|
-
return -2147483648 < value < 2147483647
|
|
119
|
+
return value is not None and (-2147483648 < value < 2147483647)
|
|
120
120
|
|
|
121
121
|
|
|
122
122
|
@k8s_format_checker.checks("int64")
|
|
123
123
|
def check_int64(value):
|
|
124
|
-
return -9223372036854775808 < value < 9223372036854775807
|
|
124
|
+
return value is not None and (-9223372036854775808 < value < 9223372036854775807)
|
|
125
125
|
|
|
126
126
|
|
|
127
127
|
@k8s_format_checker.checks("float")
|
|
128
128
|
def check_float(value):
|
|
129
|
-
return -3.4E+38 < value < +3.4E+38
|
|
129
|
+
return value is not None and (-3.4E+38 < value < +3.4E+38)
|
|
130
130
|
|
|
131
131
|
|
|
132
132
|
@k8s_format_checker.checks("double")
|
|
133
133
|
def check_double(value):
|
|
134
|
-
return -1.7E+308 < value < +1.7E+308
|
|
134
|
+
return value is not None and (-1.7E+308 < value < +1.7E+308)
|
|
135
135
|
|
|
136
136
|
|
|
137
137
|
@k8s_format_checker.checks("byte", ValueError)
|
|
@@ -619,9 +619,9 @@ class K8SResourcePluginMixin:
|
|
|
619
619
|
errors = list(self._validate_resource(manifest, source))
|
|
620
620
|
if errors:
|
|
621
621
|
for error in errors:
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
622
|
+
self.logger.error("Error detected in K8S manifest %s from %s: \n%s",
|
|
623
|
+
resource_description, source or "<unknown>", yaml.safe_dump(manifest, None),
|
|
624
|
+
exc_info=error)
|
|
625
625
|
raise errors[0]
|
|
626
626
|
|
|
627
627
|
rdef = self._get_manifest_rdef(manifest)
|
kubernator/plugins/kubectl.py
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
#
|
|
18
18
|
|
|
19
|
+
import io
|
|
19
20
|
import json
|
|
20
21
|
import logging
|
|
21
22
|
import os
|
|
@@ -23,6 +24,8 @@ import tempfile
|
|
|
23
24
|
from pathlib import Path
|
|
24
25
|
from shutil import which, copy
|
|
25
26
|
|
|
27
|
+
import yaml
|
|
28
|
+
|
|
26
29
|
from kubernator.api import (KubernatorPlugin,
|
|
27
30
|
prepend_os_path,
|
|
28
31
|
StripNL,
|
|
@@ -89,15 +92,44 @@ class KubectlPlugin(KubernatorPlugin):
|
|
|
89
92
|
context.globals.kubectl = dict(version=version,
|
|
90
93
|
kubectl_file=kubectl_file,
|
|
91
94
|
stanza=self.stanza,
|
|
92
|
-
test=self.test_kubectl
|
|
95
|
+
test=self.test_kubectl,
|
|
96
|
+
run=self.run,
|
|
97
|
+
run_capturing=self.run_capturing,
|
|
98
|
+
get=self.get,
|
|
93
99
|
)
|
|
94
100
|
|
|
95
101
|
context.globals.kubectl.version = context.kubectl.test()
|
|
96
102
|
|
|
103
|
+
def run_capturing(self, *args, **kwargs):
|
|
104
|
+
return self.context.app.run_capturing_out(self.stanza() +
|
|
105
|
+
list(args),
|
|
106
|
+
stderr_logger,
|
|
107
|
+
**kwargs
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
def run(self, *args, **kwargs):
|
|
111
|
+
self.context.app.run(self.stanza() +
|
|
112
|
+
list(args),
|
|
113
|
+
stdout_logger,
|
|
114
|
+
stderr_logger,
|
|
115
|
+
**kwargs
|
|
116
|
+
).wait()
|
|
117
|
+
|
|
118
|
+
def get(self, resource_type, resource_name, namespace=None):
|
|
119
|
+
args = ["get", resource_type, resource_name]
|
|
120
|
+
if namespace:
|
|
121
|
+
args += ["-n", namespace]
|
|
122
|
+
args += ["-o", "yaml"]
|
|
123
|
+
|
|
124
|
+
res = list(yaml.safe_load_all(io.StringIO(self.context.kubectl.run_capturing(*args))))
|
|
125
|
+
if len(res):
|
|
126
|
+
if len(res) > 1:
|
|
127
|
+
return res
|
|
128
|
+
return res[0]
|
|
129
|
+
return None
|
|
130
|
+
|
|
97
131
|
def test_kubectl(self):
|
|
98
|
-
version_out: str = self.
|
|
99
|
-
["version", "--client=true", "-o", "json"],
|
|
100
|
-
stderr_logger)
|
|
132
|
+
version_out: str = self.run_capturing("version", "--client=true", "-o", "json")
|
|
101
133
|
|
|
102
134
|
version_out_js = json.loads(version_out)
|
|
103
135
|
kubectl_version = version_out_js["clientVersion"]["gitVersion"][1:]
|
kubernator/plugins/minikube.py
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
# See the License for the specific language governing permissions and
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
#
|
|
18
|
-
|
|
18
|
+
import json
|
|
19
19
|
import logging
|
|
20
20
|
import os
|
|
21
21
|
import tempfile
|
|
@@ -91,7 +91,7 @@ class MinikubePlugin(KubernatorPlugin):
|
|
|
91
91
|
|
|
92
92
|
def register(self, minikube_version=None, profile="default", k8s_version=None,
|
|
93
93
|
keep_running=False, start_fresh=False,
|
|
94
|
-
nodes=1, driver=None, cpus="no-limit", extra_args=None):
|
|
94
|
+
nodes=1, driver=None, cpus="no-limit", extra_args=None, extra_addons=None):
|
|
95
95
|
context = self.context
|
|
96
96
|
|
|
97
97
|
context.app.register_plugin("kubeconfig")
|
|
@@ -166,12 +166,14 @@ class MinikubePlugin(KubernatorPlugin):
|
|
|
166
166
|
minikube_file=str(minikube_file),
|
|
167
167
|
profile=profile,
|
|
168
168
|
k8s_version=k8s_version,
|
|
169
|
+
k8s_version_tuple=k8s_version_tuple,
|
|
169
170
|
start_fresh=start_fresh,
|
|
170
171
|
keep_running=keep_running,
|
|
171
172
|
nodes=nodes,
|
|
172
173
|
driver=driver,
|
|
173
174
|
cpus=cpus,
|
|
174
175
|
extra_args=extra_args or [],
|
|
176
|
+
extra_addons=extra_addons or [],
|
|
175
177
|
kubeconfig=str(self.kubeconfig_dir / "config"),
|
|
176
178
|
cmd=self.cmd,
|
|
177
179
|
cmd_out=self.cmd_out
|
|
@@ -202,6 +204,16 @@ class MinikubePlugin(KubernatorPlugin):
|
|
|
202
204
|
"--wait", "apiserver",
|
|
203
205
|
"--nodes", str(minikube.nodes)]
|
|
204
206
|
|
|
207
|
+
addons = []
|
|
208
|
+
if minikube.k8s_version_tuple >= (1, 28):
|
|
209
|
+
addons += ["volumesnapshots", "csi-hostpath-driver"]
|
|
210
|
+
|
|
211
|
+
if minikube.extra_addons:
|
|
212
|
+
addons += minikube.extra_addons
|
|
213
|
+
|
|
214
|
+
if addons:
|
|
215
|
+
args += ["--addons", ",".join(addons)]
|
|
216
|
+
|
|
205
217
|
if minikube.driver == "docker":
|
|
206
218
|
args.extend(["--cpus", str(minikube.cpus)])
|
|
207
219
|
|
|
@@ -212,6 +224,24 @@ class MinikubePlugin(KubernatorPlugin):
|
|
|
212
224
|
logger.info("Updating minikube profile %r context", minikube.profile)
|
|
213
225
|
self.cmd("update-context")
|
|
214
226
|
|
|
227
|
+
if minikube.k8s_version_tuple >= (1, 28):
|
|
228
|
+
logger.info("Disabling old storage addons")
|
|
229
|
+
self.cmd("addons", "disable", "storage-provisioner")
|
|
230
|
+
self.cmd("addons", "disable", "default-storageclass")
|
|
231
|
+
|
|
232
|
+
logger.info("Running initialization scripts for profile %r", minikube.profile)
|
|
233
|
+
self.context.app.register_plugin("kubectl", version=minikube.k8s_version)
|
|
234
|
+
if minikube.k8s_version_tuple >= (1, 28):
|
|
235
|
+
storage_class = self.context.kubectl.get("storageclass", "csi-hostpath-sc")
|
|
236
|
+
self.context.kubectl.run("delete", "storageclass", "csi-hostpath-sc")
|
|
237
|
+
storage_class["metadata"]["annotations"]["storageclass.kubernetes.io/is-default-class"] = "true"
|
|
238
|
+
storage_class["volumeBindingMode"] = "WaitForFirstConsumer"
|
|
239
|
+
|
|
240
|
+
def write_stdin():
|
|
241
|
+
return json.dumps(storage_class)
|
|
242
|
+
|
|
243
|
+
self.context.kubectl.run("create", "-f", "-", stdin=write_stdin)
|
|
244
|
+
|
|
215
245
|
def minikube_stop(self):
|
|
216
246
|
minikube = self.context.minikube
|
|
217
247
|
if self.minikube_is_running():
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
kubernator/LICENSE,sha256=wKKdOCMTCPQRV5gDkVLAsXX8qSnRJ5owk7yWPO1KZNo,11387
|
|
2
|
-
kubernator/__init__.py,sha256=
|
|
2
|
+
kubernator/__init__.py,sha256=jOpQxAOrrl0lyLUkXRk6PqxxzgdZ65LU8QCBcYQthFc,915
|
|
3
3
|
kubernator/__main__.py,sha256=f0S60wgpLu--1UlOhzfWail-xt8zyIuODodX98_yPN0,707
|
|
4
4
|
kubernator/_json_path.py,sha256=pjQKXxgbpQWETYBIrIuJZHgugF92IbEAM19AC7JUmAQ,3162
|
|
5
5
|
kubernator/_k8s_client_patches.py,sha256=PEeWPInnW38NDyK7G24_Dmw-x7xHpN3vJWZeckdqgK0,76892
|
|
@@ -10,21 +10,22 @@ kubernator/proc.py,sha256=43jrpTe1FCdhDIK0b6hnB6XqU_m7iYu3wbzJyzO3pl0,5979
|
|
|
10
10
|
kubernator/plugins/__init__.py,sha256=h9TLYK8UFEi53ipZSZsTBjp0ljKhisWsgPpt_PkWrO8,670
|
|
11
11
|
kubernator/plugins/awscli.py,sha256=S6X7-qFiaZ7NDVDl2Jg0t-ih9KAJ45cUjjzd5Qe93ZM,4252
|
|
12
12
|
kubernator/plugins/eks.py,sha256=xe7vyPHNwuP8gEYDSzPyBkm-RkAtP64wCOqs9U5I7xI,2273
|
|
13
|
+
kubernator/plugins/gke.py,sha256=HZc-Bu2W8MvF50EgoAcZ8W-CAVEWJ4y8f4yG_3s8C1w,3429
|
|
13
14
|
kubernator/plugins/helm.py,sha256=2563hLr0uJucw0xo9JLfbCtpGPRZ5e5gYTnapQrqy3w,12036
|
|
14
|
-
kubernator/plugins/istio.py,sha256=
|
|
15
|
-
kubernator/plugins/k8s.py,sha256=
|
|
16
|
-
kubernator/plugins/k8s_api.py,sha256=
|
|
15
|
+
kubernator/plugins/istio.py,sha256=UFSBJo-I2x4F-ZO5WCSMpConOr_oYNZZb66DNOI_nME,15399
|
|
16
|
+
kubernator/plugins/k8s.py,sha256=A2qSOjkPasgBEc1Le2UXuSKTItd0Qz63E6Vv8WVQ0hQ,27307
|
|
17
|
+
kubernator/plugins/k8s_api.py,sha256=IkiegYwHJUasH5BlBxLo2_064cuzOGr3OJ1ToGy1p-s,27527
|
|
17
18
|
kubernator/plugins/kops.py,sha256=-yhpEjydz9E7Ep24WtEs93rLTXtw4yakdgVqXlIj1ww,9688
|
|
18
19
|
kubernator/plugins/kubeconfig.py,sha256=uwtHmF2I6LiTPrC3M88G5SfYxDWtuh0MqcMfrHHoNRA,2178
|
|
19
|
-
kubernator/plugins/kubectl.py,sha256=
|
|
20
|
-
kubernator/plugins/minikube.py,sha256=
|
|
20
|
+
kubernator/plugins/kubectl.py,sha256=hV6rnTj0XmQe5QJp3p6fNK3EQrWdNlam0qxsK3IkD5g,5125
|
|
21
|
+
kubernator/plugins/minikube.py,sha256=zbboER1VsCvIsh-yUE3_XpzPNcT4c6vh1LigDonEm3U,12384
|
|
21
22
|
kubernator/plugins/template.py,sha256=542nyS4ZNgdwJHEoIA5aLP1d4C312ydd7sPM9ZFbHuI,8357
|
|
22
23
|
kubernator/plugins/terraform.py,sha256=a1MPl9G8Rznjd28uMRdYWrjpFDLlFAVmLFH4hFEsMsQ,5285
|
|
23
24
|
kubernator/plugins/terragrunt.py,sha256=-qN8tTqPUXJ9O7CEiJVUB0GSUQU3DUTkv-aWdIIsm7Q,5051
|
|
24
|
-
kubernator-1.0.
|
|
25
|
-
kubernator-1.0.
|
|
26
|
-
kubernator-1.0.
|
|
27
|
-
kubernator-1.0.
|
|
28
|
-
kubernator-1.0.
|
|
29
|
-
kubernator-1.0.
|
|
30
|
-
kubernator-1.0.
|
|
25
|
+
kubernator-1.0.23.dist-info/METADATA,sha256=YW6ZY4aeqPYs-2EzsWTazp0PnC4LC6rj8ykZ7KB8sjc,10822
|
|
26
|
+
kubernator-1.0.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
27
|
+
kubernator-1.0.23.dist-info/entry_points.txt,sha256=IWDtHzyTleRqDSuVRXEr5GImrI7z_kh21t5DWZ8ldcQ,47
|
|
28
|
+
kubernator-1.0.23.dist-info/namespace_packages.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
29
|
+
kubernator-1.0.23.dist-info/top_level.txt,sha256=_z1CxWeKMI55ckf2vC8HqjbCn_E2Y_P5RdrhE_QWcIs,11
|
|
30
|
+
kubernator-1.0.23.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
31
|
+
kubernator-1.0.23.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|