kubernator 1.0.6.dev20231217165655__tar.gz → 1.0.6.dev20231219050913__tar.gz
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-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/PKG-INFO +1 -1
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/__init__.py +1 -1
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/app.py +26 -23
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/plugins/awscli.py +2 -2
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/plugins/eks.py +1 -1
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/plugins/helm.py +6 -6
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/plugins/istio.py +7 -7
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/plugins/kubectl.py +4 -4
- kubernator-1.0.6.dev20231219050913/kubernator/plugins/minikube.py +201 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/plugins/terraform.py +4 -4
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/plugins/terragrunt.py +4 -4
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/proc.py +4 -1
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator.egg-info/PKG-INFO +1 -1
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/setup.py +1 -1
- kubernator-1.0.6.dev20231217165655/kubernator/plugins/minikube.py +0 -101
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/MANIFEST.in +0 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/LICENSE +0 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/__main__.py +0 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/api.py +0 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/plugins/__init__.py +0 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/plugins/k8s.py +0 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/plugins/k8s_api.py +0 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/plugins/kops.py +0 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/plugins/kubeconfig.py +0 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/plugins/template.py +0 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator.egg-info/SOURCES.txt +0 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator.egg-info/dependency_links.txt +0 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator.egg-info/entry_points.txt +0 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator.egg-info/namespace_packages.txt +0 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator.egg-info/requires.txt +0 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator.egg-info/top_level.txt +0 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator.egg-info/zip-safe +0 -0
- {kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: kubernator
|
|
3
|
-
Version: 1.0.6.
|
|
3
|
+
Version: 1.0.6.dev20231219050913
|
|
4
4
|
Summary: Kubernator is the a pluggable framework for K8S provisioning
|
|
5
5
|
Home-page: https://github.com/karellen/kubernator
|
|
6
6
|
Author: Express Systems USA, Inc.
|
|
@@ -166,40 +166,43 @@ class App(KubernatorPlugin):
|
|
|
166
166
|
|
|
167
167
|
self.register_plugin(self)
|
|
168
168
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
169
|
+
try:
|
|
170
|
+
while True:
|
|
171
|
+
cwd = self.next()
|
|
172
|
+
if not cwd:
|
|
173
|
+
logger.debug("No paths left to traverse")
|
|
174
|
+
break
|
|
174
175
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
logger.debug("Inspecting directory %s", self._display_path(cwd))
|
|
178
|
-
self._run_handlers(KubernatorPlugin.handle_before_dir, False, context, None, cwd)
|
|
176
|
+
context = self.context
|
|
179
177
|
|
|
180
|
-
|
|
181
|
-
self._run_handlers(KubernatorPlugin.
|
|
178
|
+
logger.debug("Inspecting directory %s", self._display_path(cwd))
|
|
179
|
+
self._run_handlers(KubernatorPlugin.handle_before_dir, False, context, None, cwd)
|
|
182
180
|
|
|
183
|
-
|
|
184
|
-
|
|
181
|
+
if (ktor_py := (cwd / ".kubernator.py")).exists():
|
|
182
|
+
self._run_handlers(KubernatorPlugin.handle_before_script, False, context, None, cwd)
|
|
185
183
|
|
|
186
|
-
|
|
184
|
+
for h in self.context._plugins:
|
|
185
|
+
h.set_context(context)
|
|
187
186
|
|
|
188
|
-
|
|
189
|
-
h.set_context(None)
|
|
187
|
+
self._exec_ktor(ktor_py)
|
|
190
188
|
|
|
191
|
-
|
|
189
|
+
for h in self.context._plugins:
|
|
190
|
+
h.set_context(None)
|
|
192
191
|
|
|
193
|
-
|
|
192
|
+
self._run_handlers(KubernatorPlugin.handle_after_script, True, context, None, cwd)
|
|
194
193
|
|
|
195
|
-
|
|
196
|
-
context = self.context
|
|
194
|
+
self._run_handlers(KubernatorPlugin.handle_after_dir, True, context, None, cwd)
|
|
197
195
|
|
|
198
|
-
|
|
196
|
+
self.context = self._top_dir_context
|
|
197
|
+
context = self.context
|
|
199
198
|
|
|
200
|
-
|
|
199
|
+
self._run_handlers(KubernatorPlugin.handle_apply, True, context, None)
|
|
201
200
|
|
|
202
|
-
|
|
201
|
+
self._run_handlers(KubernatorPlugin.handle_verify, True, context, None)
|
|
202
|
+
finally:
|
|
203
|
+
self.context = self._top_dir_context
|
|
204
|
+
context = self.context
|
|
205
|
+
self._run_handlers(KubernatorPlugin.handle_shutdown, True, context, None)
|
|
203
206
|
|
|
204
207
|
def discover_plugins(self):
|
|
205
208
|
importlib.invalidate_caches()
|
|
@@ -54,7 +54,7 @@ class AwsCliPlugin(KubernatorPlugin):
|
|
|
54
54
|
def set_context(self, context):
|
|
55
55
|
self.context = context
|
|
56
56
|
|
|
57
|
-
def
|
|
57
|
+
def stanza(self, *args, output="json", region=None):
|
|
58
58
|
context = self.context
|
|
59
59
|
stanza = [context.awscli.aws_file, "--output", output]
|
|
60
60
|
if region:
|
|
@@ -112,7 +112,7 @@ class AwsCliPlugin(KubernatorPlugin):
|
|
|
112
112
|
|
|
113
113
|
context.globals.awscli = dict(version=version,
|
|
114
114
|
aws_file=self.aws_file,
|
|
115
|
-
|
|
115
|
+
stanza=self.stanza
|
|
116
116
|
)
|
|
117
117
|
|
|
118
118
|
def __repr__(self):
|
{kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/plugins/eks.py
RENAMED
|
@@ -64,7 +64,7 @@ class EksPlugin(KubernatorPlugin):
|
|
|
64
64
|
def handle_init(self):
|
|
65
65
|
context = self.context
|
|
66
66
|
|
|
67
|
-
self.context.app.run(context.awscli.
|
|
67
|
+
self.context.app.run(context.awscli.stanza(
|
|
68
68
|
"eks", "update-kubeconfig", "--name", self.name, "--kubeconfig", context.eks.kubeconfig,
|
|
69
69
|
region=self.region),
|
|
70
70
|
stdout_logger,
|
{kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/plugins/helm.py
RENAMED
|
@@ -106,7 +106,7 @@ class HelmPlugin(KubernatorPlugin):
|
|
|
106
106
|
def set_context(self, context):
|
|
107
107
|
self.context = context
|
|
108
108
|
|
|
109
|
-
def
|
|
109
|
+
def stanza(self):
|
|
110
110
|
context = self.context
|
|
111
111
|
stanza = [context.helm.helm_file, f"--kubeconfig={context.kubeconfig.kubeconfig}"]
|
|
112
112
|
if logger.getEffectiveLevel() < logging.INFO:
|
|
@@ -145,13 +145,13 @@ class HelmPlugin(KubernatorPlugin):
|
|
|
145
145
|
default_excludes=Globs([".*"], True),
|
|
146
146
|
namespace_transformer=True,
|
|
147
147
|
helm_file=helm_file,
|
|
148
|
-
|
|
148
|
+
stanza=self.stanza,
|
|
149
149
|
add_helm_template=self.add_helm_template,
|
|
150
150
|
add_helm=self.add_helm,
|
|
151
151
|
)
|
|
152
152
|
|
|
153
153
|
def handle_init(self):
|
|
154
|
-
version = self.context.app.run_capturing_out(self.
|
|
154
|
+
version = self.context.app.run_capturing_out(self.stanza() + ["version", "--template", "{{.Version}}"],
|
|
155
155
|
logger.error)
|
|
156
156
|
logger.info("Found Helm version %s", version)
|
|
157
157
|
|
|
@@ -204,10 +204,10 @@ class HelmPlugin(KubernatorPlugin):
|
|
|
204
204
|
logger.debug("Repository %s mapping to %s", repository, repository_hash)
|
|
205
205
|
if repository_hash not in self.repositories:
|
|
206
206
|
logger.info("Adding and updating repository %s mapping to %s", repository, repository_hash)
|
|
207
|
-
self.context.app.run(self.
|
|
207
|
+
self.context.app.run(self.stanza() + ["repo", "add", repository_hash, repository],
|
|
208
208
|
stdout_logger,
|
|
209
209
|
stderr_logger).wait()
|
|
210
|
-
self.context.app.run(self.
|
|
210
|
+
self.context.app.run(self.stanza() + ["repo", "update"],
|
|
211
211
|
stdout_logger,
|
|
212
212
|
stderr_logger).wait()
|
|
213
213
|
self.repositories.add(repository_hash)
|
|
@@ -233,7 +233,7 @@ class HelmPlugin(KubernatorPlugin):
|
|
|
233
233
|
|
|
234
234
|
stdin = write_stdin
|
|
235
235
|
|
|
236
|
-
resources = self.context.app.run_capturing_out(self.
|
|
236
|
+
resources = self.context.app.run_capturing_out(self.stanza() +
|
|
237
237
|
["template",
|
|
238
238
|
name,
|
|
239
239
|
f"{repository_hash}/{chart}",
|
|
@@ -90,19 +90,19 @@ class IstioPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
90
90
|
default_includes=Globs(["*.istio.yaml", "*.istio.yml"], True),
|
|
91
91
|
default_excludes=Globs([".*"], True),
|
|
92
92
|
istioctl_file=istioctl_file,
|
|
93
|
-
|
|
93
|
+
stanza=self.stanza,
|
|
94
94
|
test=self.test_istioctl
|
|
95
95
|
)
|
|
96
96
|
|
|
97
97
|
def test_istioctl(self):
|
|
98
98
|
context = self.context
|
|
99
|
-
version_out: str = context.app.run_capturing_out(context.istio.
|
|
99
|
+
version_out: str = context.app.run_capturing_out(context.istio.stanza() + ["version", "-o", "json"],
|
|
100
100
|
stderr_logger)
|
|
101
101
|
|
|
102
102
|
version_out_js = json.loads(version_out)
|
|
103
103
|
version = version_out_js["clientVersion"]["version"]
|
|
104
104
|
logger.info("Using istioctl %r version %r with stanza %r",
|
|
105
|
-
self.context.istio.istioctl_file, version, context.istio.
|
|
105
|
+
self.context.istio.istioctl_file, version, context.istio.stanza())
|
|
106
106
|
|
|
107
107
|
logger.info("Found Istio client version %s", version)
|
|
108
108
|
|
|
@@ -111,7 +111,7 @@ class IstioPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
111
111
|
def set_context(self, context):
|
|
112
112
|
self.context = context
|
|
113
113
|
|
|
114
|
-
def
|
|
114
|
+
def stanza(self):
|
|
115
115
|
context = self.context.istio
|
|
116
116
|
return [context.istioctl_file, f"--kubeconfig={self.context.kubeconfig.kubeconfig}"]
|
|
117
117
|
|
|
@@ -189,9 +189,9 @@ class IstioPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
189
189
|
|
|
190
190
|
if context.app.args.command == "apply":
|
|
191
191
|
logger.info("Running Istio precheck")
|
|
192
|
-
context.app.run(context.istio.
|
|
192
|
+
context.app.run(context.istio.stanza() + ["x", "precheck"],
|
|
193
193
|
stdout_logger, stderr_logger).wait()
|
|
194
|
-
context.app.run(context.istio.
|
|
194
|
+
context.app.run(context.istio.stanza() + ["validate", "-f", operators_file.name],
|
|
195
195
|
stdout_logger, stderr_logger).wait()
|
|
196
196
|
|
|
197
197
|
self._operator_init(operators_file, True)
|
|
@@ -230,7 +230,7 @@ class IstioPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
230
230
|
raise
|
|
231
231
|
|
|
232
232
|
logger.info("Running Istio operator init%s", status_details)
|
|
233
|
-
istio_operator_init = context.istio.
|
|
233
|
+
istio_operator_init = context.istio.stanza() + ["operator", "init", "-f", operators_file.name]
|
|
234
234
|
context.app.run(istio_operator_init + (["--dry-run"] if dry_run else []),
|
|
235
235
|
stdout_logger,
|
|
236
236
|
stderr_logger).wait()
|
|
@@ -49,7 +49,7 @@ class KubectlPlugin(KubernatorPlugin):
|
|
|
49
49
|
def set_context(self, context):
|
|
50
50
|
self.context = context
|
|
51
51
|
|
|
52
|
-
def
|
|
52
|
+
def stanza(self):
|
|
53
53
|
context = self.context.kubectl
|
|
54
54
|
return [context.kubectl_file, f"--kubeconfig={context.kubeconfig}"]
|
|
55
55
|
|
|
@@ -85,14 +85,14 @@ class KubectlPlugin(KubernatorPlugin):
|
|
|
85
85
|
context.globals.kubectl = dict(version=version,
|
|
86
86
|
kubeconfig=kubeconfig,
|
|
87
87
|
kubectl_file=kubectl_file,
|
|
88
|
-
|
|
88
|
+
stanza=self.stanza,
|
|
89
89
|
test=self.test_kubectl
|
|
90
90
|
)
|
|
91
91
|
|
|
92
92
|
context.globals.kubectl.version = context.kubectl.test()
|
|
93
93
|
|
|
94
94
|
def test_kubectl(self):
|
|
95
|
-
version_out: str = self.context.app.run_capturing_out(self.
|
|
95
|
+
version_out: str = self.context.app.run_capturing_out(self.stanza() +
|
|
96
96
|
["version", "--client=true", "-o", "json"],
|
|
97
97
|
stderr_logger)
|
|
98
98
|
|
|
@@ -100,7 +100,7 @@ class KubectlPlugin(KubernatorPlugin):
|
|
|
100
100
|
kubectl_version = version_out_js["clientVersion"]["gitVersion"][1:]
|
|
101
101
|
|
|
102
102
|
logger.info("Using kubectl %r version %r with stanza %r",
|
|
103
|
-
self.context.kubectl.kubectl_file, kubectl_version, self.
|
|
103
|
+
self.context.kubectl.kubectl_file, kubectl_version, self.stanza())
|
|
104
104
|
|
|
105
105
|
return kubectl_version
|
|
106
106
|
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright 2020 Express Systems USA, Inc
|
|
4
|
+
# Copyright 2023 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
|
+
|
|
24
|
+
from kubernator.api import (KubernatorPlugin,
|
|
25
|
+
StripNL,
|
|
26
|
+
get_golang_os,
|
|
27
|
+
get_golang_machine,
|
|
28
|
+
prepend_os_path,
|
|
29
|
+
get_cache_dir,
|
|
30
|
+
CalledProcessError
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
logger = logging.getLogger("kubernator.minikube")
|
|
34
|
+
proc_logger = logger.getChild("proc")
|
|
35
|
+
stdout_logger = StripNL(proc_logger.info)
|
|
36
|
+
stderr_logger = StripNL(proc_logger.warning)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class MinikubePlugin(KubernatorPlugin):
|
|
40
|
+
logger = logger
|
|
41
|
+
|
|
42
|
+
_name = "minikube"
|
|
43
|
+
|
|
44
|
+
def __init__(self):
|
|
45
|
+
self.context = None
|
|
46
|
+
self.minikube_dir = None
|
|
47
|
+
self.minikube_home_dir = None
|
|
48
|
+
self.kubeconfig_dir = None
|
|
49
|
+
|
|
50
|
+
super().__init__()
|
|
51
|
+
|
|
52
|
+
def set_context(self, context):
|
|
53
|
+
self.context = context
|
|
54
|
+
|
|
55
|
+
def get_latest_minikube_version(self):
|
|
56
|
+
context = self.context
|
|
57
|
+
versions = context.app.run_capturing_out(["git", "ls-remote", "-t", "--refs",
|
|
58
|
+
"https://github.com/kubernetes/minikube", "v*"],
|
|
59
|
+
stderr_logger)
|
|
60
|
+
|
|
61
|
+
# 06e3b0cf7999f74fc52af362b42fb21076ade64a refs/tags/v1.9.1
|
|
62
|
+
# "refs/tags/v1.9.1"
|
|
63
|
+
# "1.9.1"
|
|
64
|
+
# ("1","9","1")
|
|
65
|
+
# (1, 9, 1)
|
|
66
|
+
# sort and get latest, which is the last/highest
|
|
67
|
+
# "v1.9.1"
|
|
68
|
+
return (".".join(map(str, sorted(list(map(lambda v: tuple(map(int, v)),
|
|
69
|
+
filter(lambda v: len(v) == 3,
|
|
70
|
+
map(lambda line: line.split()[1][11:].split("."),
|
|
71
|
+
versions.splitlines(False))))))[-1])))
|
|
72
|
+
|
|
73
|
+
def cmd(self, *extra_args):
|
|
74
|
+
stanza, env = self._stanza(list(extra_args))
|
|
75
|
+
return self.context.app.run(stanza, stdout_logger, stderr_logger, env=env).wait()
|
|
76
|
+
|
|
77
|
+
def cmd_out(self, *extra_args):
|
|
78
|
+
stanza, env = self._stanza(list(extra_args))
|
|
79
|
+
return self.context.app.run_capturing_out(stanza, stderr_logger, env=env)
|
|
80
|
+
|
|
81
|
+
def _stanza(self, extra_args):
|
|
82
|
+
context = self.context
|
|
83
|
+
minikube = context.minikube
|
|
84
|
+
stanza = [context.minikube.minikube_file, "-p", f"minikube-{minikube.profile}"] + extra_args
|
|
85
|
+
env = dict(os.environ)
|
|
86
|
+
env["MINIKUBE_HOME"] = str(self.minikube_home_dir)
|
|
87
|
+
env["KUBECONFIG"] = str(minikube.kubeconfig)
|
|
88
|
+
return stanza, env
|
|
89
|
+
|
|
90
|
+
def register(self, minikube_version=None, profile="default", k8s_version=None,
|
|
91
|
+
keep_running=False, start_fresh=False,
|
|
92
|
+
nodes=1, driver="docker", cpus="no-limit", extra_args=None):
|
|
93
|
+
context = self.context
|
|
94
|
+
|
|
95
|
+
context.app.register_plugin("kubeconfig")
|
|
96
|
+
|
|
97
|
+
if not k8s_version:
|
|
98
|
+
msg = "No Kubernetes version is specified for Minikube"
|
|
99
|
+
logger.critical(msg)
|
|
100
|
+
raise RuntimeError(msg)
|
|
101
|
+
|
|
102
|
+
if not minikube_version:
|
|
103
|
+
minikube_version = self.get_latest_minikube_version()
|
|
104
|
+
logger.info("No minikube version is specified, latest is %s", minikube_version)
|
|
105
|
+
|
|
106
|
+
minikube_dl_file, _ = context.app.download_remote_file(logger,
|
|
107
|
+
f"https://github.com/kubernetes/minikube/releases"
|
|
108
|
+
f"/download/v{minikube_version}/"
|
|
109
|
+
f"minikube-{get_golang_os()}-{get_golang_machine()}",
|
|
110
|
+
"bin")
|
|
111
|
+
|
|
112
|
+
os.chmod(minikube_dl_file, 0o500)
|
|
113
|
+
self.minikube_dir = tempfile.TemporaryDirectory()
|
|
114
|
+
minikube_file = Path(self.minikube_dir.name) / "minikube"
|
|
115
|
+
minikube_file.symlink_to(minikube_dl_file)
|
|
116
|
+
prepend_os_path(self.minikube_dir.name)
|
|
117
|
+
version_out: str = self.context.app.run_capturing_out([minikube_file, "version", "--short"],
|
|
118
|
+
stderr_logger).strip()
|
|
119
|
+
version = version_out[1:]
|
|
120
|
+
logger.info("Found minikube %s in %s", version, minikube_file)
|
|
121
|
+
|
|
122
|
+
profile_dir = get_cache_dir("minikube", profile)
|
|
123
|
+
self.minikube_home_dir = profile_dir / "home"
|
|
124
|
+
self.minikube_home_dir.mkdir(parents=True, exist_ok=True)
|
|
125
|
+
self.kubeconfig_dir = profile_dir / ".kube"
|
|
126
|
+
self.kubeconfig_dir.mkdir(parents=True, exist_ok=True)
|
|
127
|
+
|
|
128
|
+
context.globals.minikube = dict(version=version,
|
|
129
|
+
minikube_file=str(minikube_file),
|
|
130
|
+
profile=profile,
|
|
131
|
+
k8s_version=k8s_version,
|
|
132
|
+
start_fresh=start_fresh,
|
|
133
|
+
keep_running=keep_running,
|
|
134
|
+
nodes=nodes,
|
|
135
|
+
driver=driver,
|
|
136
|
+
cpus=cpus,
|
|
137
|
+
extra_args=extra_args or [],
|
|
138
|
+
kubeconfig=str(self.kubeconfig_dir / "config"),
|
|
139
|
+
cmd=self.cmd,
|
|
140
|
+
cmd_out=self.cmd_out
|
|
141
|
+
)
|
|
142
|
+
context.kubeconfig.kubeconfig = context.minikube.kubeconfig
|
|
143
|
+
|
|
144
|
+
logger.info("Minikube Home is %s", self.minikube_home_dir)
|
|
145
|
+
logger.info("Minikube Kubeconfig is %s", context.minikube.kubeconfig)
|
|
146
|
+
|
|
147
|
+
def minikube_is_running(self):
|
|
148
|
+
try:
|
|
149
|
+
out = self.cmd_out("status", "-o", "json")
|
|
150
|
+
logger.info("Minikube profile %r is running: %s", self.context.minikube.profile,
|
|
151
|
+
out.strip())
|
|
152
|
+
return True
|
|
153
|
+
except CalledProcessError as e:
|
|
154
|
+
logger.info("Minikube profile %r is not running: %s", self.context.minikube.profile,
|
|
155
|
+
e.output.strip())
|
|
156
|
+
return False
|
|
157
|
+
|
|
158
|
+
def minikube_start(self):
|
|
159
|
+
minikube = self.context.minikube
|
|
160
|
+
if not self.minikube_is_running():
|
|
161
|
+
logger.info("Starting minikube profile %r...", minikube.profile)
|
|
162
|
+
self.cmd("start",
|
|
163
|
+
"--driver", str(minikube.driver),
|
|
164
|
+
"--nodes", str(minikube.nodes),
|
|
165
|
+
"--cpus", str(minikube.cpus),
|
|
166
|
+
"--kubernetes-version", str(minikube.k8s_version),
|
|
167
|
+
"--wait", "apiserver")
|
|
168
|
+
else:
|
|
169
|
+
logger.warning("Minikube profile %r is already running!", minikube.profile)
|
|
170
|
+
|
|
171
|
+
logger.info("Updating minikube profile %r context", minikube.profile)
|
|
172
|
+
self.cmd("update-context")
|
|
173
|
+
|
|
174
|
+
def minikube_stop(self):
|
|
175
|
+
minikube = self.context.minikube
|
|
176
|
+
if self.minikube_is_running():
|
|
177
|
+
logger.info("Shutting down minikube profile %r...", minikube.profile)
|
|
178
|
+
self.cmd("stop", "-o", "json")
|
|
179
|
+
|
|
180
|
+
def minikube_delete(self):
|
|
181
|
+
minikube = self.context.minikube
|
|
182
|
+
self.minikube_stop()
|
|
183
|
+
logger.warning("Deleting minikube profile %r!", minikube.profile)
|
|
184
|
+
self.cmd("delete")
|
|
185
|
+
|
|
186
|
+
def handle_start(self):
|
|
187
|
+
minikube = self.context.minikube
|
|
188
|
+
if minikube.start_fresh:
|
|
189
|
+
self.minikube_delete()
|
|
190
|
+
|
|
191
|
+
self.minikube_start()
|
|
192
|
+
|
|
193
|
+
def handle_shutdown(self):
|
|
194
|
+
minikube = self.context.minikube
|
|
195
|
+
if not minikube.keep_running:
|
|
196
|
+
self.minikube_stop()
|
|
197
|
+
else:
|
|
198
|
+
logger.warning("Will keep minikube profile %s running!", minikube.profile)
|
|
199
|
+
|
|
200
|
+
def __repr__(self):
|
|
201
|
+
return "Minikube Plugin"
|
|
@@ -51,7 +51,7 @@ class TerraformPlugin(KubernatorPlugin):
|
|
|
51
51
|
def set_context(self, context):
|
|
52
52
|
self.context = context
|
|
53
53
|
|
|
54
|
-
def
|
|
54
|
+
def stanza(self):
|
|
55
55
|
return [self.tf_file]
|
|
56
56
|
|
|
57
57
|
def register(self, version=None):
|
|
@@ -95,7 +95,7 @@ class TerraformPlugin(KubernatorPlugin):
|
|
|
95
95
|
|
|
96
96
|
context.globals.terraform = dict(version=version,
|
|
97
97
|
tf_file=self.tf_file,
|
|
98
|
-
|
|
98
|
+
stanza=self.stanza,
|
|
99
99
|
)
|
|
100
100
|
|
|
101
101
|
logger.info("Found Terraform version %s at %s", version, self.tf_file)
|
|
@@ -127,10 +127,10 @@ class TerraformPlugin(KubernatorPlugin):
|
|
|
127
127
|
if not tf_detected:
|
|
128
128
|
return
|
|
129
129
|
|
|
130
|
-
context.app.run(self.
|
|
130
|
+
context.app.run(self.stanza() + ["init", "-reconfigure", "-input=false", "-upgrade=false"],
|
|
131
131
|
stdout_logger, stderr_logger, cwd=cwd).wait()
|
|
132
132
|
|
|
133
|
-
output = json.loads(context.app.run_capturing_out(self.
|
|
133
|
+
output = json.loads(context.app.run_capturing_out(self.stanza() + ["output", "-json"],
|
|
134
134
|
stderr_logger, cwd=cwd))
|
|
135
135
|
if not output:
|
|
136
136
|
raise RuntimeError("Terraform output produced no values. Please check if Terraform is functioning.")
|
|
@@ -49,7 +49,7 @@ class TerragruntPlugin(KubernatorPlugin):
|
|
|
49
49
|
def set_context(self, context):
|
|
50
50
|
self.context = context
|
|
51
51
|
|
|
52
|
-
def
|
|
52
|
+
def stanza(self):
|
|
53
53
|
return [self.tg_file]
|
|
54
54
|
|
|
55
55
|
def register(self, version=None):
|
|
@@ -81,7 +81,7 @@ class TerragruntPlugin(KubernatorPlugin):
|
|
|
81
81
|
version = version_out.split(" ")[-1][1:].strip()
|
|
82
82
|
context.globals.terragrunt = dict(version=version,
|
|
83
83
|
tg_file=self.tg_file,
|
|
84
|
-
|
|
84
|
+
stanza=self.stanza,
|
|
85
85
|
)
|
|
86
86
|
|
|
87
87
|
logger.info("Found Terragrunt version %s at %s", version, self.tg_file)
|
|
@@ -113,10 +113,10 @@ class TerragruntPlugin(KubernatorPlugin):
|
|
|
113
113
|
if not tg_detected:
|
|
114
114
|
return
|
|
115
115
|
|
|
116
|
-
context.app.run(self.
|
|
116
|
+
context.app.run(self.stanza() + ["run-all", "init", "-reconfigure", "-input=false", "-upgrade=false"],
|
|
117
117
|
stdout_logger, stderr_logger, cwd=cwd).wait()
|
|
118
118
|
|
|
119
|
-
output_json = context.app.run_capturing_out(self.
|
|
119
|
+
output_json = context.app.run_capturing_out(self.stanza() + ["run-all", "output", "-json"],
|
|
120
120
|
stderr_logger, cwd=cwd)
|
|
121
121
|
|
|
122
122
|
json_decoder = json.JSONDecoder()
|
{kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/proc.py
RENAMED
|
@@ -70,13 +70,16 @@ class ProcessRunner:
|
|
|
70
70
|
safe_args=None, universal_newlines=True, **kwargs):
|
|
71
71
|
self._safe_args = safe_args or args
|
|
72
72
|
logger.trace("Starting %r", self._safe_args)
|
|
73
|
+
|
|
74
|
+
if "env" not in kwargs:
|
|
75
|
+
kwargs["env"] = os.environ
|
|
76
|
+
|
|
73
77
|
self._proc = Popen(args,
|
|
74
78
|
stdout=PIPE if isinstance(stdout, Callable) else (stdout if stdout is not None else DEVNULL),
|
|
75
79
|
stderr=PIPE if isinstance(stderr, Callable) else (stderr if stderr is not None else DEVNULL),
|
|
76
80
|
stdin=PIPE if isinstance(stdin, (Callable, bytes, str)) else
|
|
77
81
|
(stdin if stdin is not None else DEVNULL),
|
|
78
82
|
universal_newlines=universal_newlines,
|
|
79
|
-
env=os.environ if "env" not in kwargs else kwargs["env"],
|
|
80
83
|
**kwargs)
|
|
81
84
|
|
|
82
85
|
self._stdin_writer = (spawn(partial(stream_writer_text if universal_newlines else stream_writer_buf,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: kubernator
|
|
3
|
-
Version: 1.0.6.
|
|
3
|
+
Version: 1.0.6.dev20231219050913
|
|
4
4
|
Summary: Kubernator is the a pluggable framework for K8S provisioning
|
|
5
5
|
Home-page: https://github.com/karellen/kubernator
|
|
6
6
|
Author: Express Systems USA, Inc.
|
|
@@ -21,7 +21,7 @@ class install(_install):
|
|
|
21
21
|
if __name__ == '__main__':
|
|
22
22
|
setup(
|
|
23
23
|
name = 'kubernator',
|
|
24
|
-
version = '1.0.6.
|
|
24
|
+
version = '1.0.6.dev20231219050913',
|
|
25
25
|
description = 'Kubernator is the a pluggable framework for K8S provisioning',
|
|
26
26
|
long_description = '# Kubernator\n\nKubernator™ (Ktor™) is an integrated solution for the Kubernetes state management. It operates on directories,\nprocessing their content via a collection of plugins, generating Kubernetes resources in the process, validating them,\ntransforming them and then applying against the Kubernetes cluster.\n\n[](https://gitter.im/karellen/Lobby)\n[](https://github.com/karellen/kubernator/actions/workflows/kubernator.yml)\n[](https://coveralls.io/r/karellen/kubernator?branch=master)\n\n[](https://pypi.org/project/kubernator/)\n[](https://pypi.org/project/kubernator/)\n[](https://pypi.org/project/kubernator/)\n[](https://pypi.org/project/kubernator/)\n[](https://pypi.org/project/kubernator/)\n\n## Notices\n\n### Beta Software\n\nWhile fully functional in the current state and used in production, this software is in **BETA**. A lot of things\nare expected to change rapidly, including main APIs, initialization procedures and some core features. Documentation at\nthis stage is basically non-existent.\n\n### License\n\nThe product is licensed under the Apache License, Version 2.0. Please see LICENSE for further details.\n\n### Warranties and Liability\n\nKubernator and its plugins are provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\nexpress or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,\nMERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of\nusing or redistributing Kubernator and assume any risks associated with doing so.\n\n### Trademarks\n\n"Kubernator" and "Ktor" are trademarks or registered trademarks of Express Systems USA, Inc and Karellen, Inc. All other\ntrademarks are property of their respective owners.\n\n## Problem Statement\n\n## Solution\n\n## Using Kubernator with Docker\n\nA simple example is as follows:\n```\n$ docker run --mount type=bind,source="$(pwd)",target=/root,readonly -t ghcr.io/karellen/kubernator:latest\n```\n\nPlease note, that some plugins (e.g. `awscli`, `eks`) may require additional volume mounts or environmental\nvariables to be passed for credentials and other external configuration.\n\n## Mode of Operation\n\nKubernator is a command line utility. Upon startup and processing of the command line arguments and initializing\nlogging, Kubernator initializes plugins. Current plugins include:\n\n0. Kubernator App\n1. Terraform\n2. kOps\n3. Kubernetes\n4. Helm\n5. Template\n\nThe order of initialization matters as it\'s the order the plugin handlers are executed!\n\nThe entire application operates in the following stages by invoking each plugin\'s stage handler in sequence:\n\n1. Plugin Init Stage\n2. Pre-start script (if specified)\n3. Plugin Start Stage\n4. For each directory in the pipeline:\n 1. Plugin Before Directory Stage\n 2. If `.kubernator.py` is present in the directory:\n 1. Plugin Before Script Stage\n 2. `.kubernator.py` script\n 3. Plugin After Script Stage\n 3. Plugin After Directory Stage\n5. Plugin End Stage\n\nEach plugin individually plays a specific role and performs a specific function which will be described in a later\nsection.\n\n## State/Context\n\nThere is a global state that is carried through as the application is running. It is a hierarchy of objects (`context`)\nthat follows the parent-child relationship as the application traverses the directory structure. For example, given the\ndirectory structure `/a/b`, `/a/c`, and `/a/c/d` any value of the context set or modified in context scoped to\ndirectory `/a` is visible in directories `/a/b`, `/a/c` and `/a/c/d`, while the same modified or set in `/a/b` is only\nvisible there, while one in `/a/c` is visible in `/a/c` and in `/a/c/d` but not `/a` or `/a/b`.\n\nAdditionally, there is a `context.globals` which is the top-most context that is available in all stages that are not\nassociated with the directory structure.\n\nNote, that in cases where the directory structure traversal moves to remote directories (that are actualized by local\ntemporary directories), such remote directory structure enters the context hierarchy as a child of the directory in\nwhich remote was registered.\n\nAlso note, that context carries not just data by references to essential functions.\n\nIn pre-start and `.kubernator.py` scripts the context is fully available as a global variable `ktor`.\n\n### Plugins\n\n#### Kubernator App Plugin\n\nThe role of the Kubernator App Plugin is to traverse the directory structure, expose essential functions through context\nand to run Kubernator scripts.\n\nIn the *After Directory Stage* Kubernator app scans the directories immediately available in the current, sorts them in\nthe alphabetic order, excludes those matching any of the patterns in `context.app.excludes` and then queues up the\nremaining directories in the order the match the patterns in `context.app.includes`.\n\nThus, for a directory content `/a/foo`, `/a/bal`, `/a/bar`, `/a/baz`, excludes `f*`, and includes `baz` and `*`, the\nresulting queue of directories to traverse will be `/a/baz`, `/a/bal`, `/a/bar`.\n\nNotice, that user can further interfere with processing order of the directory queue by asking Kubernator to walk\narbitrary paths, both local and remote.\n\n##### Context\n\n* `ktor.app.args`\n > Namespace containing command line argument values\n* `ktor.app.walk_local(*paths: Union[Path, str, bytes])`\n > Immediately schedules the paths to be traversed after the current directory by adding them to the queue\n > Relative path is relative to the current directory\n* `ktor.app.walk_remote(repo, *path_prefixes: Union[Path, str, bytes])`\n > Immediately schedules the path prefixes under the remote repo URL to be traversed after the current directory by\n > adding them to the queue. Only Git URLs are currently supported.\n > All absolute path prefixes are relativized based on the repository.\n* `ktor.app.repository_credentials_provider(func: Callable)`\n > Sets a repository credentials provider function `func` that sets/overwrites credentials for URLs being specified by\n > `walk_remote`. The callable `func` accepts a single argument containing a parsed URL in a form of tuple. The `func`\n > is expected to return a tuple of three elements representing URL schema, username and password. If the value should\n > not be changed it should be None. To convert from `git://repo.com/hello` to HTTPS authentication one should write\n > a function returning `("https", "username", "password")`. The best utility is achieved by logic that allows running\n > the plan both in CI and local environments using different authentication mechanics in different environments.\n\n#### Terraform\n\nThis is exclusively designed to pull the configuration options out of Terraform and to allow scripts and plugins to\nutilize that data.\n\n##### Context\n\n* `ktor.tf`\n > A dictionary containing the values from Terraform output\n\n#### Kops\n\n##### Context\n\n#### Kubernetes\n\n##### Context\n\n#### Helm\n\n##### Context\n\n#### Templates\n\n##### Context\n\n## Examples\n\n### Adding Remote Directory\n\n```python\nktor.app.repository_credentials_provider(lambda r: ("ssh", "git", None))\nktor.app.walk_remote("git://repo.example.com/org/project?ref=dev", "/project")\n```\n\n### Adding Local Directory\n\n```python\nktor.app.walk_local("/home/username/local-dir")\n```\n\n### Using Transformers\n\n```python\ndef remove_replicas(resources, r: "K8SResource"):\n if (r.group == "apps" and r.kind in ("StatefulSet", "Deployment")\n and "replicas" in r.manifest["spec"]):\n logger.warning("Resource %s in %s contains `replica` specification that will be removed. Use HPA!!!",\n r, r.source)\n del r.manifest["spec"]["replicas"]\n\n\nktor.k8s.add_transformer(remove_replicas)\n```\n',
|
|
27
27
|
long_description_content_type = 'text/markdown',
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Copyright 2020 Express Systems USA, Inc
|
|
4
|
-
# Copyright 2023 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
|
-
|
|
22
|
-
from kubernator.api import (KubernatorPlugin,
|
|
23
|
-
StripNL,
|
|
24
|
-
get_golang_os,
|
|
25
|
-
get_golang_machine
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
logger = logging.getLogger("kubernator.minikube")
|
|
29
|
-
proc_logger = logger.getChild("proc")
|
|
30
|
-
stdout_logger = StripNL(proc_logger.info)
|
|
31
|
-
stderr_logger = StripNL(proc_logger.warning)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class MinikubePlugin(KubernatorPlugin):
|
|
35
|
-
logger = logger
|
|
36
|
-
|
|
37
|
-
_name = "minikube"
|
|
38
|
-
|
|
39
|
-
def __init__(self):
|
|
40
|
-
self.context = None
|
|
41
|
-
self.minikube_home_dir = None
|
|
42
|
-
self.kubeconfig_dir = None
|
|
43
|
-
|
|
44
|
-
super().__init__()
|
|
45
|
-
|
|
46
|
-
def set_context(self, context):
|
|
47
|
-
self.context = context
|
|
48
|
-
|
|
49
|
-
def get_latest_minikube_version(self):
|
|
50
|
-
context = self.context
|
|
51
|
-
versions = context.app.run_capturing_out(["git", "ls-remote", "-t", "--refs",
|
|
52
|
-
"https://github.com/kubernetes/minikube", "v*"],
|
|
53
|
-
stderr_logger)
|
|
54
|
-
|
|
55
|
-
# 06e3b0cf7999f74fc52af362b42fb21076ade64a refs/tags/v1.9.1
|
|
56
|
-
# "refs/tags/v1.9.1"
|
|
57
|
-
# "1.9.1"
|
|
58
|
-
# ("1","9","1")
|
|
59
|
-
# (1, 9, 1)
|
|
60
|
-
# sort and get latest, which is the last/highest
|
|
61
|
-
# "v1.9.1"
|
|
62
|
-
return (".".join(map(str, sorted(list(map(lambda v: tuple(map(int, v)),
|
|
63
|
-
filter(lambda v: len(v) == 3,
|
|
64
|
-
map(lambda line: line.split()[1][11:].split("."),
|
|
65
|
-
versions.splitlines(False))))))[-1])))
|
|
66
|
-
|
|
67
|
-
def cmd(self, ):
|
|
68
|
-
pass
|
|
69
|
-
|
|
70
|
-
def register(self, minikube_version=None, k8s_version=None):
|
|
71
|
-
context = self.context
|
|
72
|
-
|
|
73
|
-
context.app.register_plugin("kubectl")
|
|
74
|
-
|
|
75
|
-
if not minikube_version:
|
|
76
|
-
minikube_version = self.get_latest_minikube_version()
|
|
77
|
-
logger.info("No minikube version is specified, latest is %s", minikube_version)
|
|
78
|
-
|
|
79
|
-
minikube_file = context.app.download_remote_file(logger,
|
|
80
|
-
f"https://github.com/kubernetes/minikube/releases/download/"
|
|
81
|
-
f"v{minikube_version}/"
|
|
82
|
-
f"minikube-{get_golang_os()}-{get_golang_machine()}", "bin")
|
|
83
|
-
os.chmod(minikube_file, 0o500)
|
|
84
|
-
version_out: str = self.context.app.run_capturing_out([minikube_file, "version", "--short"],
|
|
85
|
-
stderr_logger)
|
|
86
|
-
version = version_out[1:]
|
|
87
|
-
logger.info("Found minikube %s in %r", version, minikube_file)
|
|
88
|
-
|
|
89
|
-
context.globals.minikube = dict(version=version,
|
|
90
|
-
minikube_file=minikube_file,
|
|
91
|
-
cmd=self.cmd
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
def handle_init(self):
|
|
95
|
-
pass
|
|
96
|
-
|
|
97
|
-
def handle_shutdown(self):
|
|
98
|
-
pass
|
|
99
|
-
|
|
100
|
-
def __repr__(self):
|
|
101
|
-
return "AWS CLI Plugin"
|
|
File without changes
|
{kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/LICENSE
RENAMED
|
File without changes
|
{kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/__main__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/plugins/k8s.py
RENAMED
|
File without changes
|
|
File without changes
|
{kubernator-1.0.6.dev20231217165655 → kubernator-1.0.6.dev20231219050913}/kubernator/plugins/kops.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|