kubernator 1.0.23.dev20251008231728__tar.gz → 1.0.23.dev20251010010455__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 (36) hide show
  1. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/PKG-INFO +1 -1
  2. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/__init__.py +1 -1
  3. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/plugins/k8s.py +28 -15
  4. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator.egg-info/PKG-INFO +1 -1
  5. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/setup.py +1 -1
  6. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/MANIFEST.in +0 -0
  7. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/LICENSE +0 -0
  8. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/__main__.py +0 -0
  9. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/_json_path.py +0 -0
  10. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/_k8s_client_patches.py +0 -0
  11. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/api.py +0 -0
  12. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/app.py +0 -0
  13. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/merge.py +0 -0
  14. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/plugins/__init__.py +0 -0
  15. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/plugins/awscli.py +0 -0
  16. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/plugins/eks.py +0 -0
  17. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/plugins/gke.py +0 -0
  18. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/plugins/helm.py +0 -0
  19. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/plugins/istio.py +0 -0
  20. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/plugins/k8s_api.py +0 -0
  21. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/plugins/kops.py +0 -0
  22. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/plugins/kubeconfig.py +0 -0
  23. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/plugins/kubectl.py +0 -0
  24. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/plugins/minikube.py +0 -0
  25. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/plugins/template.py +0 -0
  26. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/plugins/terraform.py +0 -0
  27. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/plugins/terragrunt.py +0 -0
  28. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator/proc.py +0 -0
  29. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator.egg-info/SOURCES.txt +0 -0
  30. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator.egg-info/dependency_links.txt +0 -0
  31. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator.egg-info/entry_points.txt +0 -0
  32. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator.egg-info/namespace_packages.txt +0 -0
  33. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator.egg-info/requires.txt +0 -0
  34. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator.egg-info/top_level.txt +0 -0
  35. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/kubernator.egg-info/zip-safe +0 -0
  36. {kubernator-1.0.23.dev20251008231728 → kubernator-1.0.23.dev20251010010455}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kubernator
3
- Version: 1.0.23.dev20251008231728
3
+ Version: 1.0.23.dev20251010010455
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.
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- __version__ = "1.0.23.dev20251008231728"
19
+ __version__ = "1.0.23.dev20251010010455"
20
20
 
21
21
 
22
22
  def _main():
@@ -39,7 +39,8 @@ from kubernator.api import (KubernatorPlugin,
39
39
  load_remote_file,
40
40
  StripNL,
41
41
  install_python_k8s_client,
42
- TemplateEngine)
42
+ TemplateEngine,
43
+ sleep)
43
44
  from kubernator.merge import extract_merge_instructions, apply_merge_instructions
44
45
  from kubernator.plugins.k8s_api import (K8SResourcePluginMixin,
45
46
  K8SResource,
@@ -120,6 +121,7 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
120
121
  ("apps", "StatefulSet"): K8SPropagationPolicy.ORPHAN,
121
122
  ("apps", "Deployment"): K8SPropagationPolicy.ORPHAN,
122
123
  ("storage.k8s.io", "StorageClass"): K8SPropagationPolicy.ORPHAN,
124
+ (None, "Pod"): K8SPropagationPolicy.BACKGROUND,
123
125
  },
124
126
  default_includes=Globs(["*.yaml", "*.yml"], True),
125
127
  default_excludes=Globs([".*"], True),
@@ -137,6 +139,7 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
137
139
  field_validation=field_validation,
138
140
  field_validation_warn_fatal=field_validation_warn_fatal,
139
141
  field_validation_warnings=0,
142
+ conflict_retry_delay=0.3,
140
143
  _k8s=self,
141
144
  )
142
145
  context.k8s = dict(default_includes=Globs(context.globals.k8s.default_includes),
@@ -199,7 +202,7 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
199
202
 
200
203
  k8s.client = self._setup_k8s_client()
201
204
  version = client.VersionApi(k8s.client).get_code()
202
- if "-eks-" in version.git_version:
205
+ if "-eks-" or "-gke" in version.git_version:
203
206
  git_version = version.git_version.split("-")[0]
204
207
  else:
205
208
  git_version = version.git_version
@@ -425,18 +428,26 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
425
428
  resource, resource.source, status["message"])
426
429
  raise e from None
427
430
 
428
- def create(exists_ok=False):
431
+ def create(exists_ok=False, wait_for_delete=False):
429
432
  logger.info("Creating resource %s%s%s", resource, status_msg,
430
433
  " (ignoring existing)" if exists_ok else "")
431
- try:
432
- create_func()
433
- except ApiException as e:
434
- if exists_ok:
435
- if e.status == 409:
436
- status = json.loads(e.body)
437
- if status["reason"] == "AlreadyExists":
438
- return
439
- raise
434
+ while True:
435
+ try:
436
+ create_func()
437
+ return
438
+ except ApiException as e:
439
+ if exists_ok or wait_for_delete:
440
+ if e.status == 409:
441
+ status = json.loads(e.body)
442
+ if status["reason"] == "AlreadyExists":
443
+ if wait_for_delete:
444
+ sleep(self.context.k8s.conflict_retry_delay)
445
+ logger.info("Retry creating resource %s%s%s", resource, status_msg,
446
+ " (ignoring existing)" if exists_ok else "")
447
+ continue
448
+ else:
449
+ return
450
+ raise
440
451
 
441
452
  merge_instrs, normalized_manifest = extract_merge_instructions(resource.manifest, resource)
442
453
  if merge_instrs:
@@ -471,7 +482,7 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
471
482
  if e.status == 422:
472
483
  status = json.loads(e.body)
473
484
  details = status["details"]
474
- immutable_key = details["group"], details["kind"]
485
+ immutable_key = details.get("group"), details["kind"]
475
486
 
476
487
  try:
477
488
  propagation_policy = self.context.k8s.immutable_changes[immutable_key]
@@ -484,13 +495,15 @@ class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
484
495
  "field is immutable" in cause["message"]
485
496
  or
486
497
  cause["reason"] == "FieldValueForbidden" and
487
- "Forbidden: updates to" in cause["message"]
498
+ ("Forbidden: updates to" in cause["message"]
499
+ or
500
+ "Forbidden: pod updates" in cause["message"])
488
501
  ):
489
502
  logger.info("Deleting resource %s (cascade %s)%s", resource,
490
503
  propagation_policy.policy,
491
504
  status_msg)
492
505
  delete_func(propagation_policy=propagation_policy)
493
- create(exists_ok=dry_run)
506
+ create(exists_ok=dry_run, wait_for_delete=not dry_run)
494
507
  return 1, 0, 1
495
508
  raise
496
509
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kubernator
3
- Version: 1.0.23.dev20251008231728
3
+ Version: 1.0.23.dev20251010010455
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.23.dev20251008231728',
24
+ version = '1.0.23.dev20251010010455',
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',