kaqing 1.98.139__tar.gz → 1.98.140__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.139 → kaqing-1.98.140}/PKG-INFO +1 -1
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/deploy/deploy.py +0 -1
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/deploy/deploy_frontend.py +0 -3
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/deploy/deploy_pod.py +4 -4
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/deploy/deploy_utils.py +0 -2
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/deploy/undeploy.py +0 -2
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/deploy/undeploy_frontend.py +0 -2
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/deploy/undeploy_pod.py +6 -6
- kaqing-1.98.140/adam/k8s_utils/deployment.py +219 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/k8s_utils/pods.py +14 -4
- kaqing-1.98.140/adam/version.py +5 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/kaqing.egg-info/PKG-INFO +1 -1
- {kaqing-1.98.139 → kaqing-1.98.140}/kaqing.egg-info/SOURCES.txt +1 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/setup.py +1 -1
- kaqing-1.98.139/adam/version.py +0 -5
- {kaqing-1.98.139 → kaqing-1.98.140}/README +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/app_session.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/apps.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/batch.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/checks/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/checks/check.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/checks/check_context.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/checks/check_result.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/checks/check_utils.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/checks/compactionstats.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/checks/cpu.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/checks/disk.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/checks/gossip.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/checks/issue.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/checks/memory.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/checks/status.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/cli.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/cli_group.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/column.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/columns.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/compactions.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/cpu.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/dir_data.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/dir_snapshots.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/gossip.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/host_id.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/memory.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/node_address.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/node_load.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/node_owns.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/node_status.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/node_tokens.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/node_utils.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/pod_name.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/volume_cassandra.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/columns/volume_root.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/app.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/app_ping.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/bash.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/cd.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/check.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/cli_commands.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/command.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/command_helpers.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/commands_utils.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/cp.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/cql_utils.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/cqlsh.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/deploy/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/deploy/code_start.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/deploy/code_stop.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/deploy/code_utils.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/devices.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/exit.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/help.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/issues.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/login.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/logs.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/ls.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/medusa/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/medusa/medusa.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/medusa/medusa_backup.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/medusa/medusa_restore.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/medusa/medusa_show_backupjobs.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/medusa/medusa_show_restorejobs.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/nodetool.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/nodetool_commands.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/param_get.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/param_set.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/postgres/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/postgres/postgres.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/postgres/postgres_ls.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/postgres/postgres_preview.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/postgres/postgres_session.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/preview_table.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/pwd.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/reaper/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/reaper/reaper.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/reaper/reaper_forward.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/reaper/reaper_forward_stop.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/reaper/reaper_restart.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/reaper/reaper_run_abort.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/reaper/reaper_runs.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/reaper/reaper_runs_abort.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/reaper/reaper_schedule_activate.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/reaper/reaper_schedule_start.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/reaper/reaper_schedule_stop.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/reaper/reaper_schedules.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/reaper/reaper_session.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/reaper/reaper_status.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/repair/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/repair/repair.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/repair/repair_log.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/repair/repair_run.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/repair/repair_scan.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/repair/repair_stop.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/report.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/restart.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/rollout.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/shell.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/show/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/show/show.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/show/show_adam.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/show/show_app_actions.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/show/show_app_id.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/show/show_app_queues.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/show/show_cassandra_status.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/show/show_cassandra_version.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/show/show_commands.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/show/show_login.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/show/show_params.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/show/show_processes.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/show/show_repairs.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/show/show_storage.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/commands/watch.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/config.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/embedded_apps.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/embedded_params.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/k8s_utils/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/k8s_utils/cassandra_clusters.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/k8s_utils/cassandra_nodes.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/k8s_utils/custom_resources.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/k8s_utils/ingresses.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/k8s_utils/jobs.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/k8s_utils/kube_context.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/k8s_utils/secrets.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/k8s_utils/service_accounts.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/k8s_utils/services.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/k8s_utils/statefulsets.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/k8s_utils/volumes.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/log.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/pod_exec_result.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/repl.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/repl_commands.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/repl_session.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/repl_state.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/sso/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/sso/authenticator.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/sso/authn_ad.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/sso/authn_okta.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/sso/cred_cache.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/sso/id_token.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/sso/idp.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/sso/idp_login.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/sso/idp_session.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/sso/sso_config.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/adam/utils.py +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/kaqing.egg-info/dependency_links.txt +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/kaqing.egg-info/entry_points.txt +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/kaqing.egg-info/top_level.txt +0 -0
- {kaqing-1.98.139 → kaqing-1.98.140}/setup.cfg +0 -0
@@ -1,9 +1,6 @@
|
|
1
|
-
from adam.app_session import AppSession
|
2
1
|
from adam.commands.command import Command
|
3
2
|
from adam.commands.deploy.deploy_utils import deploy_frontend
|
4
3
|
from adam.config import Config
|
5
|
-
from adam.k8s_utils.ingresses import Ingresses
|
6
|
-
from adam.k8s_utils.services import Services
|
7
4
|
from adam.repl_state import ReplState, RequiredState
|
8
5
|
from adam.utils import log2
|
9
6
|
|
@@ -3,11 +3,10 @@ from kubernetes import client
|
|
3
3
|
from adam.commands.command import Command
|
4
4
|
from adam.commands.deploy.deploy_utils import deploy_frontend, gen_labels
|
5
5
|
from adam.config import Config
|
6
|
-
from adam.k8s_utils.
|
6
|
+
from adam.k8s_utils.deployment import Deployments
|
7
7
|
from adam.k8s_utils.kube_context import KubeContext
|
8
8
|
from adam.k8s_utils.pods import Pods
|
9
9
|
from adam.k8s_utils.service_accounts import ServiceAccounts
|
10
|
-
from adam.k8s_utils.services import Services
|
11
10
|
from adam.repl_state import ReplState, RequiredState
|
12
11
|
from adam.utils import log2
|
13
12
|
|
@@ -55,11 +54,12 @@ class DeployPod(Command):
|
|
55
54
|
add=["SYS_PTRACE"]
|
56
55
|
)
|
57
56
|
)
|
58
|
-
|
57
|
+
Deployments.create(state.namespace, pod_name, image, env={'NAMESPACE': state.namespace}, container_security_context=security_context, labels=labels, sa_name=sa_name)
|
59
58
|
|
60
59
|
uri = deploy_frontend(pod_name, state.namespace, label_selector)
|
61
60
|
|
62
|
-
Pods.wait_for_running(state.namespace,
|
61
|
+
# Pods.wait_for_running(state.namespace, label_selector, msg=f'Ops pod is starting up; it will be available at {uri}.')
|
62
|
+
Pods.wait_for_running(state.namespace, pod_name, msg=f'Ops pod is starting up; it will be available at {uri}.', label_selector=label_selector)
|
63
63
|
|
64
64
|
return state
|
65
65
|
|
@@ -1,14 +1,12 @@
|
|
1
1
|
from adam.app_session import AppSession
|
2
2
|
from adam.k8s_utils.ingresses import Ingresses
|
3
3
|
from adam.k8s_utils.services import Services
|
4
|
-
from adam.utils import log2
|
5
4
|
|
6
5
|
def deploy_frontend(name: str, namespace: str, label_selector: str):
|
7
6
|
app_session: AppSession = AppSession.create('c3', 'c3', namespace)
|
8
7
|
port = 7678
|
9
8
|
labels = gen_labels(label_selector)
|
10
9
|
Services.create_service(name, namespace, port, labels, labels=labels)
|
11
|
-
# Services.create_service(name, namespace, port, {"run": "ops"})
|
12
10
|
Ingresses.create_ingress(name, namespace, app_session.host, '/c3/c3/ops($|/)', port, annotations={
|
13
11
|
'kubernetes.io/ingress.class': 'nginx',
|
14
12
|
'nginx.ingress.kubernetes.io/use-regex': 'true',
|
@@ -1,10 +1,8 @@
|
|
1
1
|
import click
|
2
2
|
|
3
3
|
from adam.commands.command import Command
|
4
|
-
from adam.commands.command_helpers import ClusterCommandHelper
|
5
4
|
from adam.commands.deploy.undeploy_frontend import UndeployFrontend
|
6
5
|
from adam.commands.deploy.undeploy_pod import UndeployPod
|
7
|
-
from .deploy_frontend import DeployFrontend
|
8
6
|
from adam.repl_state import ReplState
|
9
7
|
from adam.utils import lines_to_tabular, log, log2
|
10
8
|
|
@@ -1,8 +1,6 @@
|
|
1
1
|
from adam.commands.command import Command
|
2
2
|
from adam.commands.deploy.deploy_utils import undeploy_frontend
|
3
3
|
from adam.config import Config
|
4
|
-
from adam.k8s_utils.ingresses import Ingresses
|
5
|
-
from adam.k8s_utils.services import Services
|
6
4
|
from adam.repl_state import ReplState, RequiredState
|
7
5
|
|
8
6
|
class UndeployFrontend(Command):
|
@@ -1,12 +1,10 @@
|
|
1
|
-
from adam.app_session import AppSession
|
2
1
|
from adam.commands.command import Command
|
3
|
-
from adam.commands.deploy.deploy_utils import
|
2
|
+
from adam.commands.deploy.deploy_utils import undeploy_frontend
|
4
3
|
from adam.config import Config
|
5
|
-
from adam.k8s_utils.
|
4
|
+
from adam.k8s_utils.deployment import Deployments
|
6
5
|
from adam.k8s_utils.kube_context import KubeContext
|
7
6
|
from adam.k8s_utils.pods import Pods
|
8
7
|
from adam.k8s_utils.service_accounts import ServiceAccounts
|
9
|
-
from adam.k8s_utils.services import Services
|
10
8
|
from adam.repl_state import ReplState, RequiredState
|
11
9
|
from adam.utils import log2
|
12
10
|
|
@@ -41,9 +39,11 @@ class UndeployPod(Command):
|
|
41
39
|
return state
|
42
40
|
|
43
41
|
label_selector = Config().get('pod.label-selector', 'run=ops')
|
44
|
-
undeploy_frontend(state.namespace, label_selector)
|
45
|
-
Pods.delete_with_selector(state.namespace, label_selector, grace_period_seconds=0)
|
46
42
|
ServiceAccounts.delete(state.namespace, label_selector=label_selector)
|
43
|
+
Deployments.delete_with_selector(state.namespace, label_selector, grace_period_seconds=0)
|
44
|
+
# instantly destroy the pod
|
45
|
+
Pods.delete_with_selector(state.namespace, label_selector, grace_period_seconds=0)
|
46
|
+
undeploy_frontend(state.namespace, label_selector)
|
47
47
|
|
48
48
|
return state
|
49
49
|
|
@@ -0,0 +1,219 @@
|
|
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']
|
@@ -165,7 +165,17 @@ class Pods:
|
|
165
165
|
v1 = client.CoreV1Api()
|
166
166
|
return v1.read_namespaced_pod(name=pod_name, namespace=namespace)
|
167
167
|
|
168
|
-
def
|
168
|
+
def get_with_selector(namespace: str, label_selector: str):
|
169
|
+
v1 = client.CoreV1Api()
|
170
|
+
|
171
|
+
ret = v1.list_namespaced_pod(namespace=namespace, label_selector=label_selector)
|
172
|
+
for i in ret.items:
|
173
|
+
return v1.read_namespaced_pod(name=i.metadata.name, namespace=namespace)
|
174
|
+
|
175
|
+
def create_pod_spec(name: str, image: str, image_pull_secret: str,
|
176
|
+
envs: list, container_security_context: client.V1SecurityContext,
|
177
|
+
volume_name: str, pvc_name:str, mount_path:str,
|
178
|
+
command: list[str]=None, sa_name=None, restart_policy="Never"):
|
169
179
|
volume_mounts = []
|
170
180
|
if volume_name and pvc_name and mount_path:
|
171
181
|
volume_mounts=[client.V1VolumeMount(mount_path=mount_path, name=volume_name)]
|
@@ -182,7 +192,7 @@ class Pods:
|
|
182
192
|
security_context=client.V1PodSecurityContext(run_as_user=1001, run_as_group=1001, fs_group=1001)
|
183
193
|
|
184
194
|
return client.V1PodSpec(
|
185
|
-
restart_policy=
|
195
|
+
restart_policy=restart_policy,
|
186
196
|
containers=[container],
|
187
197
|
image_pull_secrets=[client.V1LocalObjectReference(name=image_pull_secret)],
|
188
198
|
security_context=security_context,
|
@@ -213,10 +223,10 @@ class Pods:
|
|
213
223
|
))
|
214
224
|
)
|
215
225
|
|
216
|
-
def wait_for_running(namespace: str, pod_name: str, msg: str=None):
|
226
|
+
def wait_for_running(namespace: str, pod_name: str, msg: str=None, label_selector: str = None):
|
217
227
|
msged = False
|
218
228
|
|
219
|
-
while Pods.get(namespace, pod_name).status.phase != 'Running':
|
229
|
+
while (Pods.get_with_selector(namespace, label_selector) if label_selector else Pods.get(namespace, pod_name)).status.phase != 'Running':
|
220
230
|
if not msged:
|
221
231
|
if not msg:
|
222
232
|
msg = f'Waiting for the {pod_name} pod to start up...'
|
@@ -139,6 +139,7 @@ adam/k8s_utils/__init__.py
|
|
139
139
|
adam/k8s_utils/cassandra_clusters.py
|
140
140
|
adam/k8s_utils/cassandra_nodes.py
|
141
141
|
adam/k8s_utils/custom_resources.py
|
142
|
+
adam/k8s_utils/deployment.py
|
142
143
|
adam/k8s_utils/ingresses.py
|
143
144
|
adam/k8s_utils/jobs.py
|
144
145
|
adam/k8s_utils/kube_context.py
|
kaqing-1.98.139/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
|