kubernator 1.0.9.dev20231224171539__tar.gz → 1.0.10__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.
Files changed (33) hide show
  1. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/PKG-INFO +2 -2
  2. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/__init__.py +1 -1
  3. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/plugins/k8s.py +57 -5
  4. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/plugins/k8s_api.py +31 -3
  5. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/plugins/minikube.py +1 -1
  6. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator.egg-info/PKG-INFO +2 -2
  7. kubernator-1.0.10/setup.py +95 -0
  8. kubernator-1.0.9.dev20231224171539/setup.py +0 -95
  9. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/MANIFEST.in +0 -0
  10. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/LICENSE +0 -0
  11. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/__main__.py +0 -0
  12. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/api.py +0 -0
  13. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/app.py +0 -0
  14. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/plugins/__init__.py +0 -0
  15. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/plugins/awscli.py +0 -0
  16. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/plugins/eks.py +0 -0
  17. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/plugins/helm.py +0 -0
  18. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/plugins/istio.py +0 -0
  19. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/plugins/kops.py +0 -0
  20. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/plugins/kubeconfig.py +0 -0
  21. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/plugins/kubectl.py +0 -0
  22. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/plugins/template.py +0 -0
  23. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/plugins/terraform.py +0 -0
  24. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/plugins/terragrunt.py +0 -0
  25. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator/proc.py +0 -0
  26. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator.egg-info/SOURCES.txt +0 -0
  27. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator.egg-info/dependency_links.txt +0 -0
  28. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator.egg-info/entry_points.txt +0 -0
  29. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator.egg-info/namespace_packages.txt +0 -0
  30. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator.egg-info/requires.txt +0 -0
  31. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator.egg-info/top_level.txt +0 -0
  32. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/kubernator.egg-info/zip-safe +0 -0
  33. {kubernator-1.0.9.dev20231224171539 → kubernator-1.0.10}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kubernator
3
- Version: 1.0.9.dev20231224171539
3
+ Version: 1.0.10
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.
@@ -86,7 +86,7 @@ $ docker run --mount type=bind,source="$(pwd)",target=/root,readonly -t ghcr.io/
86
86
 
87
87
  ```
88
88
  $ brew install python3.11
89
- $ pip3.11 install `kubernator~=1.0.9`
89
+ $ pip3.11 install 'kubernator~=1.0.9'
90
90
  $ kubernator --version
91
91
  ```
92
92
 
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- __version__ = "1.0.9.dev20231224171539"
19
+ __version__ = "1.0.10"
20
20
 
21
21
 
22
22
  def _main():
@@ -49,6 +49,9 @@ proc_logger = logger.getChild("proc")
49
49
  stdout_logger = StripNL(proc_logger.info)
50
50
  stderr_logger = StripNL(proc_logger.warning)
51
51
 
52
+ FIELD_VALIDATION_STRICT_MARKER = "strict decoding error: "
53
+ VALID_FIELD_VALIDATION = ("Ignore", "Warn", "Strict")
54
+
52
55
 
53
56
  def final_resource_validator(resources: Sequence[K8SResource],
54
57
  resource: K8SResource,
@@ -81,10 +84,12 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
81
84
  def set_context(self, context):
82
85
  self.context = context
83
86
 
84
- def register(self, **kwargs):
87
+ def register(self, field_validation="Strict", field_validation_warn_fatal=True):
85
88
  self.context.app.register_plugin("kubeconfig")
86
89
 
87
- def handle_init(self):
90
+ if field_validation not in VALID_FIELD_VALIDATION:
91
+ raise ValueError("'field_validation' must be one of %s" % (", ".join(VALID_FIELD_VALIDATION)))
92
+
88
93
  context = self.context
89
94
  context.globals.k8s = dict(patch_field_excludes=("^/metadata/managedFields",
90
95
  "^/metadata/generation",
@@ -108,6 +113,9 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
108
113
  add_validator=self.api_remove_validator,
109
114
  get_api_versions=self.get_api_versions,
110
115
  create_resource=self.create_resource,
116
+ field_validation=field_validation,
117
+ field_validation_warn_fatal=field_validation_warn_fatal,
118
+ field_validation_warnings=0,
111
119
  _k8s=self,
112
120
  )
113
121
  context.k8s = dict(default_includes=Globs(context.globals.k8s.default_includes),
@@ -115,6 +123,9 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
115
123
  )
116
124
  self.api_add_validator(final_resource_validator)
117
125
 
126
+ def handle_init(self):
127
+ pass
128
+
118
129
  def handle_start(self):
119
130
  self.context.kubeconfig.register_change_notifier(self._kubeconfig_changed)
120
131
  self.setup_client()
@@ -180,6 +191,19 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
180
191
 
181
192
  logger.info("Found Kubernetes %s on %s", k8s.server_git_version, k8s.client.configuration.host)
182
193
  K8SResource._k8s_client_version = tuple(map(int, pkg_version("kubernetes").split(".")))
194
+ K8SResource._k8s_field_validation = k8s.field_validation
195
+ K8SResource._logger = self.logger
196
+ K8SResource._api_warnings = self._api_warnings
197
+
198
+ def _api_warnings(self, resource, warn):
199
+ k8s = self.context.k8s
200
+ self.context.globals.k8s.field_validation_warnings += 1
201
+
202
+ log = self.logger.warning
203
+ if k8s.field_validation_warn_fatal:
204
+ log = self.logger.error
205
+
206
+ log("FAILED FIELD VALIDATION on resource %s from %s: %s", resource, resource.source, warn)
183
207
 
184
208
  def handle_before_dir(self, cwd: Path):
185
209
  context = self.context
@@ -205,6 +229,8 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
205
229
 
206
230
  def handle_apply(self):
207
231
  context = self.context
232
+ k8s = context.k8s
233
+
208
234
  self._validate_resources()
209
235
 
210
236
  cmd = context.app.args.command
@@ -258,6 +284,14 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
258
284
  create_func,
259
285
  delete_func,
260
286
  status_msg)
287
+
288
+ if ((dump or dry_run) and
289
+ k8s.field_validation_warn_fatal and self.context.globals.k8s.field_validation_warnings):
290
+ msg = ("There were %d field validation warnings and the warnings are fatal!" %
291
+ self.context.globals.k8s.field_validation_warnings)
292
+ logger.fatal(msg)
293
+ raise RuntimeError(msg)
294
+
261
295
  if dump:
262
296
  if file_format in ("json", "json-pretty"):
263
297
  json.dump(dump_results, file, sort_keys=True,
@@ -339,6 +373,19 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
339
373
  rdef = resource.rdef
340
374
  rdef.populate_api(client, self.context.k8s.client)
341
375
 
376
+ def handle_400_strict_validation_error(e: ApiException):
377
+ if e.status == 400:
378
+ status = json.loads(e.body)
379
+
380
+ if status["status"] == "Failure" and FIELD_VALIDATION_STRICT_MARKER in status["message"]:
381
+ message = status["message"]
382
+ messages = message[message.find(FIELD_VALIDATION_STRICT_MARKER) +
383
+ len(FIELD_VALIDATION_STRICT_MARKER):].split(",")
384
+ for m in messages:
385
+ self._api_warnings(resource, m.strip())
386
+
387
+ raise e from None
388
+
342
389
  def create(exists_ok=False):
343
390
  logger.info("Creating resource %s%s%s", resource, status_msg,
344
391
  " (ignoring existing)" if exists_ok else "")
@@ -350,7 +397,6 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
350
397
  status = json.loads(e.body)
351
398
  if status["reason"] == "AlreadyExists":
352
399
  return
353
-
354
400
  raise
355
401
 
356
402
  logger.debug("Applying resource %s%s", resource, status_msg)
@@ -359,7 +405,12 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
359
405
  logger.trace("Current resource %s: %s", resource, remote_resource)
360
406
  except ApiException as e:
361
407
  if e.status == 404:
362
- create()
408
+ try:
409
+ create()
410
+ except ApiException as e:
411
+ if not handle_400_strict_validation_error(e):
412
+ raise
413
+
363
414
  else:
364
415
  raise
365
416
  else:
@@ -396,7 +447,8 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
396
447
  return
397
448
  raise
398
449
  else:
399
- raise
450
+ if not handle_400_strict_validation_error(e):
451
+ raise
400
452
  else:
401
453
  logger.trace("Merged resource %s: %s", resource, merged_resource)
402
454
  patch = jsonpatch.make_patch(remote_resource, merged_resource)
@@ -37,6 +37,7 @@ from openapi_schema_validator import OAS30Validator
37
37
 
38
38
  from kubernator.api import load_file, FileType, load_remote_file, calling_frame_source
39
39
 
40
+ K8S_WARNING_HEADER = re.compile(r'(?:,\s*)?(\d{3})\s+(\S+)\s+"(.+?)(?<!\\)"(?:\s+\"(.+?)(?<!\\)\")?\s*')
40
41
  UPPER_FOLLOWED_BY_LOWER_RE = re.compile(r"(.)([A-Z][a-z]+)")
41
42
  LOWER_OR_NUM_FOLLOWED_BY_UPPER_RE = re.compile(r"([a-z0-9])([A-Z])")
42
43
 
@@ -338,6 +339,9 @@ class K8SResourceKey(namedtuple("K8SResourceKey", ["group", "kind", "name", "nam
338
339
 
339
340
  class K8SResource:
340
341
  _k8s_client_version = None
342
+ _k8s_field_validation = None
343
+ _logger = None
344
+ _api_warnings = None
341
345
 
342
346
  def __init__(self, manifest: dict, rdef: K8SResourceDef, source: Union[str, Path] = None):
343
347
  self.key = self.get_manifest_key(manifest)
@@ -403,13 +407,18 @@ class K8SResource:
403
407
  rdef = self.rdef
404
408
  kwargs = {"body": self.manifest,
405
409
  "_preload_content": False,
406
- "field_manager": "kubernator"
410
+ "field_manager": "kubernator",
407
411
  }
412
+
413
+ if self._k8s_client_version[0] > 22:
414
+ kwargs["field_validation"] = self._k8s_field_validation
408
415
  if rdef.namespaced:
409
416
  kwargs["namespace"] = self.namespace
410
417
  if dry_run:
411
418
  kwargs["dry_run"] = "All"
412
- return json.loads(rdef.create(**kwargs).data)
419
+ resp = rdef.create(**kwargs)
420
+ self._process_response_headers(resp)
421
+ return json.loads(resp.data)
413
422
 
414
423
  def patch(self, json_patch, *, patch_type: K8SResourcePatchType, force=False, dry_run=True):
415
424
  rdef = self.rdef
@@ -420,6 +429,9 @@ class K8SResource:
420
429
  "_preload_content": False,
421
430
  "field_manager": "kubernator",
422
431
  }
432
+
433
+ if self._k8s_client_version[0] > 22:
434
+ kwargs["field_validation"] = self._k8s_field_validation
423
435
  if patch_type == K8SResourcePatchType.SERVER_SIDE_PATCH:
424
436
  kwargs["force"] = force
425
437
  if rdef.namespaced:
@@ -442,7 +454,9 @@ class K8SResource:
442
454
  old_func = api_client.select_header_content_type
443
455
  try:
444
456
  api_client.select_header_content_type = select_header_content_type_patch
445
- return json.loads(rdef.patch(**kwargs).data)
457
+ resp = rdef.patch(**kwargs)
458
+ self._process_response_headers(resp)
459
+ return json.loads(resp.data)
446
460
  finally:
447
461
  api_client.select_header_content_type = old_func
448
462
 
@@ -484,6 +498,20 @@ class K8SResource:
484
498
  return False
485
499
  return self.key == other.key and self.manifest == other.manifest
486
500
 
501
+ def _process_response_headers(self, resp):
502
+ headers = resp.headers
503
+ warn_headers = headers.get("Warning")
504
+ if warn_headers:
505
+ for warn in K8S_WARNING_HEADER.findall(warn_headers):
506
+ code, _, msg, _ = warn
507
+ code = int(code)
508
+ msg = msg.encode("utf-8").decode("unicode_escape")
509
+ if code == 299:
510
+ self._api_warnings(self, msg)
511
+ else:
512
+ self._logger.warning("Unknown API warning received for resource %s from %s: code %d: %s",
513
+ self, self.source, code, msg)
514
+
487
515
 
488
516
  class K8SResourcePluginMixin:
489
517
  def __init__(self):
@@ -116,7 +116,7 @@ class MinikubePlugin(KubernatorPlugin):
116
116
  minikube_file = Path(self.minikube_dir.name) / "minikube"
117
117
  minikube_file.symlink_to(minikube_dl_file)
118
118
  prepend_os_path(self.minikube_dir.name)
119
- version_out: str = self.context.app.run_capturing_out([minikube_file, "version", "--short"],
119
+ version_out: str = self.context.app.run_capturing_out([str(minikube_file), "version", "--short"],
120
120
  stderr_logger).strip()
121
121
  version = version_out[1:]
122
122
  logger.info("Found minikube %s in %s", version, minikube_file)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kubernator
3
- Version: 1.0.9.dev20231224171539
3
+ Version: 1.0.10
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.
@@ -86,7 +86,7 @@ $ docker run --mount type=bind,source="$(pwd)",target=/root,readonly -t ghcr.io/
86
86
 
87
87
  ```
88
88
  $ brew install python3.11
89
- $ pip3.11 install `kubernator~=1.0.9`
89
+ $ pip3.11 install 'kubernator~=1.0.9'
90
90
  $ kubernator --version
91
91
  ```
92
92
 
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ from setuptools import setup
5
+ from setuptools.command.install import install as _install
6
+
7
+ class install(_install):
8
+ def pre_install_script(self):
9
+ pass
10
+
11
+ def post_install_script(self):
12
+ pass
13
+
14
+ def run(self):
15
+ self.pre_install_script()
16
+
17
+ _install.run(self)
18
+
19
+ self.post_install_script()
20
+
21
+ if __name__ == '__main__':
22
+ setup(
23
+ name = 'kubernator',
24
+ version = '1.0.10',
25
+ description = 'Kubernator is the a pluggable framework for K8S provisioning',
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[![Gitter](https://img.shields.io/gitter/room/karellen/lobby?logo=gitter)](https://gitter.im/karellen/Lobby)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/karellen/kubernator/kubernator.yml?branch=master)](https://github.com/karellen/kubernator/actions/workflows/kubernator.yml)\n[![Coverage Status](https://img.shields.io/coveralls/github/karellen/kubernator/master?logo=coveralls)](https://coveralls.io/r/karellen/kubernator?branch=master)\n\n[![Kubernator Version](https://img.shields.io/pypi/v/kubernator?logo=pypi)](https://pypi.org/project/kubernator/)\n[![Kubernator Python Versions](https://img.shields.io/pypi/pyversions/kubernator?logo=pypi)](https://pypi.org/project/kubernator/)\n[![Kubernator Downloads Per Day](https://img.shields.io/pypi/dd/kubernator?logo=pypi)](https://pypi.org/project/kubernator/)\n[![Kubernator Downloads Per Week](https://img.shields.io/pypi/dw/kubernator?logo=pypi)](https://pypi.org/project/kubernator/)\n[![Kubernator Downloads Per Month](https://img.shields.io/pypi/dm/kubernator?logo=pypi)](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
+ long_description_content_type = 'text/markdown',
28
+ classifiers = [
29
+ 'License :: OSI Approved :: Apache Software License',
30
+ 'Programming Language :: Python :: 3.9',
31
+ 'Programming Language :: Python :: 3.10',
32
+ 'Programming Language :: Python :: 3.11',
33
+ 'Operating System :: MacOS :: MacOS X',
34
+ 'Operating System :: POSIX',
35
+ 'Operating System :: POSIX :: Linux',
36
+ 'Environment :: Console',
37
+ 'Topic :: Utilities',
38
+ 'Topic :: System :: Monitoring',
39
+ 'Topic :: System :: Distributed Computing',
40
+ 'Topic :: System :: Clustering',
41
+ 'Topic :: System :: Networking',
42
+ 'Intended Audience :: System Administrators',
43
+ 'Intended Audience :: Developers',
44
+ 'Development Status :: 4 - Beta'
45
+ ],
46
+ keywords = 'kubernetes k8s kube top provisioning kOps terraform tf AWS',
47
+
48
+ author = 'Express Systems USA, Inc.',
49
+ author_email = '',
50
+ maintainer = 'Karellen, Inc., Arcadiy Ivanov',
51
+ maintainer_email = 'supervisor@karellen.co,arcadiy@karellen.co',
52
+
53
+ license = 'Apache License, Version 2.0',
54
+
55
+ url = 'https://github.com/karellen/kubernator',
56
+ project_urls = {
57
+ 'Bug Tracker': 'https://github.com/karellen/kubernator/issues',
58
+ 'Documentation': 'https://github.com/karellen/kubernator/',
59
+ 'Source Code': 'https://github.com/karellen/kubernator/'
60
+ },
61
+
62
+ scripts = [],
63
+ packages = [
64
+ 'kubernator',
65
+ 'kubernator.plugins'
66
+ ],
67
+ namespace_packages = [],
68
+ py_modules = [],
69
+ entry_points = {
70
+ 'console_scripts': ['kubernator = kubernator:main']
71
+ },
72
+ data_files = [],
73
+ package_data = {
74
+ 'kubernator': ['LICENSE']
75
+ },
76
+ install_requires = [
77
+ 'appdirs~=1.4',
78
+ 'coloredlogs~=15.0',
79
+ 'gevent>=21.1.2',
80
+ 'jinja2~=3.1',
81
+ 'json-log-formatter~=0.3',
82
+ 'jsonpatch~=1.32',
83
+ 'jsonpath-ng~=1.5',
84
+ 'jsonschema<4.0',
85
+ 'kubernetes~=28.0',
86
+ 'openapi-schema-validator~=0.1',
87
+ 'openapi-spec-validator~=0.3',
88
+ 'requests~=2.25'
89
+ ],
90
+ dependency_links = [],
91
+ zip_safe = True,
92
+ cmdclass = {'install': install},
93
+ python_requires = '>=3.9',
94
+ obsoletes = [],
95
+ )
@@ -1,95 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
-
4
- from setuptools import setup
5
- from setuptools.command.install import install as _install
6
-
7
- class install(_install):
8
- def pre_install_script(self):
9
- pass
10
-
11
- def post_install_script(self):
12
- pass
13
-
14
- def run(self):
15
- self.pre_install_script()
16
-
17
- _install.run(self)
18
-
19
- self.post_install_script()
20
-
21
- if __name__ == '__main__':
22
- setup(
23
- name = 'kubernator',
24
- version = '1.0.9.dev20231224171539',
25
- description = 'Kubernator is the a pluggable framework for K8S provisioning',
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[![Gitter](https://img.shields.io/gitter/room/karellen/lobby?logo=gitter)](https://gitter.im/karellen/Lobby)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/karellen/kubernator/kubernator.yml?branch=master)](https://github.com/karellen/kubernator/actions/workflows/kubernator.yml)\n[![Coverage Status](https://img.shields.io/coveralls/github/karellen/kubernator/master?logo=coveralls)](https://coveralls.io/r/karellen/kubernator?branch=master)\n\n[![Kubernator Version](https://img.shields.io/pypi/v/kubernator?logo=pypi)](https://pypi.org/project/kubernator/)\n[![Kubernator Python Versions](https://img.shields.io/pypi/pyversions/kubernator?logo=pypi)](https://pypi.org/project/kubernator/)\n[![Kubernator Downloads Per Day](https://img.shields.io/pypi/dd/kubernator?logo=pypi)](https://pypi.org/project/kubernator/)\n[![Kubernator Downloads Per Week](https://img.shields.io/pypi/dw/kubernator?logo=pypi)](https://pypi.org/project/kubernator/)\n[![Kubernator Downloads Per Month](https://img.shields.io/pypi/dm/kubernator?logo=pypi)](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
- long_description_content_type = 'text/markdown',
28
- classifiers = [
29
- 'License :: OSI Approved :: Apache Software License',
30
- 'Programming Language :: Python :: 3.9',
31
- 'Programming Language :: Python :: 3.10',
32
- 'Programming Language :: Python :: 3.11',
33
- 'Operating System :: MacOS :: MacOS X',
34
- 'Operating System :: POSIX',
35
- 'Operating System :: POSIX :: Linux',
36
- 'Environment :: Console',
37
- 'Topic :: Utilities',
38
- 'Topic :: System :: Monitoring',
39
- 'Topic :: System :: Distributed Computing',
40
- 'Topic :: System :: Clustering',
41
- 'Topic :: System :: Networking',
42
- 'Intended Audience :: System Administrators',
43
- 'Intended Audience :: Developers',
44
- 'Development Status :: 4 - Beta'
45
- ],
46
- keywords = 'kubernetes k8s kube top provisioning kOps terraform tf AWS',
47
-
48
- author = 'Express Systems USA, Inc.',
49
- author_email = '',
50
- maintainer = 'Karellen, Inc., Arcadiy Ivanov',
51
- maintainer_email = 'supervisor@karellen.co,arcadiy@karellen.co',
52
-
53
- license = 'Apache License, Version 2.0',
54
-
55
- url = 'https://github.com/karellen/kubernator',
56
- project_urls = {
57
- 'Bug Tracker': 'https://github.com/karellen/kubernator/issues',
58
- 'Documentation': 'https://github.com/karellen/kubernator/',
59
- 'Source Code': 'https://github.com/karellen/kubernator/'
60
- },
61
-
62
- scripts = [],
63
- packages = [
64
- 'kubernator',
65
- 'kubernator.plugins'
66
- ],
67
- namespace_packages = [],
68
- py_modules = [],
69
- entry_points = {
70
- 'console_scripts': ['kubernator = kubernator:main']
71
- },
72
- data_files = [],
73
- package_data = {
74
- 'kubernator': ['LICENSE']
75
- },
76
- install_requires = [
77
- 'appdirs~=1.4',
78
- 'coloredlogs~=15.0',
79
- 'gevent>=21.1.2',
80
- 'jinja2~=3.1',
81
- 'json-log-formatter~=0.3',
82
- 'jsonpatch~=1.32',
83
- 'jsonpath-ng~=1.5',
84
- 'jsonschema<4.0',
85
- 'kubernetes~=28.0',
86
- 'openapi-schema-validator~=0.1',
87
- 'openapi-spec-validator~=0.3',
88
- 'requests~=2.25'
89
- ],
90
- dependency_links = [],
91
- zip_safe = True,
92
- cmdclass = {'install': install},
93
- python_requires = '>=3.9',
94
- obsoletes = [],
95
- )