Skip to content

Commit c32fee6

Browse files
committed
kubevirt-vphere-skills
Signed-off-by: yaacov <kobi.zamir@gmail.com>
1 parent 14296a4 commit c32fee6

8 files changed

Lines changed: 365 additions & 8 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ mtv-agent init
1616
mtv-agent start # with LM Studio (default)
1717
mtv-agent start --with-cop # with Claude
1818
mtv-agent start --open # open the web UI in your browser when ready
19+
mtv-agent start --open-app # open in app mode (chromeless window)
1920
```
2021

2122
Or, using [uv](https://docs.astral.sh/uv/) (isolated install, no root needed):
@@ -24,7 +25,9 @@ Or, using [uv](https://docs.astral.sh/uv/) (isolated install, no root needed):
2425
uv tool install mtv-agent
2526
```
2627

27-
Open `http://localhost:8000` in your browser, or use `mtv-agent start --open`. With `--no-web`, `--open` is ignored.
28+
Open `http://localhost:8000` in your browser, or use `mtv-agent start --open`.
29+
Use `--open-app` for a chromeless app-mode window (requires Chrome/Chromium/Edge).
30+
With `--no-web`, both `--open` and `--open-app` are ignored.
2831

2932
You need an OpenAI-compatible LLM backend, access to an OpenShift cluster with
3033
MTV/Forklift, and Docker or Podman. See the

docs/cli-reference.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ mtv-agent start
4040
mtv-agent start --with-cop
4141
mtv-agent start --runtime podman --port 9000
4242
mtv-agent start --open
43+
mtv-agent start --open-app
4344
```
4445

4546
| Flag | Description |
@@ -52,6 +53,7 @@ mtv-agent start --open
5253
| `--mcp-config PATH` | Path to `mcp.json` |
5354
| `--no-web` | Do not serve the web UI |
5455
| `--open` | Open the web UI in a browser when the server is ready (skipped with `--no-web`) |
56+
| `--open-app` | Open the web UI in app mode (chromeless window) when the server is ready (skipped with `--no-web`; requires a Chromium-based browser) |
5557
| `--skip-tls` | Skip TLS verification for Kubernetes API |
5658
| `--kube-api-url URL` | Kubernetes API URL (overrides kubeconfig) |
5759
| `--kube-token TOKEN` | Kubernetes bearer token (overrides kubeconfig) |
@@ -67,6 +69,7 @@ running externally.
6769
mtv-agent serve
6870
mtv-agent serve --host 127.0.0.1 --port 9000
6971
mtv-agent serve --open
72+
mtv-agent serve --open-app
7073
```
7174

7275
| Flag | Description |
@@ -77,6 +80,7 @@ mtv-agent serve --open
7780
| `--mcp-config PATH` | Path to `mcp.json` |
7881
| `--no-web` | Do not serve the web UI |
7982
| `--open` | Open the web UI in a browser when the server is ready (skipped with `--no-web`) |
83+
| `--open-app` | Open the web UI in app mode (chromeless window) when the server is ready (skipped with `--no-web`; requires a Chromium-based browser) |
8084
| `--skip-tls` | Skip TLS verification for Kubernetes API |
8185
| `--kube-api-url URL` | Kubernetes API URL (overrides kubeconfig) |
8286
| `--kube-token TOKEN` | Kubernetes bearer token (overrides kubeconfig) |

docs/skills-and-playbooks.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ system prompt and decides which to activate based on the user's question.
4242
| `metrics-query-cookbook` | Preset queries, Ceph/network/pod/MTV metric tables |
4343
| `mtv-cli-docs` | Links to the kubectl-mtv HTML guide and MCP-to-CLI translation |
4444
| `mtv-docs` | Red Hat MTV 2.11 documentation deep links |
45+
| `kubevirt` | KubeVirt VM lifecycle: `kubectl virt` / `oc virt` commands for the user to run |
46+
| `govc` | VMware vSphere `govc` commands for inventory, VMs, snapshots, and datastores |
4547

4648
## How playbooks work
4749

mtv_agent/cli.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def _cmd_start(args: argparse.Namespace) -> None:
2727
kubeconfig=args.kubeconfig,
2828
kube_context=args.kube_context,
2929
open_browser=args.open,
30+
open_app=args.open_app,
3031
)
3132

3233

@@ -45,6 +46,7 @@ def _cmd_serve(args: argparse.Namespace) -> None:
4546
kubeconfig=args.kubeconfig,
4647
kube_context=args.kube_context,
4748
open_browser=args.open,
49+
open_app=args.open_app,
4850
)
4951

5052

@@ -146,6 +148,11 @@ def main(argv: list[str] | None = None) -> None:
146148
action="store_true",
147149
help="Open the web UI in a browser when the server is ready",
148150
)
151+
p_start.add_argument(
152+
"--open-app",
153+
action="store_true",
154+
help="Open the web UI in app mode (chromeless window) when the server is ready",
155+
)
149156
p_start.add_argument(
150157
"--skip-tls",
151158
action="store_true",
@@ -173,6 +180,11 @@ def main(argv: list[str] | None = None) -> None:
173180
action="store_true",
174181
help="Open the web UI in a browser when the server is ready",
175182
)
183+
p_serve.add_argument(
184+
"--open-app",
185+
action="store_true",
186+
help="Open the web UI in app mode (chromeless window) when the server is ready",
187+
)
176188
_add_kube_flags(p_serve)
177189
p_serve.set_defaults(func=_cmd_serve)
178190

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
---
2+
name: govc
3+
description: VMware vSphere automation with govc. Use when the user wants to list inventory, power VMs, clone, snapshot, import OVA, or inspect datastores/hosts on vCenter/ESXi. Output CLI for the user to run — do not execute govc yourself unless they ask.
4+
---
5+
6+
## For AI assistants
7+
8+
Do **not** run `govc` or shell scripts on the user’s machine unless they explicitly ask you to execute commands. Give **copy-paste** `bash` blocks, list required `GOVC_*` environment variables, and explain placeholders (paths, VM names, datacenter).
9+
10+
# govc — vSphere CLI
11+
12+
`govc` is a Go-based CLI for VMware vSphere (govmomi). Useful alongside MTV for source-side checks (VMs, snapshots, datastores) before or during migration.
13+
14+
## Install
15+
16+
Point the user to the official release or package manager they prefer:
17+
18+
```bash
19+
# Example: download release from https://github.com/vmware/govmomi/releases
20+
# Ensure the binary is on PATH as `govc`
21+
govc version
22+
```
23+
24+
## Connection environment (user sets locally)
25+
26+
```bash
27+
export GOVC_URL=vcenter.example.com
28+
export GOVC_USERNAME=administrator@vsphere.local
29+
export GOVC_PASSWORD='...'
30+
export GOVC_INSECURE=true # only if skipping TLS verify
31+
```
32+
33+
Optional defaults to shorten commands:
34+
35+
```bash
36+
export GOVC_DATACENTER=mydc
37+
export GOVC_DATASTORE=datastore1
38+
export GOVC_NETWORK='VM Network'
39+
export GOVC_RESOURCE_POOL=/mydc/host/mycluster/Resources
40+
```
41+
42+
Verify:
43+
44+
```bash
45+
govc about
46+
govc datacenter.info
47+
```
48+
49+
## Help
50+
51+
```bash
52+
govc -h
53+
govc vm.info -h
54+
```
55+
56+
## Browse inventory
57+
58+
```bash
59+
govc ls
60+
govc ls /<dc>/vm
61+
govc ls -l /<dc>/network
62+
govc find / -type m
63+
govc find / -type m -name 'app-*'
64+
```
65+
66+
## VM lifecycle
67+
68+
**Create**
69+
70+
```bash
71+
govc vm.create -m 4096 -c 2 -g ubuntu64Guest \
72+
-net.adapter vmxnet3 -disk.controller pvscsi \
73+
-disk 40GB -ds datastore1 my-vm
74+
```
75+
76+
**Clone**
77+
78+
```bash
79+
govc vm.clone -vm /path/to/template -ds datastore1 new-vm
80+
```
81+
82+
**Power**
83+
84+
```bash
85+
govc vm.power -on=true my-vm
86+
govc vm.power -s=true my-vm
87+
govc vm.power -off=true my-vm
88+
```
89+
90+
**Info and IP**
91+
92+
```bash
93+
govc vm.info my-vm
94+
govc vm.ip -v4 my-vm
95+
```
96+
97+
**Destroy**
98+
99+
```bash
100+
govc vm.destroy my-vm
101+
```
102+
103+
## Snapshots
104+
105+
```bash
106+
govc snapshot.create -vm my-vm before-change
107+
govc snapshot.tree -vm my-vm
108+
govc snapshot.revert -vm my-vm before-change
109+
govc snapshot.remove -vm my-vm before-change
110+
```
111+
112+
## Datastore file operations
113+
114+
```bash
115+
govc datastore.ls -ds datastore1
116+
govc datastore.upload ./file.iso "[datastore1] iso/file.iso"
117+
```
118+
119+
## OVA import (common for appliances)
120+
121+
```bash
122+
govc import.ova -folder=/<dc>/vm/folder ./appliance.ova
123+
```
124+
125+
## Guest operations (VMware Tools)
126+
127+
```bash
128+
govc guest.run -vm my-vm /bin/uname -a
129+
govc guest.upload -vm my-vm ./local.cfg /tmp/local.cfg
130+
```
131+
132+
## JSON for scripting
133+
134+
```bash
135+
govc vm.info -json my-vm
136+
govc find / -type m -json
137+
```
138+
139+
When unsure of flags, tell the user to run `govc <command> -h` locally.
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
---
2+
name: kubevirt
3+
description: KubeVirt VM operations via kubectl virt or oc virt. Use when the user wants to create, start, stop, console/VNC/SSH into, or inspect VMs on OpenShift/Kubernetes. Output CLI for the user to run — do not execute kubectl/oc yourself unless they ask.
4+
---
5+
6+
## For AI assistants
7+
8+
Do **not** run `kubectl`, `oc`, or `virtctl` in the user’s environment unless they explicitly ask you to execute commands. Give **copy-paste** `bash` blocks, explain placeholders (for example `<vm-name>`, `<namespace>`), and note prerequisites (logged-in cluster context, namespace, installed plugin).
9+
10+
# KubeVirt CLI (`kubectl virt` / `oc virt`)
11+
12+
The `kubectl virt` plugin (OpenShift: `oc virt`) generates and manages KubeVirt `VirtualMachine` resources.
13+
14+
## Install the plugin
15+
16+
Tell the user to install the virt plugin (pick one approach):
17+
18+
```bash
19+
# Krew (recommended)
20+
kubectl krew install virt
21+
22+
# Verify
23+
kubectl virt version
24+
```
25+
26+
On OpenShift, the same plugin is typically available as `oc virt` after installing OpenShift Virtualization.
27+
28+
## Discover flags (user runs locally)
29+
30+
```bash
31+
kubectl virt --help
32+
kubectl virt create vm --help
33+
kubectl virt ssh --help
34+
```
35+
36+
## Instance types and preferences (OpenShift)
37+
38+
Prefer **instance types** and **preferences** over raw `--memory` when the cluster exposes them:
39+
40+
```bash
41+
kubectl get virtualmachineclusterinstancetype
42+
kubectl get virtualmachineclusterpreference
43+
```
44+
45+
Common patterns: `u1.medium` (universal), `fedora` / `rhel.9` / `windows.11.virtio` preferences. With a DataSource that has annotations, `--infer-instancetype` and `--infer-preference` can select sizing automatically.
46+
47+
## List and inspect VMs
48+
49+
```bash
50+
kubectl get vm -A
51+
kubectl get vm -n <namespace>
52+
kubectl describe vm <vm-name> -n <namespace>
53+
kubectl get vmi -n <namespace>
54+
```
55+
56+
## Start, stop, restart
57+
58+
```bash
59+
kubectl virt start <vm-name> -n <namespace>
60+
kubectl virt stop <vm-name> -n <namespace>
61+
kubectl virt restart <vm-name> -n <namespace>
62+
```
63+
64+
## Create a VM (examples)
65+
66+
`kubectl virt create vm` prints YAML to stdout — the user pipes it to `kubectl apply`:
67+
68+
**Registry containerdisk + instance type**
69+
70+
```bash
71+
kubectl virt create vm \
72+
--name=my-fedora \
73+
--instancetype=u1.medium \
74+
--preference=fedora \
75+
--volume-import=type:registry,url:docker://quay.io/containerdisks/fedora:latest,size:30Gi \
76+
--user=fedora \
77+
--ssh-key="$(cat ~/.ssh/id_rsa.pub)" \
78+
| kubectl apply -f -
79+
```
80+
81+
**Cluster DataSource with inferred sizing**
82+
83+
```bash
84+
kubectl virt create vm \
85+
--name=my-vm \
86+
--volume-import=type:ds,src:openshift-virtualization-os-images/fedora,size:30Gi \
87+
--infer-instancetype --infer-preference \
88+
--user=fedora \
89+
--ssh-key="$(cat ~/.ssh/id_rsa.pub)" \
90+
| kubectl apply -f -
91+
```
92+
93+
**Fallback when no instance types (memory only)**
94+
95+
```bash
96+
kubectl virt create vm \
97+
--name=my-vm \
98+
--memory=2Gi \
99+
--run-strategy=Always \
100+
--volume-import=type:registry,url:docker://quay.io/containerdisks/fedora:latest,size:30Gi \
101+
--user=fedora \
102+
--ssh-key="$(cat ~/.ssh/id_rsa.pub)" \
103+
| kubectl apply -f -
104+
```
105+
106+
List DataSources (OpenShift golden images):
107+
108+
```bash
109+
kubectl get datasource -n openshift-virtualization-os-images
110+
```
111+
112+
### Storage gotcha
113+
114+
If DataVolumes stay pending with missing access mode / storage class, the cluster may lack a default StorageClass. The user can mark one:
115+
116+
```bash
117+
kubectl get storageclass
118+
kubectl annotate storageclass <name> storageclass.kubernetes.io/is-default-class=true
119+
```
120+
121+
## Console and VNC
122+
123+
```bash
124+
kubectl virt console <vm-name> -n <namespace>
125+
kubectl virt vnc <vm-name> -n <namespace>
126+
```
127+
128+
## SSH (virtctl-style via plugin)
129+
130+
```bash
131+
kubectl virt ssh fedora@<vm-name> -n <namespace>
132+
kubectl virt ssh fedora@<vm-name> -n <namespace> --identity-file=~/.ssh/id_rsa
133+
kubectl virt scp ./local.txt fedora@vmi/<vm-name>:./remote.txt -n <namespace>
134+
```
135+
136+
## Pause, migrate
137+
138+
```bash
139+
kubectl virt pause vm <vm-name> -n <namespace>
140+
kubectl virt unpause vm <vm-name> -n <namespace>
141+
kubectl virt migrate <vm-name> -n <namespace>
142+
```
143+
144+
When unsure of a subcommand, tell the user to run `kubectl virt <command> --help` locally.

0 commit comments

Comments
 (0)