opsctl is the command-line interface for Autopilot. It provides interactive cluster
analysis, rebalancing, resource prediction, and CRD status inspection without requiring the
full controller to be running.
opsctl keeps its original command name — it is a runtime binary, not a brand name.Installation
Build from source:bin/opsctl. Move it onto your PATH:
- A valid kubeconfig file (defaults to
~/.kube/config) - For GKE mode: GCP credentials configured (
gcloud auth application-default login) - For the
predictcommand: a reachable Prometheus endpoint
Commands
rebalance (default)
Analyze cluster resource distribution and optionally rebalance pods across nodes. This is the default command when no subcommand is specified.
GKE provision-first mode flags — when
--gke is set, opsctl provisions new nodes before
migrating workloads, avoiding resource contention during rebalancing:
predict
Predict resource usage trends and detect anomalies using Prometheus historical data.
When both
--namespace and --pod are provided, opsctl runs a detailed single-pod
prediction including trend analysis, pattern classification, forecasting, peak estimation,
and anomaly detection. When only --namespace is given (or neither), it runs a cluster-wide
analysis with node utilization and fragmentation scoring.
status
Show the current state of all Autopilot CRD resources in the cluster.
Displays tables for RebalancePolicy (schedule, dry-run mode, last run), NodeScalingPolicy
(min/max nodes, current/desired counts, last action), and PodResizePolicy (resize mode,
recommendation count, total resizes).
help
Common usage examples
Dry-run cluster analysis (default)
--dry-run defaults to
true, this is always safe.
Execute rebalancing
Adjust thresholds
GKE provision-first rebalance (dry-run)
GKE provision-first rebalance (execute)
Predict resource usage for a specific pod
Check CRD status
Exit codes
All errors are printed to stderr with a descriptive message. Diagnostic output (node tables,
analysis results) goes to stdout.
Tips
- Always start with a dry run. The default
--dry-run=trueensures no cluster changes are made until you explicitly opt in. - In GKE mode,
--spotcan reduce costs by 60–91% for new nodes, but spot VMs can be preempted — use it for fault-tolerant workloads. - The
predictcommand requires at least 5 historical data points from Prometheus. If your retention is too short, predictions won’t be available. - The
statuscommand works even if the controller is not running — it reads CRD resources directly from the API server.