kubernator 1.0.22__tar.gz → 1.0.23.dev20251007071019__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.22 → kubernator-1.0.23.dev20251007071019}/PKG-INFO +1 -1
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/__init__.py +1 -1
- kubernator-1.0.23.dev20251007071019/kubernator/plugins/gke.py +105 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/plugins/minikube.py +13 -1
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator.egg-info/PKG-INFO +1 -1
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator.egg-info/SOURCES.txt +1 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/setup.py +1 -1
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/MANIFEST.in +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/LICENSE +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/__main__.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/_json_path.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/_k8s_client_patches.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/api.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/app.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/merge.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/plugins/__init__.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/plugins/awscli.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/plugins/eks.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/plugins/helm.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/plugins/istio.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/plugins/k8s.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/plugins/k8s_api.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/plugins/kops.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/plugins/kubeconfig.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/plugins/kubectl.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/plugins/template.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/plugins/terraform.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/plugins/terragrunt.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator/proc.py +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator.egg-info/dependency_links.txt +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator.egg-info/entry_points.txt +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator.egg-info/namespace_packages.txt +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator.egg-info/requires.txt +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator.egg-info/top_level.txt +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator.egg-info/zip-safe +0 -0
- {kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/setup.cfg +0 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright 2020 Express Systems USA, Inc
|
|
4
|
+
# Copyright 2025 Karellen, Inc.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
import logging
|
|
20
|
+
import os
|
|
21
|
+
import tempfile
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
from shutil import which
|
|
24
|
+
|
|
25
|
+
from kubernator.api import (KubernatorPlugin,
|
|
26
|
+
StripNL
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
logger = logging.getLogger("kubernator.gke")
|
|
30
|
+
proc_logger = logger.getChild("proc")
|
|
31
|
+
stdout_logger = StripNL(proc_logger.info)
|
|
32
|
+
stderr_logger = StripNL(proc_logger.warning)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class GkePlugin(KubernatorPlugin):
|
|
36
|
+
logger = logger
|
|
37
|
+
|
|
38
|
+
_name = "gke"
|
|
39
|
+
|
|
40
|
+
def __init__(self):
|
|
41
|
+
self.context = None
|
|
42
|
+
self.kubeconfig_dir = tempfile.TemporaryDirectory()
|
|
43
|
+
self.name = None
|
|
44
|
+
self.region = None
|
|
45
|
+
self.project = None
|
|
46
|
+
self.gcloud_file = None
|
|
47
|
+
|
|
48
|
+
super().__init__()
|
|
49
|
+
|
|
50
|
+
def set_context(self, context):
|
|
51
|
+
self.context = context
|
|
52
|
+
|
|
53
|
+
def register(self, *, name=None, region=None, project=None):
|
|
54
|
+
context = self.context
|
|
55
|
+
|
|
56
|
+
if not name:
|
|
57
|
+
raise ValueError("`name` is required")
|
|
58
|
+
if not region:
|
|
59
|
+
raise ValueError("`region` is required")
|
|
60
|
+
if not project:
|
|
61
|
+
raise ValueError("`project` is required")
|
|
62
|
+
|
|
63
|
+
self.name = name
|
|
64
|
+
self.region = region
|
|
65
|
+
self.project = project
|
|
66
|
+
|
|
67
|
+
# Use current version
|
|
68
|
+
gcloud_file = which("gcloud")
|
|
69
|
+
if not gcloud_file:
|
|
70
|
+
raise RuntimeError("`gcloud` cannot be found")
|
|
71
|
+
logger.debug("Found gcloud in %r", gcloud_file)
|
|
72
|
+
self.gcloud_file = gcloud_file
|
|
73
|
+
|
|
74
|
+
context.app.register_plugin("kubeconfig")
|
|
75
|
+
|
|
76
|
+
context.globals.gke = dict(kubeconfig=str(Path(self.kubeconfig_dir.name) / "config"),
|
|
77
|
+
name=name,
|
|
78
|
+
region=region,
|
|
79
|
+
project=project,
|
|
80
|
+
gcloud_file=gcloud_file
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
def handle_init(self):
|
|
84
|
+
context = self.context
|
|
85
|
+
|
|
86
|
+
env = dict(os.environ)
|
|
87
|
+
env["KUBECONFIG"] = str(context.gke.kubeconfig)
|
|
88
|
+
self.context.app.run([context.gke.gcloud_file, "components", "install", "gke-gcloud-auth-plugin"],
|
|
89
|
+
stdout_logger,
|
|
90
|
+
stderr_logger).wait()
|
|
91
|
+
self.context.app.run([context.gke.gcloud_file, "container", "clusters", "get-credentials",
|
|
92
|
+
context.gke.name,
|
|
93
|
+
"--region", context.gke.region,
|
|
94
|
+
"--project", context.gke.project],
|
|
95
|
+
stdout_logger,
|
|
96
|
+
stderr_logger,
|
|
97
|
+
env=env).wait()
|
|
98
|
+
|
|
99
|
+
context.kubeconfig.set(context.gke.kubeconfig)
|
|
100
|
+
|
|
101
|
+
def handle_shutdown(self):
|
|
102
|
+
self.kubeconfig_dir.cleanup()
|
|
103
|
+
|
|
104
|
+
def __repr__(self):
|
|
105
|
+
return "GKE Plugin"
|
|
@@ -91,7 +91,7 @@ class MinikubePlugin(KubernatorPlugin):
|
|
|
91
91
|
|
|
92
92
|
def register(self, minikube_version=None, profile="default", k8s_version=None,
|
|
93
93
|
keep_running=False, start_fresh=False,
|
|
94
|
-
nodes=1, driver=None, cpus="no-limit", extra_args=None):
|
|
94
|
+
nodes=1, driver=None, cpus="no-limit", extra_args=None, extra_addons=None):
|
|
95
95
|
context = self.context
|
|
96
96
|
|
|
97
97
|
context.app.register_plugin("kubeconfig")
|
|
@@ -166,12 +166,14 @@ class MinikubePlugin(KubernatorPlugin):
|
|
|
166
166
|
minikube_file=str(minikube_file),
|
|
167
167
|
profile=profile,
|
|
168
168
|
k8s_version=k8s_version,
|
|
169
|
+
k8s_version_tuple=k8s_version_tuple,
|
|
169
170
|
start_fresh=start_fresh,
|
|
170
171
|
keep_running=keep_running,
|
|
171
172
|
nodes=nodes,
|
|
172
173
|
driver=driver,
|
|
173
174
|
cpus=cpus,
|
|
174
175
|
extra_args=extra_args or [],
|
|
176
|
+
extra_addons=extra_addons or [],
|
|
175
177
|
kubeconfig=str(self.kubeconfig_dir / "config"),
|
|
176
178
|
cmd=self.cmd,
|
|
177
179
|
cmd_out=self.cmd_out
|
|
@@ -202,6 +204,16 @@ class MinikubePlugin(KubernatorPlugin):
|
|
|
202
204
|
"--wait", "apiserver",
|
|
203
205
|
"--nodes", str(minikube.nodes)]
|
|
204
206
|
|
|
207
|
+
addons = []
|
|
208
|
+
if minikube.k8s_version_tuple >= (1, 28):
|
|
209
|
+
addons += ["volumesnapshots", "csi-hostpath-driver"]
|
|
210
|
+
|
|
211
|
+
if minikube.extra_addons:
|
|
212
|
+
addons += minikube.extra_addons
|
|
213
|
+
|
|
214
|
+
if addons:
|
|
215
|
+
args += ["--addons", ",".join(addons)]
|
|
216
|
+
|
|
205
217
|
if minikube.driver == "docker":
|
|
206
218
|
args.extend(["--cpus", str(minikube.cpus)])
|
|
207
219
|
|
|
@@ -21,7 +21,7 @@ class install(_install):
|
|
|
21
21
|
if __name__ == '__main__':
|
|
22
22
|
setup(
|
|
23
23
|
name = 'kubernator',
|
|
24
|
-
version = '1.0.
|
|
24
|
+
version = '1.0.23.dev20251007071019',
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{kubernator-1.0.22 → kubernator-1.0.23.dev20251007071019}/kubernator.egg-info/namespace_packages.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|