kubernator 1.0.16.dev20240502034800__tar.gz → 1.0.16.dev20240514041500__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.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/PKG-INFO +1 -1
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/__init__.py +1 -1
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/api.py +3 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/app.py +30 -23
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/plugins/k8s.py +23 -8
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator.egg-info/PKG-INFO +1 -1
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/setup.py +1 -1
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/MANIFEST.in +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/LICENSE +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/__main__.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/_json_path.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/_k8s_client_patches.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/merge.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/plugins/__init__.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/plugins/awscli.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/plugins/eks.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/plugins/helm.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/plugins/istio.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/plugins/k8s_api.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/plugins/kops.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/plugins/kubeconfig.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/plugins/kubectl.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/plugins/minikube.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/plugins/template.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/plugins/terraform.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/plugins/terragrunt.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/proc.py +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator.egg-info/SOURCES.txt +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator.egg-info/dependency_links.txt +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator.egg-info/entry_points.txt +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator.egg-info/namespace_packages.txt +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator.egg-info/requires.txt +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator.egg-info/top_level.txt +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator.egg-info/zip-safe +0 -0
- {kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: kubernator
|
|
3
|
-
Version: 1.0.16.
|
|
3
|
+
Version: 1.0.16.dev20240514041500
|
|
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.
|
{kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/api.py
RENAMED
|
@@ -747,6 +747,9 @@ class KubernatorPlugin:
|
|
|
747
747
|
def handle_shutdown(self):
|
|
748
748
|
pass
|
|
749
749
|
|
|
750
|
+
def handle_summary(self):
|
|
751
|
+
pass
|
|
752
|
+
|
|
750
753
|
|
|
751
754
|
def install_python_k8s_client(run, package_major, logger, logger_stdout, logger_stderr, disable_patching):
|
|
752
755
|
cache_dir = get_cache_dir("python")
|
{kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/app.py
RENAMED
|
@@ -178,42 +178,49 @@ class App(KubernatorPlugin):
|
|
|
178
178
|
self.register_plugin(self)
|
|
179
179
|
|
|
180
180
|
try:
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
181
|
+
try:
|
|
182
|
+
while True:
|
|
183
|
+
cwd = self.next()
|
|
184
|
+
if not cwd:
|
|
185
|
+
logger.debug("No paths left to traverse")
|
|
186
|
+
break
|
|
186
187
|
|
|
187
|
-
|
|
188
|
+
context = self.context
|
|
188
189
|
|
|
189
|
-
|
|
190
|
-
|
|
190
|
+
logger.debug("Inspecting directory %s", self._display_path(cwd))
|
|
191
|
+
self._run_handlers(KubernatorPlugin.handle_before_dir, False, context, None, cwd)
|
|
191
192
|
|
|
192
|
-
|
|
193
|
-
|
|
193
|
+
if (ktor_py := (cwd / ".kubernator.py")).exists():
|
|
194
|
+
self._run_handlers(KubernatorPlugin.handle_before_script, False, context, None, cwd)
|
|
194
195
|
|
|
195
|
-
|
|
196
|
-
|
|
196
|
+
for h in self.context._plugins:
|
|
197
|
+
h.set_context(context)
|
|
197
198
|
|
|
198
|
-
|
|
199
|
+
self._exec_ktor(ktor_py)
|
|
199
200
|
|
|
200
|
-
|
|
201
|
-
|
|
201
|
+
for h in self.context._plugins:
|
|
202
|
+
h.set_context(None)
|
|
202
203
|
|
|
203
|
-
|
|
204
|
+
self._run_handlers(KubernatorPlugin.handle_after_script, True, context, None, cwd)
|
|
204
205
|
|
|
205
|
-
|
|
206
|
+
self._run_handlers(KubernatorPlugin.handle_after_dir, True, context, None, cwd)
|
|
206
207
|
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
self.context = self._top_dir_context
|
|
209
|
+
context = self.context
|
|
209
210
|
|
|
210
|
-
|
|
211
|
+
self._run_handlers(KubernatorPlugin.handle_apply, True, context, None)
|
|
211
212
|
|
|
212
|
-
|
|
213
|
-
|
|
213
|
+
self._run_handlers(KubernatorPlugin.handle_verify, True, context, None)
|
|
214
|
+
finally:
|
|
215
|
+
self.context = self._top_dir_context
|
|
216
|
+
context = self.context
|
|
217
|
+
self._run_handlers(KubernatorPlugin.handle_shutdown, True, context, None)
|
|
218
|
+
except: # noqa E722
|
|
219
|
+
raise
|
|
220
|
+
else:
|
|
214
221
|
self.context = self._top_dir_context
|
|
215
222
|
context = self.context
|
|
216
|
-
self._run_handlers(KubernatorPlugin.
|
|
223
|
+
self._run_handlers(KubernatorPlugin.handle_summary, True, context, None)
|
|
217
224
|
|
|
218
225
|
def discover_plugins(self):
|
|
219
226
|
importlib.invalidate_caches()
|
|
@@ -81,6 +81,7 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
81
81
|
|
|
82
82
|
self._transformers = []
|
|
83
83
|
self._validators = []
|
|
84
|
+
self._summary = 0, 0, 0
|
|
84
85
|
|
|
85
86
|
def set_context(self, context):
|
|
86
87
|
self.context = context
|
|
@@ -248,6 +249,7 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
248
249
|
|
|
249
250
|
patch_field_excludes = [re.compile(e) for e in context.globals.k8s.patch_field_excludes]
|
|
250
251
|
dump_results = []
|
|
252
|
+
total_created, total_patched, total_deleted = 0, 0, 0
|
|
251
253
|
for resource in self.resources.values():
|
|
252
254
|
if dump:
|
|
253
255
|
resource_id = {"apiVersion": resource.api_version,
|
|
@@ -280,13 +282,17 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
280
282
|
create_func = partial(resource.create, dry_run=dry_run)
|
|
281
283
|
delete_func = partial(resource.delete, dry_run=dry_run)
|
|
282
284
|
|
|
283
|
-
self._apply_resource(dry_run,
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
285
|
+
created, patched, deleted = self._apply_resource(dry_run,
|
|
286
|
+
patch_field_excludes,
|
|
287
|
+
resource,
|
|
288
|
+
patch_func,
|
|
289
|
+
create_func,
|
|
290
|
+
delete_func,
|
|
291
|
+
status_msg)
|
|
292
|
+
|
|
293
|
+
total_created += created
|
|
294
|
+
total_patched += patched
|
|
295
|
+
total_deleted += deleted
|
|
290
296
|
|
|
291
297
|
if ((dump or dry_run) and
|
|
292
298
|
k8s.field_validation_warn_fatal and self.context.globals.k8s.field_validation_warnings):
|
|
@@ -301,6 +307,12 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
301
307
|
indent=4 if file_format == "json-pretty" else None)
|
|
302
308
|
else:
|
|
303
309
|
yaml.safe_dump(dump_results, file)
|
|
310
|
+
else:
|
|
311
|
+
self._summary = total_created, total_patched, total_deleted
|
|
312
|
+
|
|
313
|
+
def handle_summary(self):
|
|
314
|
+
total_created, total_patched, total_deleted = self._summary
|
|
315
|
+
logger.info("Created %d, patched %d, deleted %d resources", total_created, total_patched, total_deleted)
|
|
304
316
|
|
|
305
317
|
def api_load_resources(self, path: Path, file_type: str):
|
|
306
318
|
return self.add_local_resources(path, FileType[file_type.upper()])
|
|
@@ -422,6 +434,7 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
422
434
|
if e.status == 404:
|
|
423
435
|
try:
|
|
424
436
|
create()
|
|
437
|
+
return 1, 0, 0
|
|
425
438
|
except ApiException as e:
|
|
426
439
|
if not handle_400_strict_validation_error(e):
|
|
427
440
|
raise
|
|
@@ -459,7 +472,7 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
459
472
|
status_msg)
|
|
460
473
|
delete_func(propagation_policy=propagation_policy)
|
|
461
474
|
create(exists_ok=dry_run)
|
|
462
|
-
return
|
|
475
|
+
return 1, 0, 1
|
|
463
476
|
raise
|
|
464
477
|
else:
|
|
465
478
|
if not handle_400_strict_validation_error(e):
|
|
@@ -476,8 +489,10 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
|
|
|
476
489
|
if patch:
|
|
477
490
|
logger.info("Patching resource %s%s", resource, status_msg)
|
|
478
491
|
patch_func(patch)
|
|
492
|
+
return 0, 1, 0
|
|
479
493
|
else:
|
|
480
494
|
logger.info("Nothing to patch for resource %s", resource)
|
|
495
|
+
return 0, 0, 0
|
|
481
496
|
|
|
482
497
|
def _filter_resource_patch(self, patch: Iterable[Mapping], excludes: Iterable[re.compile]):
|
|
483
498
|
result = []
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: kubernator
|
|
3
|
-
Version: 1.0.16.
|
|
3
|
+
Version: 1.0.16.dev20240514041500
|
|
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.16.
|
|
24
|
+
version = '1.0.16.dev20240514041500',
|
|
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\n## Using Kubernator on MacOS\n\n```\n$ brew install python3.11\n$ pip3.11 install \'kubernator~=1.0.9\'\n$ kubernator --version\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',
|
|
File without changes
|
{kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/LICENSE
RENAMED
|
File without changes
|
{kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/__main__.py
RENAMED
|
File without changes
|
{kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/_json_path.py
RENAMED
|
File without changes
|
|
File without changes
|
{kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/merge.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kubernator-1.0.16.dev20240502034800 → kubernator-1.0.16.dev20240514041500}/kubernator/proc.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
|