diff --git a/CHANGELOG.md b/CHANGELOG.md index 243d2fa..25e7484 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Note: Breaking changes between versions are indicated by "💥". ## Unreleased +- [Feature] Add `tutor [dev|local|k8s] status` command, which provides basic information about the platform's status. - 💥[Improvement] Make it possible to run `tutor k8s exec ` (#636). As a consequence, it is no longer possible to run quoted commands: `tutor k8s exec ""`. Instead, you should remove the quotes: `tutor k8s exec `. ## v13.1.11 (2022-04-12) diff --git a/docs/k8s.rst b/docs/k8s.rst index b861755..e8508e4 100644 --- a/docs/k8s.rst +++ b/docs/k8s.rst @@ -64,6 +64,10 @@ On Minikube, the dashboard is already installed. To access the dashboard, run:: minikube dashboard +Lastly, Tutor itself provides a rudimentary listing of your cluster's nodes, workloads, and services:: + + tutor k8s status + Technical details ----------------- diff --git a/docs/local.rst b/docs/local.rst index 5f8a218..c6a6a67 100644 --- a/docs/local.rst +++ b/docs/local.rst @@ -98,6 +98,14 @@ Finally, tracking logs that store `user events None context.invoke(dc_command, command="logs", args=args) +@click.command(help="Print status information for containers") +@click.pass_context +def status(context: click.Context) -> None: + context.invoke(dc_command, command="ps") + + @click.command( short_help="Direct interface to docker-compose.", help=( @@ -307,3 +313,4 @@ def add_commands(command_group: click.Group) -> None: command_group.add_command(bindmount_command) command_group.add_command(execute) command_group.add_command(logs) + command_group.add_command(status) diff --git a/tutor/commands/k8s.py b/tutor/commands/k8s.py index bc4ec5d..620f40c 100644 --- a/tutor/commands/k8s.py +++ b/tutor/commands/k8s.py @@ -501,6 +501,13 @@ def kubectl_apply(root: str, *args: str) -> None: utils.kubectl("apply", "--kustomize", tutor_env.pathjoin(root), *args) +@click.command(help="Print status information for all k8s resources") +@click.pass_obj +def status(context: K8sContext) -> int: + config = tutor_config.load(context.root) + return utils.kubectl("get", "all", *resource_namespace_selector(config)) + + def kubectl_exec(config: Config, service: str, command: List[str]) -> int: selector = f"app.kubernetes.io/name={service}" pods = K8sClients.instance().core_api.list_namespaced_pod( @@ -573,3 +580,4 @@ k8s.add_command(logs) k8s.add_command(wait) k8s.add_command(upgrade) k8s.add_command(apply_command) +k8s.add_command(status)