Skip to content

Commit 7e3c61e

Browse files
committed
feat(kubevirt): add windows-golden-image prompt for automated Windows golden image creation
Add a new MCP prompt that guides the AI agent through creating a Windows golden image via the windows-efi-installer Tekton pipeline from the Tekton catalog. The prompt supports Windows 10, 11, 2k22 (default), and 2k25, and enforces a Microsoft EULA acceptance flow before creating the PipelineRun. Code was assisted by Cursor AI. Signed-off-by: Karel Simon <ksimon@redhat.com>
1 parent 5ac04d6 commit 7e3c61e

9 files changed

Lines changed: 926 additions & 2 deletions

File tree

.github/workflows/mcpchecker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ jobs:
136136
;;
137137
kubevirt)
138138
echo "label-selector=suite=kubevirt" >> $GITHUB_OUTPUT
139-
echo "toolsets=core,config,kubevirt" >> $GITHUB_OUTPUT
139+
echo "toolsets=core,config,kubevirt,tekton" >> $GITHUB_OUTPUT
140140
;;
141141
kiali)
142142
echo "label-selector=suite=kiali" >> $GITHUB_OUTPUT

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,12 @@ In case multi-cluster support is enabled (default) and you have access to multip
592592
- `namespace` (`string`) **(required)** - The namespace of the VirtualMachine to troubleshoot
593593
- `name` (`string`) **(required)** - The name of the VirtualMachine to troubleshoot
594594

595+
- **windows-golden-image** - Guides creation of a Windows golden image via the windows-efi-installer Tekton pipeline
596+
- `winImageDownloadURL` (`string`) **(required)** - Microsoft Windows ISO download URL
597+
- `namespace` (`string`) - Target namespace for the PipelineRun
598+
- `windowsVersion` (`string`) - Windows version: 10, 11, 2k22 (default), or 2k25
599+
- `pipelineVersion` (`string`) - Pipeline version (default: latest). Use specific version like 0.25.0 if needed
600+
595601
</details>
596602

597603

docs/kubevirt.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,38 @@ Generate a step-by-step troubleshooting guide for diagnosing VirtualMachine issu
6363
6. Related Kubernetes events
6464

6565
Usage requires the `namespace` and `name` of the VirtualMachine to troubleshoot.
66+
67+
#### `windows-golden-image`
68+
69+
Create a Windows golden image by running the `windows-efi-installer` Tekton pipeline
70+
from the [KubeVirt Tekton Pipelines catalog](https://artifacthub.io/packages/tekton-pipeline/kubevirt-tekton-pipelines/windows-efi-installer).
71+
The pipeline downloads a Windows ISO, modifies it for EFI automated installation,
72+
creates a VM, installs Windows, and produces a bootable DataSource/DataVolume suitable
73+
as a golden image for Windows VirtualMachines.
74+
75+
**How it works:**
76+
The prompt dynamically fetches the latest PipelineRun template from Artifact Hub, ensuring
77+
compatibility with the specified pipeline version. This means the generated YAML will always
78+
match the format expected by the pipeline, even when new versions introduce changes.
79+
80+
**Prerequisites:**
81+
- KubeVirt
82+
- Tekton Pipelines
83+
- Both `kubevirt` and `tekton` toolsets must be enabled
84+
85+
**Arguments:**
86+
- `winImageDownloadURL` (required): Microsoft Windows ISO download URL
87+
- `namespace` (optional): Target namespace for the PipelineRun
88+
- `windowsVersion` (optional): Windows version — `10`, `11`, `2k22` (default), or `2k25`
89+
- `pipelineVersion` (optional): Pipeline version to use (default: latest). Specify a version like `0.25.0` if needed
90+
91+
**EULA Notice:**
92+
The prompt instructs the AI agent to ask for explicit user acceptance of the Microsoft
93+
EULA before creating the PipelineRun. The `acceptEula` parameter is only set to `true`
94+
after the user confirms agreement.
95+
96+
**Usage:**
97+
Requires both `kubevirt` and `tekton` toolsets enabled:
98+
```shell
99+
kubernetes-mcp-server --toolsets core,kubevirt,tekton
100+
```
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
kind: Task
2+
apiVersion: mcpchecker/v1alpha2
3+
metadata:
4+
labels:
5+
suite: kubevirt
6+
requires: kubevirt,tekton
7+
name: "windows-golden-image-no-eula"
8+
difficulty: medium
9+
description: "Test the windows-golden-image prompt output and EULA handling"
10+
spec:
11+
requires:
12+
- extension: kubernetes
13+
as: k8s
14+
setup:
15+
- k8s.delete:
16+
apiVersion: v1
17+
kind: Namespace
18+
metadata:
19+
name: windows-golden-image-no-eula
20+
ignoreNotFound: true
21+
- k8s.create:
22+
apiVersion: v1
23+
kind: Namespace
24+
metadata:
25+
name: windows-golden-image-no-eula
26+
verify:
27+
- script:
28+
inline: |-
29+
#!/usr/bin/env bash
30+
set -euo pipefail
31+
NS="windows-golden-image-no-eula"
32+
33+
echo "=== Verification: Windows Golden Image Prompt Output ==="
34+
35+
# The task explicitly says "I do not accept the Microsoft EULA.".
36+
# A PipelineRun being present means the agent ignored that instruction.
37+
PIPELINERUN_COUNT=$(kubectl get pipelinerun -n "$NS" 2>/dev/null | grep -c "windows" || true)
38+
39+
if [ "$PIPELINERUN_COUNT" -gt "0" ]; then
40+
echo "✗ PipelineRun was created despite EULA not being accepted — agent disobeyed instructions"
41+
exit 1
42+
fi
43+
44+
echo "✓ No PipelineRun created (correct — EULA was not accepted)"
45+
echo ""
46+
echo "=== Prompt Output Verification Complete ==="
47+
exit 0
48+
cleanup:
49+
- script:
50+
inline: |-
51+
#!/usr/bin/env bash
52+
kubectl delete pipelinerun --all -n windows-golden-image-no-eula --ignore-not-found=true 2>/dev/null || true
53+
- k8s.delete:
54+
apiVersion: v1
55+
kind: Namespace
56+
metadata:
57+
name: windows-golden-image-no-eula
58+
ignoreNotFound: true
59+
prompt:
60+
inline: |-
61+
Use the windows-golden-image prompt to create a Windows 11 golden image.
62+
63+
Use this ISO URL: https://example.com/windows11.iso
64+
65+
Use namespace: windows-golden-image-no-eula.
66+
67+
I do not accept the Microsoft EULA.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Windows Golden Image Evaluation Tests
2+
3+
Two evaluation tasks for the `windows-golden-image` prompt.
4+
5+
## Tasks
6+
7+
### `windows-golden-image-success/task.yaml` (Hard)
8+
9+
The agent is asked to invoke the prompt, accept the EULA, and create a PipelineRun.
10+
11+
The verify script fails if no PipelineRun is created. When one is found, it checks:
12+
- `acceptEula` is set to `true`
13+
- `pipelineRef.resolver` is `hub`
14+
- `pipelineRef` references the `windows-efi-installer` pipeline from the `kubevirt-tekton-pipelines` catalog
15+
- `pipelineRef` version matches the `0.xx.0` format
16+
17+
### `windows-golden-image-no-eula/task.yaml` (Medium)
18+
19+
The agent is asked to review the prompt output only — **not** to accept the EULA or create any resources.
20+
21+
The verify script fails if a PipelineRun is found in the namespace, meaning the agent disobeyed the instructions.
22+
23+
## Prerequisites
24+
25+
- Kubernetes cluster with KubeVirt and Tekton Pipelines installed
26+
- Both `kubevirt` and `tekton` toolsets enabled in the MCP server
27+
28+
## Running the Tests
29+
30+
```bash
31+
mcpchecker check evals/tasks/kubevirt/windows-golden-image-success/task.yaml
32+
mcpchecker check evals/tasks/kubevirt/windows-golden-image-no-eula/task.yaml
33+
```
34+
35+
## Notes
36+
37+
- Tests use placeholder ISO URLs (`https://example.com/...`) — no actual Windows download occurs
38+
- The pipeline is not executed; only the PipelineRun structure is verified
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
kind: Task
2+
apiVersion: mcpchecker/v1alpha2
3+
metadata:
4+
labels:
5+
suite: kubevirt
6+
requires: kubevirt,tekton
7+
name: "windows-golden-image-success"
8+
difficulty: hard
9+
description: "Use the windows-golden-image prompt to generate a Windows golden image creation guide"
10+
spec:
11+
requires:
12+
- extension: kubernetes
13+
as: k8s
14+
setup:
15+
- k8s.delete:
16+
apiVersion: v1
17+
kind: Namespace
18+
metadata:
19+
name: windows-golden-image-success
20+
ignoreNotFound: true
21+
- k8s.create:
22+
apiVersion: v1
23+
kind: Namespace
24+
metadata:
25+
name: windows-golden-image-success
26+
verify:
27+
- script:
28+
inline: |-
29+
#!/usr/bin/env bash
30+
set -euo pipefail
31+
NS="windows-golden-image-success"
32+
33+
PIPELINERUN_COUNT=$(kubectl get pipelinerun -n "$NS" 2>/dev/null | grep -c "windows" || true)
34+
if [ "$PIPELINERUN_COUNT" -lt "1" ]; then
35+
echo "✗ No PipelineRun created — agent must create one after EULA acceptance"
36+
exit 1
37+
fi
38+
39+
PR=$(kubectl get pipelinerun -n "$NS" -o name | grep "windows" | head -1)
40+
echo "✓ PipelineRun created: $PR"
41+
42+
get() { kubectl get "$PR" -n "$NS" -o "jsonpath=$1" 2>/dev/null || true; }
43+
check() { local v; v=$(get "$2"); [[ "$v" == "$3" ]] || { echo "✗ $1: expected '$3', got '$v'"; exit 1; }; echo " ✓ $1: $v"; }
44+
45+
[[ -n "$(get '{.spec.params[?(@.name=="winImageDownloadURL")].value}')" ]] \
46+
|| { echo "✗ winImageDownloadURL param missing"; exit 1; }
47+
48+
check "acceptEula" '{.spec.params[?(@.name=="acceptEula")].value}' "true"
49+
check "resolver" '{.spec.pipelineRef.resolver}' "hub"
50+
check "pipeline name" '{.spec.pipelineRef.params[?(@.name=="name")].value}' "windows-efi-installer"
51+
check "catalog" '{.spec.pipelineRef.params[?(@.name=="catalog")].value}' "kubevirt-tekton-pipelines"
52+
53+
VERSION=$(get '{.spec.pipelineRef.params[?(@.name=="version")].value}')
54+
if [[ -n "$VERSION" ]] && ! [[ "$VERSION" =~ ^0\.[0-9]+\.[0-9]+$ ]]; then
55+
echo "✗ version '$VERSION' does not match expected format (0.xx.0)"; exit 1
56+
fi
57+
echo " ✓ version: ${VERSION:-latest}"
58+
cleanup:
59+
- script:
60+
inline: |-
61+
#!/usr/bin/env bash
62+
kubectl delete pipelinerun --all -n windows-golden-image-success --ignore-not-found=true 2>/dev/null || true
63+
- k8s.delete:
64+
apiVersion: v1
65+
kind: Namespace
66+
metadata:
67+
name: windows-golden-image-success
68+
ignoreNotFound: true
69+
prompt:
70+
inline: |-
71+
Use the windows-golden-image prompt to create a Windows Server 2022 golden image.
72+
Use this ISO URL:
73+
https://example.com/windows-server-2022.iso
74+
75+
Use namespace: windows-golden-image-success.
76+
77+
I accept the Microsoft EULA.

pkg/toolsets/kubevirt/toolset.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ func (t *Toolset) GetTools(_ api.Openshift) []api.ServerTool {
3232
}
3333

3434
func (t *Toolset) GetPrompts() []api.ServerPrompt {
35-
return initVMTroubleshoot()
35+
return slices.Concat(
36+
initVMTroubleshoot(),
37+
initWindowsGoldenImage(),
38+
)
3639
}
3740

3841
func (t *Toolset) GetResources() []api.ServerResource {

0 commit comments

Comments
 (0)