Managing virtual machines with OpenShift Pipelines

Red Hat OpenShift Pipelines is a Kubernetes-native CI/CD framework that allows developers to design and run each step of the CI/CD pipeline in its own container.

The Tekton Tasks Operator (TTO) integrates OKD Virtualization with OpenShift Pipelines. TTO includes cluster tasks and example pipelines that allow you to:

  • Create and manage virtual machines (VMs), persistent volume claims (PVCs), and data volumes

  • Run commands in VMs

  • Manipulate disk images with libguestfs tools

Managing virtual machines with Red Hat OpenShift Pipelines is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.

Prerequisites

  • You have access to an OKD cluster with cluster-admin permissions.

  • You have installed the OpenShift CLI (oc).

  • You have installed OpenShift Pipelines.

Deploying the Tekton Tasks Operator resources

The Tekton Tasks Operator (TTO) cluster tasks and example pipelines are not deployed by default when you install OKD Virtualization. To deploy TTO resources, enable the deployTektonTaskResources feature gate in the HyperConverged custom resource (CR).

Procedure

  1. Open the HyperConverged CR in your default editor by running the following command:

    1. $ oc edit hco -n openshift-cnv kubevirt-hyperconverged
  2. Set the spec.featureGates.deployTektonTaskResources field to true.

    1. apiVersion: hco.kubevirt.io/v1beta1
    2. kind: HyperConverged
    3. metadata:
    4. name: kubevirt-hyperconverged
    5. namespace: kubevirt-hyperconverged
    6. spec:
    7. tektonPipelinesNamespace: <user_namespace> (1)
    8. featureGates:
    9. deployTektonTaskResources: true (2)
    10. # ...
    1The namespace where the pipelines are to be run.
    2The feature gate to be enabled to deploy TTO resources.

    The cluster tasks and example pipelines remain available even if you disable the feature gate later.

  3. Save your changes and exit the editor.

Virtual machine tasks supported by the Tekton Tasks Operator

The following table shows the cluster tasks that are included as part of the Tekton Tasks Operator.

Table 1. Virtual machine tasks supported by the Tekton Tasks Operator
TaskDescription

create-vm-from-template

Create a virtual machine from a template.

copy-template

Copy a virtual machine template.

modify-vm-template

Modify a virtual machine template.

modify-data-object

Create or delete data volumes or data sources.

cleanup-vm

Run a script or a command in a virtual machine and stop or delete the virtual machine afterward.

disk-virt-customize

Use the virt-customize tool to run a customization script on a target PVC.

disk-virt-sysprep

Use the virt-sysprep tool to run a sysprep script on a target PVC.

wait-for-vmi-status

Wait for a specific status of a virtual machine instance and fail or succeed based on the status.

Example pipelines

The Tekton Tasks Operator includes the following example Pipeline manifests. You can run the example pipelines by using the web console or CLI.

You might have to run more than one installer pipline if you need multiple versions of Windows. If you run more than one installer pipeline, each one requires unique parameters, such as the autounattend config map and base image name. For example, if you need Windows 10 and Windows 11 or Windows Server 2022 images, you have to run both the Windows efi installer pipeline and the Windows bios installer pipeline. However, if you need Windows 11 and Windows Server 2022 images, you have to run only the Windows efi installer pipeline.

Windows EFI installer pipeline

This pipeline installs Windows 11 or Windows Server 2022 into a new data volume from a Windows installation image (ISO file). A custom answer file is used to run the installation process.

Windows BIOS installer pipeline

This pipeline installs Windows 10 into a new data volume from a Windows installation image, also called an ISO file. A custom answer file is used to run the installation process.

Windows customize pipeline

This pipeline clones the data volume of a basic Windows 10, 11, or Windows Server 2022 installation, customizes it by installing Microsoft SQL Server Express or Microsoft Visual Studio Code, and then creates a new image and template.

Running the example pipelines using the web console

You can run the example pipelines from the Pipelines menu in the web console.

Procedure

  1. Click PipelinesPipelines in the side menu.

  2. Select a pipeline to open the Pipeline details page.

  3. From the Actions list, select Start. The Start Pipeline dialog is displayed.

  4. Keep the default values for the parameters and then click Start to run the pipeline. The Details tab tracks the progress of each task and displays the pipeline status.

Running the example pipelines using the CLI

Use a PipelineRun resource to run the example pipelines. A PipelineRun object is the running instance of a pipeline. It instantiates a pipeline for execution with specific inputs, outputs, and execution parameters on a cluster. It also creates a TaskRun object for each task in the pipeline.

Procedure

  1. To run the Windows 10 installer pipeline, create the following PipelineRun manifest:

    1. apiVersion: tekton.dev/v1beta1
    2. kind: PipelineRun
    3. metadata:
    4. generateName: windows10-installer-run-
    5. labels:
    6. pipelinerun: windows10-installer-run
    7. spec:
    8. params:
    9. - name: winImageDownloadURL
    10. value: <link_to_windows_10_iso> (1)
    11. pipelineRef:
    12. name: windows10-installer
    13. taskRunSpecs:
    14. - pipelineTaskName: copy-template
    15. taskServiceAccountName: copy-template-task
    16. - pipelineTaskName: modify-vm-template
    17. taskServiceAccountName: modify-vm-template-task
    18. - pipelineTaskName: create-vm-from-template
    19. taskServiceAccountName: create-vm-from-template-task
    20. - pipelineTaskName: wait-for-vmi-status
    21. taskServiceAccountName: wait-for-vmi-status-task
    22. - pipelineTaskName: create-base-dv
    23. taskServiceAccountName: modify-data-object-task
    24. - pipelineTaskName: cleanup-vm
    25. taskServiceAccountName: cleanup-vm-task
    26. status: {}
    1Specify the URL for the Windows 10 64-bit ISO file. The product language must be English (United States).
  2. Apply the PipelineRun manifest:

    1. $ oc apply -f windows10-installer-run.yaml
  3. To run the Windows 10 customize pipeline, create the following PipelineRun manifest:

    1. apiVersion: tekton.dev/v1beta1
    2. kind: PipelineRun
    3. metadata:
    4. generateName: windows10-customize-run-
    5. labels:
    6. pipelinerun: windows10-customize-run
    7. spec:
    8. params:
    9. - name: allowReplaceGoldenTemplate
    10. value: true
    11. - name: allowReplaceCustomizationTemplate
    12. value: true
    13. pipelineRef:
    14. name: windows10-customize
    15. taskRunSpecs:
    16. - pipelineTaskName: copy-template-customize
    17. taskServiceAccountName: copy-template-task
    18. - pipelineTaskName: modify-vm-template-customize
    19. taskServiceAccountName: modify-vm-template-task
    20. - pipelineTaskName: create-vm-from-template
    21. taskServiceAccountName: create-vm-from-template-task
    22. - pipelineTaskName: wait-for-vmi-status
    23. taskServiceAccountName: wait-for-vmi-status-task
    24. - pipelineTaskName: create-base-dv
    25. taskServiceAccountName: modify-data-object-task
    26. - pipelineTaskName: cleanup-vm
    27. taskServiceAccountName: cleanup-vm-task
    28. - pipelineTaskName: copy-template-golden
    29. taskServiceAccountName: copy-template-task
    30. - pipelineTaskName: modify-vm-template-golden
    31. taskServiceAccountName: modify-vm-template-task
    32. status: {}
  4. Apply the PipelineRun manifest:

    1. $ oc apply -f windows10-customize-run.yaml

Additional resources