kaqing 1.98.140__tar.gz → 2.0.2__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.
- {kaqing-1.98.140 → kaqing-2.0.2}/PKG-INFO +1 -1
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/deploy/undeploy_pod.py +12 -7
- kaqing-2.0.2/adam/k8s_utils/deployment.py +50 -0
- kaqing-2.0.2/adam/version.py +5 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/kaqing.egg-info/PKG-INFO +1 -1
- {kaqing-1.98.140 → kaqing-2.0.2}/setup.py +1 -1
- kaqing-1.98.140/adam/k8s_utils/deployment.py +0 -219
- kaqing-1.98.140/adam/version.py +0 -5
- {kaqing-1.98.140 → kaqing-2.0.2}/README +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/__init__.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/app_session.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/apps.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/batch.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/checks/__init__.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/checks/check.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/checks/check_context.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/checks/check_result.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/checks/check_utils.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/checks/compactionstats.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/checks/cpu.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/checks/disk.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/checks/gossip.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/checks/issue.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/checks/memory.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/checks/status.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/cli.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/cli_group.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/__init__.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/column.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/columns.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/compactions.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/cpu.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/dir_data.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/dir_snapshots.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/gossip.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/host_id.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/memory.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/node_address.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/node_load.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/node_owns.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/node_status.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/node_tokens.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/node_utils.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/pod_name.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/volume_cassandra.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/columns/volume_root.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/__init__.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/app.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/app_ping.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/bash.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/cd.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/check.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/cli_commands.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/command.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/command_helpers.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/commands_utils.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/cp.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/cql_utils.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/cqlsh.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/deploy/__init__.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/deploy/code_start.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/deploy/code_stop.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/deploy/code_utils.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/deploy/deploy.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/deploy/deploy_frontend.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/deploy/deploy_pod.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/deploy/deploy_utils.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/deploy/undeploy.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/deploy/undeploy_frontend.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/devices.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/exit.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/help.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/issues.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/login.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/logs.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/ls.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/medusa/__init__.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/medusa/medusa.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/medusa/medusa_backup.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/medusa/medusa_restore.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/medusa/medusa_show_backupjobs.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/medusa/medusa_show_restorejobs.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/nodetool.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/nodetool_commands.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/param_get.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/param_set.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/postgres/__init__.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/postgres/postgres.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/postgres/postgres_ls.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/postgres/postgres_preview.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/postgres/postgres_session.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/preview_table.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/pwd.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/reaper/__init__.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/reaper/reaper.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/reaper/reaper_forward.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/reaper/reaper_forward_stop.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/reaper/reaper_restart.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/reaper/reaper_run_abort.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/reaper/reaper_runs.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/reaper/reaper_runs_abort.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/reaper/reaper_schedule_activate.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/reaper/reaper_schedule_start.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/reaper/reaper_schedule_stop.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/reaper/reaper_schedules.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/reaper/reaper_session.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/reaper/reaper_status.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/repair/__init__.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/repair/repair.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/repair/repair_log.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/repair/repair_run.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/repair/repair_scan.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/repair/repair_stop.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/report.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/restart.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/rollout.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/shell.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/show/__init__.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/show/show.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/show/show_adam.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/show/show_app_actions.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/show/show_app_id.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/show/show_app_queues.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/show/show_cassandra_status.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/show/show_cassandra_version.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/show/show_commands.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/show/show_login.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/show/show_params.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/show/show_processes.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/show/show_repairs.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/show/show_storage.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/commands/watch.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/config.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/embedded_apps.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/embedded_params.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/k8s_utils/__init__.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/k8s_utils/cassandra_clusters.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/k8s_utils/cassandra_nodes.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/k8s_utils/custom_resources.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/k8s_utils/ingresses.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/k8s_utils/jobs.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/k8s_utils/kube_context.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/k8s_utils/pods.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/k8s_utils/secrets.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/k8s_utils/service_accounts.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/k8s_utils/services.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/k8s_utils/statefulsets.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/k8s_utils/volumes.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/log.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/pod_exec_result.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/repl.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/repl_commands.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/repl_session.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/repl_state.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/sso/__init__.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/sso/authenticator.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/sso/authn_ad.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/sso/authn_okta.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/sso/cred_cache.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/sso/id_token.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/sso/idp.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/sso/idp_login.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/sso/idp_session.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/sso/sso_config.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/adam/utils.py +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/kaqing.egg-info/SOURCES.txt +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/kaqing.egg-info/dependency_links.txt +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/kaqing.egg-info/entry_points.txt +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/kaqing.egg-info/top_level.txt +0 -0
- {kaqing-1.98.140 → kaqing-2.0.2}/setup.cfg +0 -0
@@ -34,15 +34,20 @@ class UndeployPod(Command):
|
|
34
34
|
if not self.validate_state(state):
|
35
35
|
return state
|
36
36
|
|
37
|
-
if KubeContext.in_cluster():
|
38
|
-
log2('This is doable only from outside of the Kubernetes cluster.')
|
39
|
-
return state
|
40
|
-
|
41
37
|
label_selector = Config().get('pod.label-selector', 'run=ops')
|
42
|
-
|
43
|
-
|
38
|
+
try:
|
39
|
+
ServiceAccounts.delete(state.namespace, label_selector=label_selector)
|
40
|
+
except Exception as e:
|
41
|
+
log2(e)
|
42
|
+
try:
|
43
|
+
Deployments.delete_with_selector(state.namespace, label_selector, grace_period_seconds=0)
|
44
|
+
except Exception as e:
|
45
|
+
log2(e)
|
44
46
|
# instantly destroy the pod
|
45
|
-
|
47
|
+
try:
|
48
|
+
Pods.delete_with_selector(state.namespace, label_selector, grace_period_seconds=0)
|
49
|
+
except Exception as e:
|
50
|
+
log2(e)
|
46
51
|
undeploy_frontend(state.namespace, label_selector)
|
47
52
|
|
48
53
|
return state
|
@@ -0,0 +1,50 @@
|
|
1
|
+
from kubernetes import client
|
2
|
+
|
3
|
+
from adam.k8s_utils.pods import Pods
|
4
|
+
|
5
|
+
# utility collection on deployments; methods are all static
|
6
|
+
class Deployments:
|
7
|
+
def delete_with_selector(namespace: str, label_selector: str, grace_period_seconds: int = None):
|
8
|
+
v1 = client.AppsV1Api()
|
9
|
+
|
10
|
+
ret = v1.list_namespaced_deployment(namespace=namespace, label_selector=label_selector)
|
11
|
+
for i in ret.items:
|
12
|
+
v1.delete_namespaced_deployment(name=i.metadata.name, namespace=namespace, grace_period_seconds=grace_period_seconds)
|
13
|
+
|
14
|
+
def create_deployment_spec(name: str, image: str, image_pull_secret: str,
|
15
|
+
envs: list, container_security_context: client.V1SecurityContext,
|
16
|
+
volume_name: str, pvc_name:str, mount_path:str,
|
17
|
+
command: list[str]=None, sa_name=None, labels: dict[str, str] = {}):
|
18
|
+
return client.V1DeploymentSpec(
|
19
|
+
replicas=1,
|
20
|
+
selector=client.V1LabelSelector(match_labels=labels),
|
21
|
+
template=client.V1PodTemplateSpec(
|
22
|
+
metadata=client.V1ObjectMeta(labels=labels),
|
23
|
+
spec=Pods.create_pod_spec(name, image, image_pull_secret, envs, container_security_context,
|
24
|
+
volume_name, pvc_name, mount_path, command=command, sa_name=sa_name,
|
25
|
+
restart_policy="Always"),
|
26
|
+
),
|
27
|
+
)
|
28
|
+
|
29
|
+
def create(namespace: str, deployment_name: str, image: str,
|
30
|
+
command: list[str] = None,
|
31
|
+
secret: str = None,
|
32
|
+
env: dict[str, any] = {},
|
33
|
+
container_security_context: client.V1SecurityContext = None,
|
34
|
+
labels: dict[str, str] = {},
|
35
|
+
volume_name: str = None,
|
36
|
+
pvc_name: str = None,
|
37
|
+
mount_path: str = None,
|
38
|
+
sa_name=None):
|
39
|
+
v1 = client.AppsV1Api()
|
40
|
+
envs = []
|
41
|
+
for k, v in env.items():
|
42
|
+
envs.append(client.V1EnvVar(name=str(k), value=str(v)))
|
43
|
+
deployment = Deployments.create_deployment_spec(deployment_name, image, secret, envs, container_security_context, volume_name, pvc_name, mount_path, command=command, sa_name=sa_name, labels=labels)
|
44
|
+
return v1.create_namespaced_deployment(
|
45
|
+
namespace=namespace,
|
46
|
+
body=client.V1Deployment(spec=deployment, metadata=client.V1ObjectMeta(
|
47
|
+
name=deployment_name,
|
48
|
+
labels=labels
|
49
|
+
))
|
50
|
+
)
|
@@ -1,219 +0,0 @@
|
|
1
|
-
from collections.abc import Callable
|
2
|
-
from concurrent.futures import ThreadPoolExecutor, as_completed
|
3
|
-
import sys
|
4
|
-
import time
|
5
|
-
from typing import TypeVar, cast
|
6
|
-
from kubernetes import client
|
7
|
-
from kubernetes.stream import stream
|
8
|
-
from kubernetes.stream.ws_client import ERROR_CHANNEL
|
9
|
-
|
10
|
-
from adam.config import Config
|
11
|
-
from adam.k8s_utils.pods import Pods
|
12
|
-
from adam.pod_exec_result import PodExecResult
|
13
|
-
from adam.utils import elapsed_time, log2
|
14
|
-
from .kube_context import KubeContext
|
15
|
-
|
16
|
-
T = TypeVar('T')
|
17
|
-
_TEST_POD_EXEC_OUTS: PodExecResult = None
|
18
|
-
|
19
|
-
# utility collection on deployments; methods are all static
|
20
|
-
class Deployments:
|
21
|
-
def set_test_pod_exec_outs(outs: PodExecResult):
|
22
|
-
global _TEST_POD_EXEC_OUTS
|
23
|
-
_TEST_POD_EXEC_OUTS = outs
|
24
|
-
|
25
|
-
return _TEST_POD_EXEC_OUTS
|
26
|
-
|
27
|
-
def delete(pod_name: str, namespace: str):
|
28
|
-
try:
|
29
|
-
v1 = client.CoreV1Api()
|
30
|
-
api_response = v1.delete_namespaced_pod(pod_name, namespace)
|
31
|
-
except Exception as e:
|
32
|
-
log2("Exception when calling CoreV1Api->delete_namespaced_pod: %s\n" % e)
|
33
|
-
|
34
|
-
def delete_with_selector(namespace: str, label_selector: str, grace_period_seconds: int = None):
|
35
|
-
v1 = client.AppsV1Api()
|
36
|
-
|
37
|
-
ret = v1.list_namespaced_deployment(namespace=namespace, label_selector=label_selector)
|
38
|
-
for i in ret.items:
|
39
|
-
v1.delete_namespaced_deployment(name=i.metadata.name, namespace=namespace, grace_period_seconds=grace_period_seconds)
|
40
|
-
|
41
|
-
def on_pods(pods: list[str],
|
42
|
-
namespace: str,
|
43
|
-
body: Callable[[ThreadPoolExecutor, str, str, bool], T],
|
44
|
-
post: Callable[[T], T] = None,
|
45
|
-
action: str = 'action', max_workers=0, show_out=True) -> list[T]:
|
46
|
-
show_out = KubeContext.show_out(show_out)
|
47
|
-
|
48
|
-
if not max_workers:
|
49
|
-
max_workers = Config().action_workers(action, 0)
|
50
|
-
if max_workers > 0:
|
51
|
-
# if parallel, node sampling is suppressed
|
52
|
-
if KubeContext.show_parallelism():
|
53
|
-
log2(f'Executing on all nodes from statefulset in parallel...')
|
54
|
-
start_time = time.time()
|
55
|
-
try:
|
56
|
-
with ThreadPoolExecutor(max_workers=max_workers) as executor:
|
57
|
-
# disable stdout from the pod_exec, then show the output in a for loop
|
58
|
-
futures = [body(executor, pod, namespace, show_out) for pod in pods]
|
59
|
-
if len(futures) == 0:
|
60
|
-
return cast(list[T], [])
|
61
|
-
|
62
|
-
rs = [future.result() for future in as_completed(futures)]
|
63
|
-
if post:
|
64
|
-
rs = [post(r, show_out=show_out) for r in rs]
|
65
|
-
|
66
|
-
return rs
|
67
|
-
finally:
|
68
|
-
if KubeContext.show_parallelism():
|
69
|
-
log2(f"Parallel {action} elapsed time: {elapsed_time(start_time)} with {max_workers} workers")
|
70
|
-
else:
|
71
|
-
results: list[T] = []
|
72
|
-
|
73
|
-
samples = Config().action_node_samples(action, sys.maxsize)
|
74
|
-
l = min(len(pods), samples)
|
75
|
-
adj = 'all'
|
76
|
-
if l < len(pods):
|
77
|
-
adj = f'{l} sample'
|
78
|
-
if show_out:
|
79
|
-
log2(f'Executing on {adj} nodes from statefulset...')
|
80
|
-
for pod_name in pods:
|
81
|
-
try:
|
82
|
-
result = body(None, pod_name, namespace, show_out)
|
83
|
-
if post:
|
84
|
-
result = post(result, show_out=show_out)
|
85
|
-
results.append(result)
|
86
|
-
if result:
|
87
|
-
l -= 1
|
88
|
-
if not l:
|
89
|
-
break
|
90
|
-
except Exception as e:
|
91
|
-
log2(e)
|
92
|
-
|
93
|
-
return results
|
94
|
-
|
95
|
-
def exec(pod_name: str, container: str, namespace: str, command: str, show_out = True, throw_err = False, interaction: Callable[[any, list[str]], any] = None):
|
96
|
-
if _TEST_POD_EXEC_OUTS:
|
97
|
-
return _TEST_POD_EXEC_OUTS
|
98
|
-
|
99
|
-
show_out = KubeContext.show_out(show_out)
|
100
|
-
|
101
|
-
api = client.CoreV1Api()
|
102
|
-
|
103
|
-
exec_command = ["/bin/sh", "-c", command]
|
104
|
-
k_command = f'kubectl exec {pod_name} -c {container} -n {namespace} -- {command}'
|
105
|
-
if show_out:
|
106
|
-
print(k_command)
|
107
|
-
|
108
|
-
resp = stream(
|
109
|
-
api.connect_get_namespaced_pod_exec,
|
110
|
-
pod_name,
|
111
|
-
namespace,
|
112
|
-
command=exec_command,
|
113
|
-
container=container,
|
114
|
-
stderr=True,
|
115
|
-
stdin=True,
|
116
|
-
stdout=True,
|
117
|
-
tty=True,
|
118
|
-
_preload_content=False,
|
119
|
-
)
|
120
|
-
|
121
|
-
stdout = []
|
122
|
-
stderr = []
|
123
|
-
error_output = None
|
124
|
-
try:
|
125
|
-
while resp.is_open():
|
126
|
-
resp.update(timeout=1)
|
127
|
-
if resp.peek_stdout():
|
128
|
-
frag = resp.read_stdout()
|
129
|
-
stdout.append(frag)
|
130
|
-
if show_out: print(frag, end="")
|
131
|
-
|
132
|
-
if interaction:
|
133
|
-
interaction(resp, stdout)
|
134
|
-
if resp.peek_stderr():
|
135
|
-
frag = resp.read_stderr()
|
136
|
-
stderr.append(frag)
|
137
|
-
if show_out: print(frag, end="")
|
138
|
-
|
139
|
-
try:
|
140
|
-
# get the exit code from server
|
141
|
-
error_output = resp.read_channel(ERROR_CHANNEL)
|
142
|
-
except Exception:
|
143
|
-
pass
|
144
|
-
except Exception as e:
|
145
|
-
if throw_err:
|
146
|
-
raise e
|
147
|
-
else:
|
148
|
-
log2(e)
|
149
|
-
finally:
|
150
|
-
resp.close()
|
151
|
-
|
152
|
-
return PodExecResult("".join(stdout), "".join(stderr), k_command, error_output)
|
153
|
-
|
154
|
-
def get_container(namespace: str, pod_name: str, container_name: str):
|
155
|
-
pod = Pods.get(namespace, pod_name)
|
156
|
-
if not pod:
|
157
|
-
return None
|
158
|
-
|
159
|
-
for container in pod.spec.containers:
|
160
|
-
if container_name == container.name:
|
161
|
-
return container
|
162
|
-
|
163
|
-
return None
|
164
|
-
|
165
|
-
def get(namespace: str, pod_name: str):
|
166
|
-
v1 = client.CoreV1Api()
|
167
|
-
return v1.read_namespaced_pod(name=pod_name, namespace=namespace)
|
168
|
-
|
169
|
-
def create_deployment_spec(name: str, image: str, image_pull_secret: str,
|
170
|
-
envs: list, container_security_context: client.V1SecurityContext,
|
171
|
-
volume_name: str, pvc_name:str, mount_path:str,
|
172
|
-
command: list[str]=None, sa_name=None, labels: dict[str, str] = {}):
|
173
|
-
return client.V1DeploymentSpec(
|
174
|
-
replicas=1,
|
175
|
-
selector=client.V1LabelSelector(match_labels=labels),
|
176
|
-
template=client.V1PodTemplateSpec(
|
177
|
-
metadata=client.V1ObjectMeta(labels=labels),
|
178
|
-
spec=Pods.create_pod_spec(name, image, image_pull_secret, envs, container_security_context,
|
179
|
-
volume_name, pvc_name, mount_path, command=command, sa_name=sa_name,
|
180
|
-
restart_policy="Always"),
|
181
|
-
),
|
182
|
-
)
|
183
|
-
|
184
|
-
def create(namespace: str, deployment_name: str, image: str,
|
185
|
-
command: list[str] = None,
|
186
|
-
secret: str = None,
|
187
|
-
env: dict[str, any] = {},
|
188
|
-
container_security_context: client.V1SecurityContext = None,
|
189
|
-
labels: dict[str, str] = {},
|
190
|
-
volume_name: str = None,
|
191
|
-
pvc_name: str = None,
|
192
|
-
mount_path: str = None,
|
193
|
-
sa_name=None):
|
194
|
-
v1 = client.AppsV1Api()
|
195
|
-
envs = []
|
196
|
-
for k, v in env.items():
|
197
|
-
envs.append(client.V1EnvVar(name=str(k), value=str(v)))
|
198
|
-
deployment = Deployments.create_deployment_spec(deployment_name, image, secret, envs, container_security_context, volume_name, pvc_name, mount_path, command=command, sa_name=sa_name, labels=labels)
|
199
|
-
return v1.create_namespaced_deployment(
|
200
|
-
namespace=namespace,
|
201
|
-
body=client.V1Deployment(spec=deployment, metadata=client.V1ObjectMeta(
|
202
|
-
name=deployment_name,
|
203
|
-
labels=labels
|
204
|
-
))
|
205
|
-
)
|
206
|
-
|
207
|
-
def wait_for_running(namespace: str, pod_name: str, msg: str=None):
|
208
|
-
msged = False
|
209
|
-
|
210
|
-
while Pods.get(namespace, pod_name).status.phase != 'Running':
|
211
|
-
if not msged:
|
212
|
-
if not msg:
|
213
|
-
msg = f'Waiting for the {pod_name} pod to start up...'
|
214
|
-
log2(msg)
|
215
|
-
msged = True
|
216
|
-
time.sleep(5)
|
217
|
-
|
218
|
-
def completed(namespace: str, pod_name: str):
|
219
|
-
return Pods.get(namespace, pod_name).status.phase in ['Succeeded', 'Failed']
|
kaqing-1.98.140/adam/version.py
DELETED
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
|
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
|
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
|
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
|
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
|
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
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|