kaqing 1.98.139__tar.gz → 2.0.1__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-2.0.1}/PKG-INFO +1 -1
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/deploy/deploy.py +0 -1
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/deploy/deploy_frontend.py +0 -3
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/deploy/deploy_pod.py +4 -4
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/deploy/deploy_utils.py +0 -2
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/deploy/undeploy.py +0 -2
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/deploy/undeploy_frontend.py +0 -2
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/deploy/undeploy_pod.py +15 -10
- kaqing-2.0.1/adam/k8s_utils/deployment.py +50 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/k8s_utils/pods.py +14 -4
- kaqing-2.0.1/adam/version.py +5 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/kaqing.egg-info/PKG-INFO +1 -1
- {kaqing-1.98.139 → kaqing-2.0.1}/kaqing.egg-info/SOURCES.txt +1 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/setup.py +1 -1
- kaqing-1.98.139/adam/version.py +0 -5
- {kaqing-1.98.139 → kaqing-2.0.1}/README +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/app_session.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/apps.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/batch.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/checks/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/checks/check.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/checks/check_context.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/checks/check_result.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/checks/check_utils.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/checks/compactionstats.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/checks/cpu.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/checks/disk.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/checks/gossip.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/checks/issue.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/checks/memory.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/checks/status.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/cli.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/cli_group.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/column.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/columns.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/compactions.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/cpu.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/dir_data.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/dir_snapshots.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/gossip.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/host_id.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/memory.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/node_address.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/node_load.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/node_owns.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/node_status.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/node_tokens.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/node_utils.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/pod_name.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/volume_cassandra.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/columns/volume_root.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/app.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/app_ping.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/bash.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/cd.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/check.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/cli_commands.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/command.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/command_helpers.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/commands_utils.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/cp.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/cql_utils.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/cqlsh.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/deploy/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/deploy/code_start.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/deploy/code_stop.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/deploy/code_utils.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/devices.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/exit.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/help.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/issues.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/login.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/logs.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/ls.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/medusa/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/medusa/medusa.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/medusa/medusa_backup.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/medusa/medusa_restore.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/medusa/medusa_show_backupjobs.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/medusa/medusa_show_restorejobs.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/nodetool.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/nodetool_commands.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/param_get.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/param_set.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/postgres/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/postgres/postgres.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/postgres/postgres_ls.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/postgres/postgres_preview.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/postgres/postgres_session.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/preview_table.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/pwd.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/reaper/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/reaper/reaper.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/reaper/reaper_forward.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/reaper/reaper_forward_stop.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/reaper/reaper_restart.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/reaper/reaper_run_abort.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/reaper/reaper_runs.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/reaper/reaper_runs_abort.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/reaper/reaper_schedule_activate.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/reaper/reaper_schedule_start.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/reaper/reaper_schedule_stop.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/reaper/reaper_schedules.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/reaper/reaper_session.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/reaper/reaper_status.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/repair/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/repair/repair.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/repair/repair_log.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/repair/repair_run.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/repair/repair_scan.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/repair/repair_stop.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/report.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/restart.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/rollout.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/shell.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/show/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/show/show.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/show/show_adam.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/show/show_app_actions.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/show/show_app_id.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/show/show_app_queues.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/show/show_cassandra_status.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/show/show_cassandra_version.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/show/show_commands.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/show/show_login.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/show/show_params.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/show/show_processes.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/show/show_repairs.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/show/show_storage.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/commands/watch.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/config.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/embedded_apps.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/embedded_params.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/k8s_utils/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/k8s_utils/cassandra_clusters.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/k8s_utils/cassandra_nodes.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/k8s_utils/custom_resources.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/k8s_utils/ingresses.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/k8s_utils/jobs.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/k8s_utils/kube_context.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/k8s_utils/secrets.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/k8s_utils/service_accounts.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/k8s_utils/services.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/k8s_utils/statefulsets.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/k8s_utils/volumes.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/log.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/pod_exec_result.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/repl.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/repl_commands.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/repl_session.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/repl_state.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/sso/__init__.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/sso/authenticator.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/sso/authn_ad.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/sso/authn_okta.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/sso/cred_cache.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/sso/id_token.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/sso/idp.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/sso/idp_login.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/sso/idp_session.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/sso/sso_config.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/adam/utils.py +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/kaqing.egg-info/dependency_links.txt +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/kaqing.egg-info/entry_points.txt +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/kaqing.egg-info/top_level.txt +0 -0
- {kaqing-1.98.139 → kaqing-2.0.1}/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
|
|
@@ -36,14 +34,21 @@ class UndeployPod(Command):
|
|
36
34
|
if not self.validate_state(state):
|
37
35
|
return state
|
38
36
|
|
39
|
-
if KubeContext.in_cluster():
|
40
|
-
log2('This is doable only from outside of the Kubernetes cluster.')
|
41
|
-
return state
|
42
|
-
|
43
37
|
label_selector = Config().get('pod.label-selector', 'run=ops')
|
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)
|
46
|
+
# instantly destroy the pod
|
47
|
+
try:
|
48
|
+
Pods.delete_with_selector(state.namespace, label_selector, grace_period_seconds=0)
|
49
|
+
except Exception as e:
|
50
|
+
log2(e)
|
44
51
|
undeploy_frontend(state.namespace, label_selector)
|
45
|
-
Pods.delete_with_selector(state.namespace, label_selector, grace_period_seconds=0)
|
46
|
-
ServiceAccounts.delete(state.namespace, label_selector=label_selector)
|
47
52
|
|
48
53
|
return state
|
49
54
|
|
@@ -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
|
+
)
|
@@ -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
|