kubernator 1.0.16__tar.gz → 1.0.16.dev20240502034800__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.

Files changed (35) hide show
  1. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/PKG-INFO +2 -2
  2. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/__init__.py +1 -1
  3. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/api.py +0 -3
  4. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/app.py +23 -30
  5. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/plugins/k8s.py +9 -38
  6. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator.egg-info/PKG-INFO +2 -2
  7. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator.egg-info/requires.txt +1 -1
  8. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/setup.py +2 -2
  9. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/MANIFEST.in +0 -0
  10. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/LICENSE +0 -0
  11. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/__main__.py +0 -0
  12. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/_json_path.py +0 -0
  13. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/_k8s_client_patches.py +0 -0
  14. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/merge.py +0 -0
  15. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/plugins/__init__.py +0 -0
  16. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/plugins/awscli.py +0 -0
  17. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/plugins/eks.py +0 -0
  18. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/plugins/helm.py +0 -0
  19. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/plugins/istio.py +0 -0
  20. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/plugins/k8s_api.py +0 -0
  21. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/plugins/kops.py +0 -0
  22. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/plugins/kubeconfig.py +0 -0
  23. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/plugins/kubectl.py +0 -0
  24. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/plugins/minikube.py +0 -0
  25. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/plugins/template.py +0 -0
  26. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/plugins/terraform.py +0 -0
  27. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/plugins/terragrunt.py +0 -0
  28. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator/proc.py +0 -0
  29. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator.egg-info/SOURCES.txt +0 -0
  30. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator.egg-info/dependency_links.txt +0 -0
  31. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator.egg-info/entry_points.txt +0 -0
  32. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator.egg-info/namespace_packages.txt +0 -0
  33. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator.egg-info/top_level.txt +0 -0
  34. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/kubernator.egg-info/zip-safe +0 -0
  35. {kubernator-1.0.16 → kubernator-1.0.16.dev20240502034800}/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.dev20240502034800
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.
@@ -43,7 +43,7 @@ Requires-Dist: kubernetes~=29.0
43
43
  Requires-Dist: openapi-schema-validator~=0.1
44
44
  Requires-Dist: openapi-spec-validator~=0.3
45
45
  Requires-Dist: platformdirs~=4.2
46
- Requires-Dist: requests<=2.31.0
46
+ Requires-Dist: requests~=2.25
47
47
 
48
48
  # Kubernator
49
49
 
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- __version__ = "1.0.16"
19
+ __version__ = "1.0.16.dev20240502034800"
20
20
 
21
21
 
22
22
  def _main():
@@ -747,9 +747,6 @@ class KubernatorPlugin:
747
747
  def handle_shutdown(self):
748
748
  pass
749
749
 
750
- def handle_summary(self):
751
- pass
752
-
753
750
 
754
751
  def install_python_k8s_client(run, package_major, logger, logger_stdout, logger_stderr, disable_patching):
755
752
  cache_dir = get_cache_dir("python")
@@ -178,49 +178,42 @@ class App(KubernatorPlugin):
178
178
  self.register_plugin(self)
179
179
 
180
180
  try:
181
- try:
182
- while True:
183
- cwd = self.next()
184
- if not cwd:
185
- logger.debug("No paths left to traverse")
186
- break
181
+ while True:
182
+ cwd = self.next()
183
+ if not cwd:
184
+ logger.debug("No paths left to traverse")
185
+ break
187
186
 
188
- context = self.context
187
+ context = self.context
189
188
 
190
- logger.debug("Inspecting directory %s", self._display_path(cwd))
191
- self._run_handlers(KubernatorPlugin.handle_before_dir, False, context, None, cwd)
189
+ logger.debug("Inspecting directory %s", self._display_path(cwd))
190
+ self._run_handlers(KubernatorPlugin.handle_before_dir, False, context, None, cwd)
192
191
 
193
- if (ktor_py := (cwd / ".kubernator.py")).exists():
194
- self._run_handlers(KubernatorPlugin.handle_before_script, False, context, None, cwd)
192
+ if (ktor_py := (cwd / ".kubernator.py")).exists():
193
+ self._run_handlers(KubernatorPlugin.handle_before_script, False, context, None, cwd)
195
194
 
196
- for h in self.context._plugins:
197
- h.set_context(context)
195
+ for h in self.context._plugins:
196
+ h.set_context(context)
198
197
 
199
- self._exec_ktor(ktor_py)
198
+ self._exec_ktor(ktor_py)
200
199
 
201
- for h in self.context._plugins:
202
- h.set_context(None)
200
+ for h in self.context._plugins:
201
+ h.set_context(None)
203
202
 
204
- self._run_handlers(KubernatorPlugin.handle_after_script, True, context, None, cwd)
203
+ self._run_handlers(KubernatorPlugin.handle_after_script, True, context, None, cwd)
205
204
 
206
- self._run_handlers(KubernatorPlugin.handle_after_dir, True, context, None, cwd)
205
+ self._run_handlers(KubernatorPlugin.handle_after_dir, True, context, None, cwd)
207
206
 
208
- self.context = self._top_dir_context
209
- context = self.context
207
+ self.context = self._top_dir_context
208
+ context = self.context
210
209
 
211
- self._run_handlers(KubernatorPlugin.handle_apply, True, context, None)
210
+ self._run_handlers(KubernatorPlugin.handle_apply, True, context, None)
212
211
 
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:
212
+ self._run_handlers(KubernatorPlugin.handle_verify, True, context, None)
213
+ finally:
221
214
  self.context = self._top_dir_context
222
215
  context = self.context
223
- self._run_handlers(KubernatorPlugin.handle_summary, True, context, None)
216
+ self._run_handlers(KubernatorPlugin.handle_shutdown, True, context, None)
224
217
 
225
218
  def discover_plugins(self):
226
219
  importlib.invalidate_caches()
@@ -68,19 +68,6 @@ def final_resource_validator(resources: Sequence[K8SResource],
68
68
  resource, resource.source)
69
69
 
70
70
 
71
- def normalize_pkg_version(v: str):
72
- v_split = v.split(".")
73
- rev = v_split[-1]
74
- if not rev.isdigit():
75
- new_rev = ""
76
- for c in rev:
77
- if not c.isdigit():
78
- break
79
- new_rev += c
80
- v_split[-1] = new_rev
81
- return tuple(map(int, v_split))
82
-
83
-
84
71
  class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
85
72
  logger = logger
86
73
 
@@ -94,7 +81,6 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
94
81
 
95
82
  self._transformers = []
96
83
  self._validators = []
97
- self._summary = 0, 0, 0
98
84
 
99
85
  def set_context(self, context):
100
86
  self.context = context
@@ -206,8 +192,7 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
206
192
  k8s.server_git_version = git_version
207
193
 
208
194
  logger.info("Found Kubernetes %s on %s", k8s.server_git_version, k8s.client.configuration.host)
209
-
210
- K8SResource._k8s_client_version = normalize_pkg_version(pkg_version("kubernetes"))
195
+ K8SResource._k8s_client_version = tuple(map(int, pkg_version("kubernetes").split(".")))
211
196
  K8SResource._k8s_field_validation = k8s.field_validation
212
197
  K8SResource._k8s_field_validation_patched = not k8s.disable_client_patches
213
198
  K8SResource._logger = self.logger
@@ -263,7 +248,6 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
263
248
 
264
249
  patch_field_excludes = [re.compile(e) for e in context.globals.k8s.patch_field_excludes]
265
250
  dump_results = []
266
- total_created, total_patched, total_deleted = 0, 0, 0
267
251
  for resource in self.resources.values():
268
252
  if dump:
269
253
  resource_id = {"apiVersion": resource.api_version,
@@ -296,17 +280,13 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
296
280
  create_func = partial(resource.create, dry_run=dry_run)
297
281
  delete_func = partial(resource.delete, dry_run=dry_run)
298
282
 
299
- created, patched, deleted = self._apply_resource(dry_run,
300
- patch_field_excludes,
301
- resource,
302
- patch_func,
303
- create_func,
304
- delete_func,
305
- status_msg)
306
-
307
- total_created += created
308
- total_patched += patched
309
- total_deleted += deleted
283
+ self._apply_resource(dry_run,
284
+ patch_field_excludes,
285
+ resource,
286
+ patch_func,
287
+ create_func,
288
+ delete_func,
289
+ status_msg)
310
290
 
311
291
  if ((dump or dry_run) and
312
292
  k8s.field_validation_warn_fatal and self.context.globals.k8s.field_validation_warnings):
@@ -321,12 +301,6 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
321
301
  indent=4 if file_format == "json-pretty" else None)
322
302
  else:
323
303
  yaml.safe_dump(dump_results, file)
324
- else:
325
- self._summary = total_created, total_patched, total_deleted
326
-
327
- def handle_summary(self):
328
- total_created, total_patched, total_deleted = self._summary
329
- logger.info("Created %d, patched %d, deleted %d resources", total_created, total_patched, total_deleted)
330
304
 
331
305
  def api_load_resources(self, path: Path, file_type: str):
332
306
  return self.add_local_resources(path, FileType[file_type.upper()])
@@ -448,7 +422,6 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
448
422
  if e.status == 404:
449
423
  try:
450
424
  create()
451
- return 1, 0, 0
452
425
  except ApiException as e:
453
426
  if not handle_400_strict_validation_error(e):
454
427
  raise
@@ -486,7 +459,7 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
486
459
  status_msg)
487
460
  delete_func(propagation_policy=propagation_policy)
488
461
  create(exists_ok=dry_run)
489
- return 1, 0, 1
462
+ return
490
463
  raise
491
464
  else:
492
465
  if not handle_400_strict_validation_error(e):
@@ -503,10 +476,8 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
503
476
  if patch:
504
477
  logger.info("Patching resource %s%s", resource, status_msg)
505
478
  patch_func(patch)
506
- return 0, 1, 0
507
479
  else:
508
480
  logger.info("Nothing to patch for resource %s", resource)
509
- return 0, 0, 0
510
481
 
511
482
  def _filter_resource_patch(self, patch: Iterable[Mapping], excludes: Iterable[re.compile]):
512
483
  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.dev20240502034800
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.
@@ -43,7 +43,7 @@ Requires-Dist: kubernetes~=29.0
43
43
  Requires-Dist: openapi-schema-validator~=0.1
44
44
  Requires-Dist: openapi-spec-validator~=0.3
45
45
  Requires-Dist: platformdirs~=4.2
46
- Requires-Dist: requests<=2.31.0
46
+ Requires-Dist: requests~=2.25
47
47
 
48
48
  # Kubernator
49
49
 
@@ -10,4 +10,4 @@ kubernetes~=29.0
10
10
  openapi-schema-validator~=0.1
11
11
  openapi-spec-validator~=0.3
12
12
  platformdirs~=4.2
13
- requests<=2.31.0
13
+ requests~=2.25
@@ -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.dev20240502034800',
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[![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
27
  long_description_content_type = 'text/markdown',
@@ -87,7 +87,7 @@ if __name__ == '__main__':
87
87
  'openapi-schema-validator~=0.1',
88
88
  'openapi-spec-validator~=0.3',
89
89
  'platformdirs~=4.2',
90
- 'requests<=2.31.0'
90
+ 'requests~=2.25'
91
91
  ],
92
92
  dependency_links = [],
93
93
  zip_safe = True,