Skip to content
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

chore: deploy configmaps as a part of pipeline #375

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ spec:
value: win10
- name: isoDVName
value: win10
- name: acceptEula
value: "true"
pipelineRef:
name: windows-efi-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
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).
The pipeline uses a ConfigMap containing an `unattend.xml` file for automated customization of Windows. Example ConfigMaps are deployed within the Pipeline. In case you would like to use a different ConfigMap, specify a different URL in the `unattendXMLConfigMapsURL` parameter and adjust `customizeConfigMapName` parameter with correct the `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: Allows to specify a download URL to a file with ConfigMaps containing a Windows `unattend.xml` file. These ConfigMaps can be used for automated customization of Windows. Specify the desired 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,7 +58,28 @@ spec:
type: string
default: win11-customized
tasks:
- name: import-unattend-configmaps
params:
- name: SCRIPT
value: oc apply -f $(params.unattendXMLConfigMapsURL)
- name: VERSION
value: latest
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
runAfter:
- import-unattend-configmaps
taskRef:
resolver: hub
params:
Expand Down Expand Up @@ -187,6 +212,25 @@ spec:
value: cleanup-vm
- name: version
value: v0.20.0
- name: delete-imported-configmaps
0xFelix marked this conversation as resolved.
Show resolved Hide resolved
params:
- name: SCRIPT
value: oc delete -f $(params.unattendXMLConfigMapsURL)
- name: VERSION
value: latest
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
38 changes: 22 additions & 16 deletions release/pipelines/windows-efi-installer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,28 @@ 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, replace the lines `<AcceptEula>false<\/AcceptEula>` with `<AcceptEula>true<\/AcceptEula>`, or run this command:
```
sed -i "s/<AcceptEula>false<\/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 a different ConfigMap, specify a different URL in the `autounattendXMLConfigMapsURL` parameter and adjust `autounattendConfigMapName` parameter with the 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). Pipeline automatically removes ConfigMaps at the end of the PipelineRun. If the content available in `autounattendXMLConfigMapsURL` changes during the Pipeline run, Pipeline may not remove all the objects it created.

> [!IMPORTANT]
> Example PipelineRuns have special parameter acceptEula. By setting this parameter, you are agreeing to the applicable
> Microsoft end user license agreement(s) for each deployment or installation for the Microsoft product(s). In case you
> set it to false, the Pipeline will exit in first task.

Pipeline runs with resolvers:
```yaml
Expand All @@ -84,6 +86,8 @@ spec:
params:
- name: winImageDownloadURL
value: ${WIN_IMAGE_DOWNLOAD_URL}
- name: acceptEula
value: false
pipelineRef:
params:
- name: catalog
Expand Down Expand Up @@ -157,6 +161,8 @@ spec:
params:
- name: winImageDownloadURL
value: ${WIN_IMAGE_DOWNLOAD_URL}
- name: acceptEula
value: false
- name: preferenceName
value: windows.2k22
- name: autounattendConfigMapName
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: false
pipelineRef:
resolver: hub
params:
Expand Down Expand Up @@ -74,6 +76,8 @@ spec:
params:
- name: winImageDownloadURL
value: ${WIN_IMAGE_DOWNLOAD_URL}
- name: acceptEula
value: false
- name: preferenceName
value: windows.2k22
- name: autounattendConfigMapName
Expand Down
56 changes: 56 additions & 0 deletions release/pipelines/windows-efi-installer/windows-efi-installer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ spec:
- description: Download URL to Windows 11 or server 2022 installation ISO (English United States x64 version is needed). You can follow https://www.microsoft.com/en-us/software-download/windows11 or https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2022 to get one.
name: winImageDownloadURL
type: string
- name: acceptEula
description: By setting this parameter, you are agreeing to the applicable Microsoft end user license agreement(s) for each deployment or installation for the Microsoft product(s).
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.
ksimon1 marked this conversation as resolved.
Show resolved Hide resolved
type: string
default: https://raw.githubusercontent.com/kubevirt/kubevirt-tekton-tasks/main/release/pipelines/windows-efi-installer/configmaps/windows-efi-installer-configmaps.yaml
- name: instanceTypeName
type: string
description: Name of VirtualMachineClusterInstancetype object
Expand Down Expand Up @@ -61,6 +68,34 @@ spec:
name: isoDVName
type: string
tasks:
- name: import-autounattend-configmaps
params:
- name: SCRIPT
value: |-
if [ "$(params.acceptEula)" ]; then
curl $(params.autounattendXMLConfigMapsURL) | \
sed "s/<AcceptEula>false<\/AcceptEula>/<AcceptEula>true<\/AcceptEula>/g" | \
oc apply -f -
else
echo "Microsoft Eula is not accepted"
echo "Exiting"
exit 1
fi
- name: VERSION
value: latest
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: import-win-iso
params:
- name: manifest
Expand Down Expand Up @@ -116,6 +151,8 @@ spec:
- name: version
value: v0.20.0
- name: create-vm-root-disk
runAfter:
- import-autounattend-configmaps
taskRef:
resolver: hub
params:
Expand Down Expand Up @@ -290,6 +327,25 @@ spec:
value: modify-data-object
- name: version
value: v0.20.0
- name: delete-imported-configmaps
params:
- name: SCRIPT
value: oc delete -f $(params.autounattendXMLConfigMapsURL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we cache the config map somewhere? If it changes during the pipeline run, then the delete might not work as expected.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use the customizeConfigMapName or autounattendConfigMapName params to delete the correct configmaps instead of URL

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem will be, if the URL contains multiple configmaps, then it will delete only single CM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you return the created config maps as a result in import-unattend-configmaps and use that result to delete them in delete-imported-configmaps?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, because the task does not have results defined in manifest https://github.com/tektoncd/catalog/blob/main/task/openshift-client/0.2/openshift-client.yaml#L14

Copy link
Member

@0xFelix 0xFelix Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you perhaps cache the ConfigMaps file in a Workspace instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not mistaken, the workspaces requires record in PipelinerRun (see the note in https://tekton.dev/docs/pipelines/workspaces/#specifying-workspaces-in-pipelineruns). That means, we would break triggering of the pipeline from the UI. Users would have to build their own manifest for triggering the pipeline, which would go against the idea of this pipeline.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunate. I'm just concerned this will be handed back to us as a possible bug in the future. If there's not other way, maybe we can at least document it in the description or somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair point, let me update it tomorrow

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documented in 4bda75d

- name: VERSION
value: latest
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:
- description: Name of the created base DataVolume
name: baseDvName
Expand Down
3 changes: 3 additions & 0 deletions scripts/ansible/variables.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
os_image_namespace: kubevirt-os-images
catalog: kubevirt-tekton-tasks
openshift_client_catalog: tekton-catalog-tasks
openshift_client_task_version: 0.2.0
openshift_client_oc_version: latest
catalog_type: artifact
pipelines_catalog: kubevirt-tekton-pipelines
3 changes: 0 additions & 3 deletions scripts/deploy-pipelines.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@ USE_RESOLVER_IN_MANIFESTS=false make generate-pipelines
visit "${REPO_DIR}/release/pipelines"
for PIPELINE_NAME in "windows-efi-installer" "windows-customize"; do
oc apply -f "${PIPELINE_NAME}/${PIPELINE_NAME}.yaml"
# uncomment accepting eula in autounattend.xml
sed -i "s/<AcceptEula>false<\/AcceptEula>/<AcceptEula>true<\/AcceptEula>/g" "${PIPELINE_NAME}/configmaps/${PIPELINE_NAME}-configmaps.yaml"
oc apply -f "${PIPELINE_NAME}/configmaps"
done
leave
20 changes: 10 additions & 10 deletions templates-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).
The pipeline uses a ConfigMap containing an `unattend.xml` file for automated customization of Windows. Example ConfigMaps are deployed within the Pipeline. In case you would like to use a different ConfigMap, specify a different URL in the `unattendXMLConfigMapsURL` parameter and adjust `customizeConfigMapName` parameter with correct the `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:
{% for item in pipeline_runs_yaml %}
Expand Down
Loading