Skip to content

Commit

Permalink
chore: deploy configmaps as a part of pipeline
Browse files Browse the repository at this point in the history
this change will remove the step, when user has to manually create
the necessary ConfigMaps needed by VM. They are now deployed
and removed by the Pipeline.

Signed-off-by: Karel Simon <[email protected]>
  • Loading branch information
ksimon1 committed May 7, 2024
1 parent 50f48be commit c89d715
Show file tree
Hide file tree
Showing 20 changed files with 417 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ spec:
params:
- name: winImageDownloadURL
value: http://http-server/disk.img
- name: acceptEula
value: "true"
pipelineRef:
name: windows-bios-installer
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ spec:
value: http://http-server/disk.img
- name: baseDvNamespace
value: kubevirt
- name: acceptEula
value: "true"
pipelineRef:
name: windows-efi-installer
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ spec:
params:
- name: winImageDownloadURL
value: http://http-server/disk.img
- name: acceptEula
value: "true"
- name: preferenceName
value: windows.2k22
- name: autounattendConfigMapName
Expand Down
26 changes: 15 additions & 11 deletions release/pipelines/windows-bios-installer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,27 @@ The Pipeline implements this by spinning up a new VirtualMachine which boots fro
## Pipeline Description

```
create-vm-root-disk --- create-vm --- wait-for-vmi-status --- cleanup-vm
import-autounattend-configmaps --- create-vm-root-disk --- create-vm --- wait-for-vmi-status --- cleanup-vm --- delete-imported-configmaps
```

1. `create-vm-root-disk` Task creates an empty DataVolume.
2. `create-vm` Task creates a VirtualMachine called `windows-bios-installer-*`
1. `import-autounattend-configmaps` imports ConfigMap with autounattend xml needed for automated installation of Windows.
2. `create-vm-root-disk` Task creates an empty DataVolume.
3. `create-vm` Task creates a VirtualMachine called `windows-bios-installer-*`
from the empty DataVolume and with the `windows-bios-installer-cd-rom` DataVolume attached as a CD-ROM.
A second DataVolume with the virtio-win ISO will also be attached (Pipeline parameter `virtioContainerDiskName`). The VirtualMachine has to be created in the same namespace as the empty DataVolume.
3. `wait-for-vmi-status` Task waits until the VirtualMachine shuts down.
4. `cleanup-vm` deletes the installer VirtualMachine and ISO DataVolume (also in case of failure of the previous Tasks).
5. The output artifact will be the `win10` DataVolume with the basic Windows installation.
4. `wait-for-vmi-status` Task waits until the VirtualMachine shuts down.
5. `cleanup-vm` deletes the installer VirtualMachine and ISO DataVolume (also in case of failure of the previous Tasks).
6. The output artifact will be the `win10` DataVolume with the basic Windows installation.
It will boot into the Windows OOBE and needs to be setup further before it can be used.
7. `delete-imported-configmaps` deletes imported ConfigMaps.

## How to run

Before you create PipelineRuns, you must create ConfigMaps with an autounattend.xml in the same namespace in which the VirtualMachine will be created.
Examples of ConfigMaps can be found [here](https://github.com/kubevirt/kubevirt-tekton-tasks/tree/main/release/pipelines/windows-bios-installer/configmaps). Before applying ConfigMap, uncomment the lines with `<AcceptEula>true<\/AcceptEula>`, or run this command:
```
sed -i "s/<!-- <AcceptEula>true<\/AcceptEula> -->/<AcceptEula>true<\/AcceptEula>/g" "configmaps/windows-bios-installer-configmaps.yaml"
```
Pipeline uses ConfigMaps with autounattend.xml file for automated installation of Windows from ISO file. Example ConfigMaps are deployed within the Pipeline. In case you would like to use different ConfigMap, specify different URL to `autounattendXMLConfigmapsURL` parameter and adjust `autounattendConfigMapName` parameter with correct ConfigMap name. Examples of ConfigMaps can be found [here](https://github.com/kubevirt/kubevirt-tekton-tasks/tree/main/release/pipelines/windows-bios-installer/configmaps).

> [!IMPORTANT]
> Example PipelineRuns have special parameter acceptEula. By setting this parameter to true, you are accepting Eula
> specified in autounattend.xml file in ConfigMap. For more information please contact Microsoft of your legal department.
Pipeline run with resolver:
```yaml
Expand All @@ -59,6 +61,8 @@ spec:
params:
- name: winImageDownloadURL
value: ${WIN_IMAGE_DOWNLOAD_URL}
- name: acceptEula
value: <replace with true or false>
pipelineRef:
params:
- name: catalog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ spec:
params:
- name: winImageDownloadURL
value: ${WIN_IMAGE_DOWNLOAD_URL}
- name: acceptEula
value: <replace with true or false>
pipelineRef:
resolver: hub
params:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ spec:
- name: winImageDownloadURL
description: Download URL to Windows installation ISO (English United States x64 version is needed). You can follow e.g. https://www.microsoft.com/en-us/software-download/windows10ISO to get windows 10 iso.
type: string
- name: acceptEula
description: By setting this parameter to true, you are accepting Eula specified in autounattend.xml file in ConfigMap. For more information please contact Microsoft of your legal department.
type: string
- name: autounattendXMLConfigmapsURL
description: Download URL to ConfigMaps with Windows autounattend.xml file. ConfigMap is used for automated installation of Windows from ISO file. Specify the correct ConfigMap name in `autounattendConfigMapName` parameter.
type: string
default: https://raw.githubusercontent.com/kubevirt/kubevirt-tekton-tasks/main/release/pipelines/windows-bios-installer/configmaps/windows-bios-installer-configmaps.yaml
- name: instanceTypeName
type: string
description: Name of VirtualMachineClusterInstancetype object
Expand Down Expand Up @@ -61,6 +68,32 @@ spec:
type: string
default: win10
tasks:
- name: import-autounattend-configmaps
params:
- name: SCRIPT
value: |-
if [ $(params.acceptEula) ]; then
curl -o $(params.autounattendXMLConfigMapsURL) configmap.yaml
sed -i "s/<!-- <AcceptEula>true<\/AcceptEula> -->/<AcceptEula>true<\/AcceptEula>/g" configmap.yaml
oc apply -f configmap.yaml
else
exit 1
fi
- name: VERSION
value: 4.15
taskRef:
resolver: hub
params:
- name: catalog
value: tekton-catalog-tasks
- name: type
value: artifact
- name: kind
value: task
- name: name
value: openshift-client
- name: version
value: 0.2.0
- name: create-vm-root-disk
taskRef:
resolver: hub
Expand All @@ -75,6 +108,8 @@ spec:
value: modify-data-object
- name: version
value: v0.19.0
runAfter:
- import-autounattend-configmaps
params:
- name: manifest
value: |-
Expand Down Expand Up @@ -227,6 +262,25 @@ spec:
value: cleanup-vm
- name: version
value: v0.19.0
- name: delete-imported-configmaps
params:
- name: SCRIPT
value: oc apply -f $(params.autounattendXMLConfigMapsURL)
- name: VERSION
value: 4.15
taskRef:
resolver: hub
params:
- name: catalog
value: tekton-catalog-tasks
- name: type
value: artifact
- name: kind
value: task
- name: name
value: openshift-client
- name: version
value: 0.2.0
results:
- name: baseDvName
description: Name of the created base DataVolume
Expand Down
20 changes: 10 additions & 10 deletions release/pipelines/windows-customize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ The provided reference ConfigMap (`windows-sqlserver`) boots Windows 10, 11 or W
## Pipeline Description

```
copy-vm-root-disk --- create-vm --- wait-for-vmi-status --- cleanup-vm
import-unattend-configmaps --- copy-vm-root-disk --- create-vm --- wait-for-vmi-status --- cleanup-vm --- delete-imported-configmaps
```

1. `copy-vm-root-disk` Task copies PVC defined in `sourceDiskImageName` and `sourceDiskImageNamespace` parameters.
2. `create-vm` Task creates a VirtualMachine called `windows-customize-*` from the base DataVolume and with the customize ConfigMap attached as a CD-ROM (Pipeline parameter `customizeConfigMapName`). The VirtualMachine has to be created in the same namespace as the source DataVolume.
3. `wait-for-vmi-status` Task waits until the VirtualMachine shuts down.
4. `cleanup-vm` deletes the installer VirtualMachine (also in case of failure of the previous Tasks).
5. The output artifact will be the `win*-customized` DataVolume with the customized Windows installation. It will boot into the Windows OOBE and needs to be setup further before it can be used (depends on the applied customizations).
6. The `windows11-unattend` ConfigMap can be used to boot the VirtualMachine into the Desktop (depends on the applied customizations).
1. `import-unattend-configmaps` imports ConfigMap with unattend xml needed for automated customization of Windows.
2. `copy-vm-root-disk` Task copies PVC defined in `sourceDiskImageName` and `sourceDiskImageNamespace` parameters.
3. `create-vm` Task creates a VirtualMachine called `windows-customize-*` from the base DataVolume and with the customize ConfigMap attached as a CD-ROM (Pipeline parameter `customizeConfigMapName`). The VirtualMachine has to be created in the same namespace as the source DataVolume.
4. `wait-for-vmi-status` Task waits until the VirtualMachine shuts down.
5. `cleanup-vm` deletes the installer VirtualMachine (also in case of failure of the previous Tasks).
6. The output artifact will be the `win*-customized` DataVolume with the customized Windows installation. It will boot into the Windows OOBE and needs to be setup further before it can be used (depends on the applied customizations).
7. The `windows11-unattend` ConfigMap can be used to boot the VirtualMachine into the Desktop (depends on the applied customizations).
8. `delete-imported-configmaps` deletes imported ConfigMaps.

## How to run

Before you create PipelineRuns, you must create ConfigMaps with an autounattend.xml in the same namespace in which the VirtualMachine will be created.
Examples of ConfigMaps can be found [here](https://github.com/kubevirt/kubevirt-tekton-tasks/tree/main/release/pipelines/windows-customize/configmaps).
Pipeline uses ConfigMaps with unattend.xml file for automated customization of Windows. Example ConfigMaps are deployed within the Pipeline. In case you would like to use different ConfigMap, specify different URL to `unattendXMLConfigmapsURL` parameter and adjust `customizeConfigMapName` parameter with correct ConfigMap name. Examples of ConfigMaps can be found [here](https://github.com/kubevirt/kubevirt-tekton-tasks/tree/main/release/pipelines/windows-customize/configmaps).

Pipeline runs with resolvers:
```yaml
Expand Down
44 changes: 44 additions & 0 deletions release/pipelines/windows-customize/windows-customize.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ spec:
reused for customizing Windows 10, 11 or server 2k22. Different OS versions
requires different customizeConfigMapName parameter with unattend.xml.
params:
- name: unattendXMLConfigmapsURL
description: Download URL to Configmaps with Windows unattend.xml file. Configmap is used for automated customization of Windows. Specify the correct ConfigMap name in `customizeConfigMapName` parameter.
type: string
default: https://raw.githubusercontent.com/kubevirt/kubevirt-tekton-tasks/main/release/pipelines/windows-customize/configmaps/windows-customize-configmaps.yaml
- name: instanceTypeName
type: string
description: Name of VirtualMachineClusterInstancetype object
Expand Down Expand Up @@ -54,6 +58,25 @@ spec:
type: string
default: win11-customized
tasks:
- name: import-unattend-configmaps
params:
- name: SCRIPT
value: oc apply -f $(params.unattendXMLConfigMapsURL)
- name: VERSION
value: 4.15
taskRef:
resolver: hub
params:
- name: catalog
value: tekton-catalog-tasks
- name: type
value: artifact
- name: kind
value: task
- name: name
value: openshift-client
- name: version
value: 0.2.0
- name: copy-vm-root-disk
taskRef:
resolver: hub
Expand All @@ -68,6 +91,8 @@ spec:
value: modify-data-object
- name: version
value: v0.19.0
runAfter:
- import-unattend-configmaps
params:
- name: manifest
value: |-
Expand Down Expand Up @@ -187,6 +212,25 @@ spec:
value: cleanup-vm
- name: version
value: v0.19.0
- name: delete-imported-configmaps
params:
- name: SCRIPT
value: oc apply -f $(params.unattendXMLConfigMapsURL)
- name: VERSION
value: 4.15
taskRef:
resolver: hub
params:
- name: catalog
value: tekton-catalog-tasks
- name: type
value: artifact
- name: kind
value: task
- name: name
value: openshift-client
- name: version
value: 0.2.0
results:
- name: baseDvName
description: Name of the created base DataVolume
Expand Down
35 changes: 19 additions & 16 deletions release/pipelines/windows-efi-installer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,27 @@ After the ISO is modified it creates a new VirtualMachine which boots from the m
## Pipeline Description

```
import-win-iso --- modify-windows-iso-file --- create-vm --- wait-for-vmi-status --- cleanup-vm
|
create-vm-root-disk ---
import-autounattend-configmaps --- import-win-iso --- modify-windows-iso-file --- create-vm --- wait-for-vmi-status --- cleanup-vm --- delete-imported-configmaps
|
create-vm-root-disk ---
```

1. `create-vm-root-disk` creates empty DataVolume which is used for Windows installation.
2. `import-win-iso` creates new DataVolume with Windows ISO file with name defined in `isoDVName` parameter. The DataVolume needs to be in the same namespace as the PipelineRun (because the PVC is mounted into the PipelineRun pod).
3. `modify-windows-iso-file` extracts imported ISO file, replaces prompt bootloader (which is used as a default one when EFI is used) with no-prompt bootloader, pack the updated files back to new ISO, convert the ISO and replaces original ISO with updated one.Replacement of bootloader is needed to be able to automate installation of Windows versions which require EFI.
4. `create-vm` Task creates a VirtualMachine. A DataVolume with the Windows source ISO will be attached as CD-ROM and a second empty DataVolume will be used as installation destination. A third DataVolume with the virtio-win ISO will also be attached (Pipeline parameter `virtioContainerDiskName`). The VirtualMachine has to be created in the same namespace as the DataVolume with the ISO file. In case you would like to run the VirtualMachine in a different namespace, both Datavolumes have to be copied to the same namespace as the VirtualMachine.
5. `wait-for-vmi-status` Task waits until the VirtualMachine shuts down.
6. `cleanup-vm` deletes the installer VirtualMachine and all of its DataVolumes.
7. The output artifact will be the `baseDvName`/`baseDvNamespace` DataVolume with the basic Windows installation. It will boot into the Windows OOBE and needs to be setup further before it can be used.
1. `import-autounattend-configmaps` imports ConfigMap with autounattend xml needed for automated installation of Windows.
2. `create-vm-root-disk` creates empty DataVolume which is used for Windows installation.
3. `import-win-iso` creates new DataVolume with Windows ISO file with name defined in `isoDVName` parameter. The DataVolume needs to be in the same namespace as the PipelineRun (because the PVC is mounted into the PipelineRun pod).
4. `modify-windows-iso-file` extracts imported ISO file, replaces prompt bootloader (which is used as a default one when EFI is used) with no-prompt bootloader, pack the updated files back to new ISO, convert the ISO and replaces original ISO with updated one.Replacement of bootloader is needed to be able to automate installation of Windows versions which require EFI.
5. `create-vm` Task creates a VirtualMachine. A DataVolume with the Windows source ISO will be attached as CD-ROM and a second empty DataVolume will be used as installation destination. A third DataVolume with the virtio-win ISO will also be attached (Pipeline parameter `virtioContainerDiskName`). The VirtualMachine has to be created in the same namespace as the DataVolume with the ISO file. In case you would like to run the VirtualMachine in a different namespace, both Datavolumes have to be copied to the same namespace as the VirtualMachine.
6. `wait-for-vmi-status` Task waits until the VirtualMachine shuts down.
7. `cleanup-vm` deletes the installer VirtualMachine and all of its DataVolumes.
8. The output artifact will be the `baseDvName`/`baseDvNamespace` DataVolume with the basic Windows installation. It will boot into the Windows OOBE and needs to be setup further before it can be used.
9. `delete-imported-configmaps` deletes imported ConfigMaps.

## How to run

Before you create PipelineRuns, you must create ConfigMaps with an autounattend.xml in the same namespace in which the VirtualMachine will be created.
Examples of ConfigMaps can be found [here](https://github.com/kubevirt/kubevirt-tekton-tasks/tree/main/release/pipelines/windows-efi-installer/configmaps). Before applying ConfigMap, uncomment the lines with `<AcceptEula>true<\/AcceptEula>`, or run this command:
```
sed -i "s/<!-- <AcceptEula>true<\/AcceptEula> -->/<AcceptEula>true<\/AcceptEula>/g" "configmaps/windows-efi-installer-configmaps.yaml"
```
Pipeline uses ConfigMaps with autounattend.xml file for automated installation of Windows from ISO file. Example ConfigMaps are deployed within the Pipeline. In case you would like to use different ConfigMap, specify different URL to `autounattendXMLConfigmapsURL` parameter and adjust `autounattendConfigMapName` parameter with correct ConfigMap name. Examples of ConfigMaps can be found [here](https://github.com/kubevirt/kubevirt-tekton-tasks/tree/main/release/pipelines/windows-efi-installer/configmaps).

> [!IMPORTANT]
> Example PipelineRuns have special parameter acceptEula. By setting this parameter to true, you are accepting Eula
> specified in autounattend.xml file in ConfigMap. For more information please contact Microsoft of your legal department.
Pipeline runs with resolvers:
```yaml
Expand All @@ -79,6 +80,8 @@ spec:
params:
- name: winImageDownloadURL
value: ${WIN_IMAGE_DOWNLOAD_URL}
- name: acceptEula
value: <replace with true or false>
pipelineRef:
params:
- name: catalog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ spec:
params:
- name: winImageDownloadURL
value: ${WIN_IMAGE_DOWNLOAD_URL}
- name: acceptEula
value: <replace with true or false>
pipelineRef:
resolver: hub
params:
Expand Down
Loading

0 comments on commit c89d715

Please sign in to comment.