-
Notifications
You must be signed in to change notification settings - Fork 385
chore(kubevirt): add eval tasks for VM creation and lifecycle #626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # KubeVirt installation and management | ||
|
|
||
| # KubeVirt version configuration | ||
| KUBEVIRT_VERSION ?= v1.7.0 | ||
| CDI_VERSION ?= v1.64.0 | ||
|
lyarwood marked this conversation as resolved.
|
||
|
|
||
| # Detect if we're using a released version or main/latest | ||
| KUBEVIRT_RELEASE_URL = https://github.com/kubevirt/kubevirt/releases/download/$(KUBEVIRT_VERSION) | ||
| CDI_RELEASE_URL = https://github.com/kubevirt/containerized-data-importer/releases/download/$(CDI_VERSION) | ||
|
|
||
| ##@ KubeVirt | ||
|
|
||
| .PHONY: kubevirt-install | ||
| kubevirt-install: ## Install KubeVirt and CDI on the cluster | ||
| @echo "=========================================" | ||
| @echo "Installing KubeVirt $(KUBEVIRT_VERSION)" | ||
| @echo "=========================================" | ||
| @echo "" | ||
| @echo "Installing KubeVirt operator..." | ||
| @kubectl apply -f $(KUBEVIRT_RELEASE_URL)/kubevirt-operator.yaml | ||
| @echo "" | ||
| @echo "Installing KubeVirt CR..." | ||
| @kubectl apply -f $(KUBEVIRT_RELEASE_URL)/kubevirt-cr.yaml | ||
| @echo "" | ||
| @echo "Waiting for KubeVirt to become ready (this can take a few minutes)..." | ||
| @kubectl -n kubevirt wait kv kubevirt --for condition=Available --timeout=15m | ||
|
lyarwood marked this conversation as resolved.
|
||
| @echo "✅ KubeVirt is ready" | ||
| @echo "" | ||
| @echo "Installing CDI (Containerized Data Importer) $(CDI_VERSION)..." | ||
| @kubectl apply -f $(CDI_RELEASE_URL)/cdi-operator.yaml | ||
| @kubectl apply -f $(CDI_RELEASE_URL)/cdi-cr.yaml | ||
| @echo "" | ||
| @echo "Waiting for CDI to become ready..." | ||
| @kubectl wait --for=condition=Available cdi/cdi -n cdi --timeout=5m | ||
| @echo "✅ CDI is ready" | ||
| @echo "" | ||
| @echo "=========================================" | ||
| @echo "KubeVirt Installation Complete" | ||
| @echo "=========================================" | ||
| @echo "" | ||
| @echo "KubeVirt version: $(KUBEVIRT_VERSION)" | ||
| @echo "CDI version: $(CDI_VERSION)" | ||
| @echo "" | ||
| @echo "Verify installation with:" | ||
| @echo " kubectl get kubevirt -n kubevirt" | ||
| @echo " kubectl get cdi -n cdi" | ||
| @echo "" | ||
|
|
||
| .PHONY: kubevirt-uninstall | ||
| kubevirt-uninstall: ## Uninstall KubeVirt and CDI from the cluster | ||
| @echo "Uninstalling KubeVirt and CDI..." | ||
| @kubectl delete -f $(KUBEVIRT_RELEASE_URL)/kubevirt-cr.yaml --ignore-not-found | ||
| @kubectl delete -f $(KUBEVIRT_RELEASE_URL)/kubevirt-operator.yaml --ignore-not-found | ||
| @kubectl delete -f $(CDI_RELEASE_URL)/cdi-cr.yaml --ignore-not-found | ||
| @kubectl delete -f $(CDI_RELEASE_URL)/cdi-operator.yaml --ignore-not-found | ||
| @echo "✅ KubeVirt and CDI uninstalled" | ||
|
|
||
| .PHONY: kubevirt-status | ||
| kubevirt-status: ## Show KubeVirt and CDI status | ||
| @echo "=========================================" | ||
| @echo "KubeVirt Status" | ||
| @echo "=========================================" | ||
| @echo "" | ||
| @echo "KubeVirt:" | ||
| @kubectl get kubevirt -n kubevirt -o wide || { echo "KubeVirt not installed"; exit 1; } | ||
| @echo "" | ||
| @echo "CDI:" | ||
| @kubectl get cdi -n cdi -o wide || { echo "CDI not installed"; exit 1; } | ||
| @echo "" | ||
| @echo "KubeVirt Pods:" | ||
| @kubectl get pods -n kubevirt | ||
| @echo "" | ||
| @echo "CDI Pods:" | ||
| @kubectl get pods -n cdi | ||
| @echo "" | ||
| @echo "VirtualMachines (all namespaces):" | ||
| @kubectl get virtualmachines --all-namespaces || echo "No VirtualMachines found" | ||
| @echo "" | ||
|
lyarwood marked this conversation as resolved.
|
||
| @echo "VirtualMachineInstances (all namespaces):" | ||
| @kubectl get virtualmachineinstances --all-namespaces || echo "No VirtualMachineInstances found" | ||
| @echo "" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # KubeVirt Task Stack | ||
|
|
||
| KubeVirt-focused MCP tasks live here. Each folder under this directory represents a self-contained scenario that exercises the KubeVirt toolset (virtual machine creation, lifecycle management, troubleshooting). | ||
|
|
||
| ## Adding a New Task | ||
|
|
||
| 1. Create a new subdirectory (e.g., `create-vm-foo/`) and place the scenario YAML plus any helper scripts or artifacts inside it. | ||
| 2. Make sure the YAML's `metadata` block includes `name` and `difficulty` so it shows up correctly in the catalog below. | ||
| 3. Keep prompts concise and action-oriented; verification commands should rely on KubeVirt resources and helper functions whenever possible. | ||
|
|
||
| ## Tasks Defined | ||
|
|
||
| ### VM Creation | ||
|
|
||
| - **[easy] create-vm-basic** - Create a basic Fedora virtual machine | ||
| - **Prompt:** *Please create a Fedora virtual machine named test-vm in the vm-test namespace.* | ||
|
|
||
| - **[easy] create-vm-ubuntu** - Create an Ubuntu virtual machine | ||
| - **Prompt:** *Create an Ubuntu virtual machine named ubuntu-vm in the vm-test namespace.* | ||
|
|
||
| - **[easy] create-vm-with-instancetype** - Create a VM using VirtualMachineInstancetype | ||
|
lyarwood marked this conversation as resolved.
|
||
| - **Prompt:** *Create a Fedora virtual machine with specific instance types and preferences.* | ||
|
|
||
| - **[easy] create-vm-with-size** - Create a VM with specific size requirements | ||
|
lyarwood marked this conversation as resolved.
|
||
| - **Prompt:** *Create a virtual machine with custom CPU and memory specifications.* | ||
|
|
||
| ### VM Lifecycle Management | ||
|
|
||
| - **[medium] pause-vm** - Pause a running virtual machine | ||
| - **Prompt:** *Please pause the virtual machine named paused-vm in the vm-test namespace.* | ||
|
|
||
| - **[medium] delete-vm** - Delete a virtual machine | ||
| - **Prompt:** *Please delete the virtual machine named deleted-vm in the vm-test namespace.* | ||
|
|
||
| ### VM Modification | ||
|
|
||
| - **[hard] update-vm-resources** - Update VM CPU and memory resources | ||
| - **Prompt:** *A VirtualMachine named test-vm-update exists in the vm-test namespace. It currently has 1 vCPU and 2Gi of memory. Please update the VirtualMachine to add an additional vCPU (making it 2 vCPUs total) and increase the memory to at least 3Gi.* | ||
|
|
||
| ## Helper Scripts | ||
|
|
||
| Many tasks rely on helper scripts located in `evals/tasks/kubevirt/helpers/`: | ||
|
|
||
| - `verify-vm.sh` - Common VM verification functions used across multiple test scenarios | ||
|
|
||
| ## Running Tasks | ||
|
|
||
| These tasks are designed to be used with the gevals evaluation framework. Each task includes: | ||
|
lyarwood marked this conversation as resolved.
|
||
|
|
||
| - **setup** - Prepares the test environment (creates namespace, sets up initial VM state) | ||
| - **verify** - Validates the expected outcome after the agent completes the task | ||
| - **cleanup** - Removes resources created during the test | ||
| - **prompt** - The instruction given to the AI agent | ||
|
|
||
| Example workflow: | ||
|
|
||
| 1. Setup creates the initial state | ||
| 2. Agent receives the prompt and executes actions using MCP tools | ||
| 3. Verify checks if the agent accomplished the goal | ||
| 4. Cleanup removes test resources | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| kind: Task | ||
|
lyarwood marked this conversation as resolved.
|
||
| metadata: | ||
| name: "create-basic-vm" | ||
| difficulty: easy | ||
| steps: | ||
| setup: | ||
| inline: |- | ||
| #!/usr/bin/env bash | ||
| NS="${EVAL_NAMESPACE:-vm-test}" | ||
| kubectl delete namespace "$NS" --ignore-not-found | ||
| kubectl create namespace "$NS" | ||
| verify: | ||
| inline: |- | ||
| #!/usr/bin/env bash | ||
| source evals/tasks/kubevirt/helpers/verify-vm.sh | ||
| NS="${EVAL_NAMESPACE:-vm-test}" | ||
|
|
||
| # Wait for VirtualMachine to be created | ||
| verify_vm_exists "test-vm" "$NS" || exit 1 | ||
|
lyarwood marked this conversation as resolved.
|
||
|
|
||
| # Verify container disk is Fedora | ||
| verify_container_disk "test-vm" "$NS" "fedora" || exit 1 | ||
|
|
||
| # Verify runStrategy is set and deprecated 'running' field is not used | ||
| verify_run_strategy "test-vm" "$NS" || exit 1 | ||
| verify_no_deprecated_running_field "test-vm" "$NS" || exit 1 | ||
|
|
||
| echo "All validations passed" | ||
| exit 0 | ||
| cleanup: | ||
| inline: |- | ||
| #!/usr/bin/env bash | ||
| NS="${EVAL_NAMESPACE:-vm-test}" | ||
| kubectl delete virtualmachine test-vm -n "$NS" --ignore-not-found | ||
| kubectl delete namespace "$NS" --ignore-not-found | ||
| prompt: | ||
| inline: Create a Fedora virtual machine named test-vm in the ${EVAL_NAMESPACE:-vm-test} namespace. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| kind: Task | ||
| metadata: | ||
| name: "create-ubuntu-vm" | ||
| difficulty: easy | ||
| steps: | ||
| setup: | ||
| inline: |- | ||
| #!/usr/bin/env bash | ||
| NS="${EVAL_NAMESPACE:-vm-test}" | ||
| kubectl delete namespace "$NS" --ignore-not-found | ||
| kubectl create namespace "$NS" | ||
| verify: | ||
| inline: |- | ||
| #!/usr/bin/env bash | ||
| source evals/tasks/kubevirt/helpers/verify-vm.sh | ||
| NS="${EVAL_NAMESPACE:-vm-test}" | ||
|
|
||
| # Wait for VirtualMachine to be created | ||
| verify_vm_exists "ubuntu-vm" "$NS" || exit 1 | ||
|
|
||
| # Verify container disk is Ubuntu | ||
| verify_container_disk "ubuntu-vm" "$NS" "ubuntu" || exit 1 | ||
|
|
||
| # Verify runStrategy is set and deprecated 'running' field is not used | ||
| verify_run_strategy "ubuntu-vm" "$NS" || exit 1 | ||
| verify_no_deprecated_running_field "ubuntu-vm" "$NS" || exit 1 | ||
|
|
||
| echo "All validations passed" | ||
| exit 0 | ||
| cleanup: | ||
| inline: |- | ||
| #!/usr/bin/env bash | ||
| NS="${EVAL_NAMESPACE:-vm-test}" | ||
| kubectl delete virtualmachine ubuntu-vm -n "$NS" --ignore-not-found | ||
| kubectl delete namespace "$NS" --ignore-not-found | ||
| prompt: | ||
| inline: Create an Ubuntu virtual machine named ubuntu-vm in the ${EVAL_NAMESPACE:-vm-test} namespace. |
43 changes: 43 additions & 0 deletions
43
evals/tasks/kubevirt/create-vm-with-instancetype/task.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| kind: Task | ||
| metadata: | ||
| name: "create-vm-with-instancetype" | ||
| difficulty: easy | ||
| steps: | ||
| setup: | ||
| inline: |- | ||
| #!/usr/bin/env bash | ||
| NS="${EVAL_NAMESPACE:-vm-test}" | ||
| kubectl delete namespace "$NS" --ignore-not-found | ||
| kubectl create namespace "$NS" | ||
| verify: | ||
| inline: |- | ||
| #!/usr/bin/env bash | ||
| source evals/tasks/kubevirt/helpers/verify-vm.sh | ||
| NS="${EVAL_NAMESPACE:-vm-test}" | ||
|
|
||
| # Wait for VirtualMachine to be created | ||
| verify_vm_exists "test-vm-instancetype" "$NS" || exit 1 | ||
|
|
||
| # Verify that it has the specific instancetype reference (u1.medium) | ||
| verify_instancetype "test-vm-instancetype" "$NS" "u1.medium" || exit 1 | ||
|
|
||
| # Verify runStrategy is set and deprecated 'running' field is not used | ||
| verify_run_strategy "test-vm-instancetype" "$NS" || exit 1 | ||
| verify_no_deprecated_running_field "test-vm-instancetype" "$NS" || exit 1 | ||
|
|
||
| # Verify no direct resource specification (should use instancetype) | ||
| verify_no_direct_resources "test-vm-instancetype" "$NS" | ||
|
|
||
| # Verify container disk is Fedora (default workload) | ||
| verify_container_disk "test-vm-instancetype" "$NS" "fedora" | ||
|
|
||
| echo "All validations passed" | ||
| exit 0 | ||
| cleanup: | ||
| inline: |- | ||
| #!/usr/bin/env bash | ||
| NS="${EVAL_NAMESPACE:-vm-test}" | ||
| kubectl delete virtualmachine test-vm-instancetype -n "$NS" --ignore-not-found | ||
| kubectl delete namespace "$NS" --ignore-not-found | ||
| prompt: | ||
| inline: Create a Fedora virtual machine named test-vm-instancetype in the ${EVAL_NAMESPACE:-vm-test} namespace with instancetype 'u1.medium'. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| kind: Task | ||
| metadata: | ||
| name: "create-vm-with-size" | ||
| difficulty: easy | ||
| steps: | ||
| setup: | ||
| inline: |- | ||
| #!/usr/bin/env bash | ||
| NS="${EVAL_NAMESPACE:-vm-test}" | ||
| kubectl delete namespace "$NS" --ignore-not-found | ||
| kubectl create namespace "$NS" | ||
| verify: | ||
| inline: |- | ||
| #!/usr/bin/env bash | ||
| source evals/tasks/kubevirt/helpers/verify-vm.sh | ||
| NS="${EVAL_NAMESPACE:-vm-test}" | ||
|
|
||
| # Wait for VirtualMachine to be created | ||
| verify_vm_exists "test-vm-size" "$NS" || exit 1 | ||
|
|
||
| # Verify that it has an instancetype or direct resources | ||
| verify_has_resources_or_instancetype "test-vm-size" "$NS" || exit 1 | ||
|
|
||
| # Check if instancetype contains 'large' (matching the requested size) | ||
| verify_instancetype_contains "test-vm-size" "$NS" "large" "requested size 'large'" | ||
|
|
||
| # Verify runStrategy is set and deprecated 'running' field is not used | ||
| verify_run_strategy "test-vm-size" "$NS" || exit 1 | ||
| verify_no_deprecated_running_field "test-vm-size" "$NS" || exit 1 | ||
|
|
||
| # Verify container disk is Fedora (default workload) | ||
| verify_container_disk "test-vm-size" "$NS" "fedora" | ||
|
|
||
| echo "All validations passed" | ||
| exit 0 | ||
| cleanup: | ||
| inline: |- | ||
| #!/usr/bin/env bash | ||
| NS="${EVAL_NAMESPACE:-vm-test}" | ||
| kubectl delete virtualmachine test-vm-size -n "$NS" --ignore-not-found | ||
| kubectl delete namespace "$NS" --ignore-not-found | ||
| prompt: | ||
| inline: Create a Fedora virtual machine named test-vm-size in the ${EVAL_NAMESPACE:-vm-test} namespace with size 'large' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on prior internal discussions, we might want to remove the
local-env-setupand others, and leave the more local granular tasks (kind, keycloak, kiali, and kubevirt)cc @matzew
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manusa I don't mind either way but maybe for now that's something we could handle in a follow up that also removes these
local-env-setuptargets?