kubectl Plugin¶
Hybernate provides a kubectl hybernate plugin for exporting discovered workloads as ManagedWorkload YAML manifests, designed for GitOps workflows.
Installation¶
Download the binary from the releases page and place it in your PATH:
# macOS (Apple Silicon)
curl -LO https://github.com/okedeji/hybernate/releases/latest/download/kubectl-hybernate-darwin-arm64.tar.gz
tar xzf kubectl-hybernate-darwin-arm64.tar.gz
chmod +x kubectl-hybernate-darwin-arm64
mv kubectl-hybernate-darwin-arm64 /usr/local/bin/kubectl-hybernate
# Linux (amd64)
curl -LO https://github.com/okedeji/hybernate/releases/latest/download/kubectl-hybernate-linux-amd64.tar.gz
tar xzf kubectl-hybernate-linux-amd64.tar.gz
chmod +x kubectl-hybernate-linux-amd64
mv kubectl-hybernate-linux-amd64 /usr/local/bin/kubectl-hybernate
kubectl krew install --manifest-url \
https://github.com/okedeji/hybernate/releases/latest/download/krew-hybernate.yaml
Note
This uses a custom manifest URL. Once the plugin is accepted into the krew-index, you'll be able to install with just kubectl krew install hybernate.
Usage¶
Note
The plugin requires a WorkloadPolicy to exist in the target namespace. It reads from the policy's status.discovered field. If the policy doesn't exist, the command exits with a clear error.
Export All Unmanaged Workloads¶
Outputs YAML to stdout. Pipe to kubectl apply or redirect to a file:
Export to Individual Files¶
Creates one file per workload (e.g., manifests/my-api.yaml).
Filter by Classification¶
# Only idle workloads
kubectl hybernate export --policy staging-policy -n staging --classification Idle
# Only wasteful workloads
kubectl hybernate export --policy staging-policy -n staging --classification Wasteful
# Both
kubectl hybernate export --policy staging-policy -n staging \
--classification Idle --classification Wasteful
Export a Specific Workload¶
Include Already-Managed Workloads¶
By default, workloads that already have a ManagedWorkload CR are skipped. To include them (useful when graduating from auto-manage to GitOps):
Flags Reference¶
| Flag | Short | Default | Description |
|---|---|---|---|
--policy |
(required) | Name of the WorkloadPolicy to export from | |
--namespace |
-n |
default |
Namespace of the WorkloadPolicy |
--output |
-o |
(stdout) | Directory to write individual YAML files |
--name |
Export only the workload with this name | ||
--classification |
Filter by classification (Active, Idle, Wasteful) |
||
--include-managed |
false |
Include workloads that already have a ManagedWorkload |
GitOps Workflow¶
A typical workflow for introducing Hybernate via GitOps:
- Deploy a WorkloadPolicy in
suggestmode to discover workloads - Review discovered workloads:
kubectl get workloadpolicy staging-policy -n staging -o yaml - Export the ones you want to manage:
kubectl hybernate export --policy staging-policy -n staging --classification Idle --output ./k8s/hybernate/ - Commit the manifests to your Git repository
- Let ArgoCD/Flux sync them to the cluster
See the GitOps Export Guide for a detailed walkthrough.