# `kubectl-ate` A Kubernetes-native CLI plugin for managing Substrate Actor and Worker lifecycles. ## Running the CLI There are two ways to run the tool, depending on whether you are developing locally or installing it permanently. ### 1. Install as a native `kubectl` Plugin You can use `go install` to compile the tool and place the binary directly into your Go bin directory (which should be in your `$PATH`). Because the source folder is named `kubectl-ate`, Kubernetes will automatically recognize the resulting binary! ```bash go install ./cmd/kubectl-ate ``` You can now run it seamlessly anywhere as a native Kubernetes command: `kubectl ate `. ### 2. Run directly from source (Development) If you are testing changes to the codebase, you can bypass compilation and run the CLI directly from the source tree: ```bash go run ./cmd/kubectl-ate ``` ## Connection & Auto Port-Forwarding By default, `kubectl-ate` will automatically read your `~/.kube/config`, discover the `ate-api-server` pods in your cluster, and establish a temporary background port-forward tunnel to execute gRPC calls securely. If you prefer to route traffic directly (e.g., through a LoadBalancer or when running natively inside a cluster pod), simply provide the `--endpoint` flag to bypass the tunnel. ## Tracing The CLI supports on-demand tracing using the `--trace` flag. When enabled, the CLI will generate a trace ID and signal to the server that it wants the request to be traced. **Prerequisites:** 1. The Google Cloud project must have the **Cloud Trace API** enabled. You can enable it using: ```bash gcloud services enable cloudtrace.googleapis.com --project=PROJECT_ID ``` 2. The GKE cluster must have **Managed OpenTelemetry** enabled. Clusters created by `setup-gcp create cluster` or `setup-gcp bootstrap` always enable it. For a cluster that does not have it, enable it with: ```bash gcloud beta container clusters update CLUSTER_NAME \ --project=PROJECT_ID \ --managed-otel-scope=COLLECTION_AND_INSTRUMENTATION_COMPONENTS \ --location=LOCATION ``` **Local (kind):** The kind overlay installed by `hack/install-ate-kind.sh --deploy-ate-system` already provisions an in-cluster OpenTelemetry Collector and a Jaeger all-in-one in the `otel-system` namespace. No additional setup is required. Port-forward the Jaeger UI and invoke any command with `--trace`: ```bash kubectl port-forward -n otel-system svc/jaeger 16686:16686 & kubectl ate get actor my-counter-1 --trace # open http://localhost:16686 and search for the most recent trace ``` ## Global Flags These flags can be appended to any command: | Flag | Short | Description | Default | |---|---|---|---| | `--kubeconfig` | | Path to your kubeconfig file | `~/.kube/config` | | `--context` | | Name of the kubeconfig context to use | current context | | `--endpoint` | | Manual gRPC endpoint override (e.g., `localhost:8080`) | | | `--token-file` | | Path to a bearer token for ate-api authentication, or `-` for stdin | Kubernetes ServiceAccount token | | `--output` | `-o` | Output format (`table`, `json`, `yaml`) | `table` | | `--trace` | | Enable on-demand tracing for the request | `false` | --- ## Command Reference & Examples ### Getting Resources List and inspect the state of actors and workers across the cluster. ```bash # List actors in one atespace; -a is shorthand for --atespace kubectl ate get actors --atespace kubectl ate get actors -a # List actors across all atespaces kubectl ate get actors -A # Get a specific actor by name and output as raw YAML kubectl ate get actor --atespace -o yaml # List all physical workers and see which actors are assigned to them kubectl ate get workers # Filter workers by Kubernetes namespace, assigned-actor atespace, or # worker pool labels (same flags as `top workers`) kubectl ate get workers -n kubectl ate get workers -a kubectl ate get workers -l ``` > **Note:** `get actors` requires either `--atespace ` / `-a ` (one atespace) or `-A`/`--all-atespaces` (all atespaces) — there is no default atespace. Getting a single actor always requires `--atespace`/`-a`, since an actor is addressed by `(atespace, name)`. `-a` (lower-case) scopes to one atespace; `-A` (upper-case) spans all. > **Note:** Actors and workers are not Kubernetes CRDs — they live in the Substrate control plane (valkey/redis), not `etcd`. `kubectl get actor` and `kubectl get worker` will not return anything; only `kubectl ate get …` queries the control plane. `kubectl get actortemplate` and `kubectl get workerpool` *do* work, because those are CRDs. #### `kubectl ate get actor` output columns | Column | Meaning | |---|---| | `ATESPACE` | The atespace the actor belongs to. Part of the actor's identity; folded into the storage key as `actor::`. | | `NAME` | The actor's name. User-provided for application actors; UUID for the golden actor that each template materialises during `ResumeGoldenActor`. | | `TEMPLATE` | The `ActorTemplate` the actor was created from, as `/` (the template namespace is distinct from `ATESPACE`). | | `STATE` | One of `ACTOR_STATE_RESUMING`, `ACTOR_STATE_RUNNING`, `ACTOR_STATE_SUSPENDING`, `ACTOR_STATE_SUSPENDED`. | | `ATEOM POD` | The worker pod (namespace/name) currently hosting the actor. Empty while suspended. | | `ATEOM IP` | The pod IP of that worker. Empty while suspended. | | `VERSION` | Monotonic integer that increments on every state transition (resume / suspend / checkpoint). Useful for distinguishing snapshots. | | `AGE` | Time elapsed since the actor was created. | #### `kubectl ate get worker` output columns | Column | Meaning | |---|---| | `NAMESPACE` | The `WorkerPool` namespace. | | `POOL` | The `WorkerPool` name. | | `POD` | The worker pod name. | | `STATUS` | `FREE` (idle, ready to receive an actor) or `ASSIGNED` (currently hosting an actor). | | `ASSIGNED ACTOR` | If `STATUS=ASSIGNED`, the actor reference `/