Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Create software templates for VMs with OpenShift Virtualization

Increasing developer productivity with OpenShift Virtualization and Red Hat Developer Hub: Part 3

August 16, 2024
Valentina Rodriguez Sosa
Related topics:
Developer ProductivityDeveloper ToolsDevOpsGitOpsHelmApplication modernizationVirtualization
Related products:
Red Hat Developer HubRed Hat OpenShiftRed Hat OpenShift Container PlatformRed Hat OpenShift Virtualization

Share:

    In the previous articles in this series, we demonstrated how Red Hat OpenShift Virtualization and Red Hat Developer Hub can increase developer productivity by building virtual machines with a click of a button and showcased the user experience for developers when building a new virtual machine based on the definitions of platform engineering and operations. In this installment, we explore software templates concepts, architecture, and how to use them to build virtual machines (VMs).

    The technology stack 

    Figure 1 depicts the various technologies used in this solution.

    The icons representing the various technologies used in this solution.
    Figure 1: The technology stack used for this solution.

    Red Hat OpenShift is a unified platform to build, modernize, and deploy applications at scale. Work smarter and faster with a complete set of services for bringing apps to market on your choice of infrastructure.

    Red Hat OpenShift GitOps is an operator that uses Argo CD as the declarative GitOps engine. It enables GitOps workflows across multicluster OpenShift and Kubernetes infrastructure. Using Red Hat OpenShift GitOps, administrators can consistently configure and deploy Kubernetes-based infrastructure and applications across clusters and development lifecycles.

    Helm is a package manager for Kubernetes used in this case to build software templates, read from the Developer Hub template parameters and translate it into the Helm values file. 

    GitLab, used for this demo content, is the SCM used to store the software templates and the VM manifest definitions. Developer Hub supports Gitea and GitHub. See supported documentation.

    Software templates overview

    Defining a Kubernetes object based on pipelines, deployments, virtual machines, and etc., software templates allow us to build Kubernetes objects using best practices and scale these to the rest of the organization. It will be defined in a source repository and managed by GitOps to ensure the objects are created in the target cluster. Red Hat Developer Hub will create a backstage component using the software templates with the user’s parameters entered in the creation process (Bringing a self-service experience for Developers to build Virtual Machines (VMs) with Red Hat Developer Hub). The component will be used to build new source code repositories and Kubernetes manifests. 

    Overview of the software templates components

    Software templates are customizable, but you need at least these files to enable Red Hat Developer Hub to read from the software templates. More information: How to create a Software Template from Backstage.

    • Component/catalog-info.yaml: This file will represent the object in Developer Hub,  such as name and links, as shown in Figure 2.

      A view of the catalog-info.yaml file.
      Figure 2:  The source repository showing the catalog-info.yaml file from the software templates definitions.
    • Developer Hub, powered by GitOps, maintains the desired state as the actual state in the cluster for any template definitions, ensuring system stability. See Figure 3.

      A view of some software template definition options.
      Figure 3:  The image shows the source repository showing the manifest content folder from the software templates definitions.
    • GitOps application definitions and necessary secrets to read from the SCM. In this case, the argo-app-dev.yaml is the Argo CD Application pointing to the VM manifest’s folder, as shown in Figure 4.

      A view of the argocd files in the source repository.
      Figure 4:  The source repository showing the argocd files from the software templates definitions.
    • Helm Charts are great for templating. In this case, the VM manifests are implemented using Helm. See Figure 5.

      A view of the helm charts from the software templates definitions in the source repository.
      Figure 5: The source repository showing the helm charts from the software templates definitions.
    • template.yaml file: Defines the UI experience for the end user and the desired steps to get the software templates, create repositories, create GitOps objects, and more. See Figure 6.

      alt text
      Figure 6:  The source repository showing the template.yaml file from the software templates definitions.

    Software templates defining the template.yaml

    template.yaml will define the UI experience for the end user and the desired steps to get the software templates, create repositories, create GitOps objects, and more. 

    Defining the UI

    In this use case, we only allow developers to choose the namespace, cluster, user owner and the virtual machine’s name. See the previous article in this series to review the UI experience. It is up to the operations and platform engineering team to decide how much developers will be able to define when they are building the VMs. Review the Software template file. Figure 7 depicts this workflow.

    A user selecting a software template, entering the required data, and data mapped back into the template.yaml file and then into the values.yaml file as part of the Helm Charts.
    Figure 7:  The interaction from the user with Developer Hub and the software templates.

    The figure shows a user selecting a software template, entering the required data, after which the data is mapped back into the template.yaml file and then into the values.yaml file as part of the Helm Charts.

    Defining the steps for the VM creation

    After the user clicks the Create button, a series of actions will happen that are all part of the VM’s creation process to build a VM using OpenShift Virtualization and Red Hat Developer Hub (Figure 8). These steps are customizable and will be defined on the template.yaml file as part of the Software templates. Review the Software template file.

    A depiction of the steps in the virtual machine creation process.
    Figure 8:  The steps that Developer Hub took to build a VM.

    Step 1: Generating the source code component

    Developer Hub reads from the parameters coming from the UI and software templates definitions:

    action: fetch:template

    Step 2: Publishing to source code repository

    From there, it clones the repo with a new source code representing the VM source code. In this case, we only have one file, the catalog-info.yaml:

    action: publish:gitlab

    Step 3: Registering the source code component

    Using the catalog-info.yaml file, Developer Hub will register this component, making it available in the Developer Hub UI:

    action: catalog:register

    Step 4: Generating the deployment resources and artifacts

    Building the templates using the software templates defined in the manifest folder and reading from the template.yaml file to create the manifests in a new repository representing the values required to build the VM:

    action: fetch:template

    Step 5: Publishing to deployment resource repository

    Publish the templated source code into the GitLab repository:

    action: publish:gitlab

    See Figure 9.

    A view of the source repositories app-legacy-m5 and app-legacy-m5-gitops.
    Figure 9:  The two new source repositories created.

    Step 6: Create Argo CD resources

    Request Argo CD  to create a GitOps application based on the previous source repository published in the last step:

    action: argocd:create-resources

    Using OpenShift GitOps to create a VM

    The OpenShift GitOps controller will ensure that the desired state defined on the project and application are applied into the cluster. The OpenShift Virtualization operator will ensure that the VMs are being created, pods are running, and the VNC Console is accessible. See Figures 10 and 11.

    A depiction of the legacy application GitOps created based on the software templates.
    Figure 10: The argocd UI and the legacy application gitops created based on the software template (application and secret).
    A depiction of the legacy application related objects created based on the software templates.
    Figure 11: The argocd UI and the legacy application related objects created based on the software template (application and secret).

    Building VMs Helm charts

    Below we detail the utility of using Helm Charts in conjunction with virtual machines (VMs).

    Why use Helm?

    As part of your overall GitOps strategy, Helm is a powerful tool that provides agility, security, and consistency across multiple environments.

    Advantages of Helm for IT operations

    • Agility: Help streamline and integrate into GitOps and CI/CD efforts. Helm provides agility with automatic deployment and simple, consistent upgrades.
    • Simplicity: Simplify deployment by making automation generally available to developers for frequently deployed applications.
    • Consistency: Automate manual tasks, significantly reducing deployment time, as well as chances of error during deployment. 

    What is a Helm chart?

    Helm charts are a collection of files that describe a Kubernetes cluster’s resources and package them together as an application. They are comprised of four basic components: 

    • The chart: chart.yaml defines the application metadata like name, version, dependencies, etc. 

    • Values: values.yaml sets values, which is how you will set variable substitutions for reusing your chart. You may also have a values JSON schema that describes a structure for the values file, which can help in creating dynamic forms and validating your values parameters.

    • The templates directory: Templates/houses your templates and combines them with the values set in your values.yaml file to create manifests

    • The charts directory: Charts/stores any chart dependencies you define in chart.yaml and reconstructs with Helm dependency build or Helm dependency update.

    Each time you install a Helm chart, you also create an instance of it, called a release.

    Using VMs from instance types

    You can simplify virtual machine (VM) creation by using instance types, an easy way to define your VM's manifest. You can customize the helm charts as much as you want and use specific configurations to build your VM. Creating virtual machines from instance types. 

    Your Helm chart files can represent all the virtual machine definitions. For this use case, the Helm charts are: 

    • _template/helpers.tpl to hold the variables such as labels, annotations to be used on the manifest files. More information.
    • template/Vm.yaml, kubevirt.io/v1 VirtualMachine object representing the instance of the virtual machine that will be created in OpenShift.
    • chart.yaml
      • Including the Chart’s definition, such as name and version.
    • values.yaml
      • Variables coming from the template.yaml. 

    Exploring the new repository 

    From GitLab, two new repositories were created by Developer Hub according to the software template definition. In this use case, the template.yaml defined two repositories: one for the GitOps files and the other for the VM source code. In this case, only the catalog-info file is needed. In the case of applications, you might have stored the application source as part of this new repository. The content was autogenerated by Developer Hub using the UI parameters and the software template definitions. See Figures 12-14.

    A view of the content of the new gitops project created in GitLab.
    Figure 12: The content of the new gitops project created in GitLab.  
    A view of the content of the new gitops project created in GitLab. within the argocd folder.
    Figure 13: The content from the new gitops folder created in GitLab.  
    A view of the Helm directory containing the VMs Helm definitions needed to build the VM.
    Figure 14: The Helm directory containing the VMs Helm definitions needed to build the VM.  

    Conclusion

    Developers can create many instances from VMs' pre-defined software templates with just a few clicks. Software template customizations will determine how many templates will need to be available for Developers to access the different types of VMs required. Software Templates used in this demo.

    Next

    Read the full series—Part 1: Building virtual machines with Red Hat Developer Hub: The what, why, and how.

    Last updated: September 13, 2024

    Related Posts

    • A developer’s guide to Red Hat Developer Hub and Janus

    • Achieve more with less using Red Hat Developer Hub's self-service features

    • Red Hat Developer Hub: Your gateway to seamless development

    • From code to production with OpenShift Pipelines and Argo CD

    • Building virtual machines with Red Hat Developer Hub: The what, why, and how

    • A self-service approach to building virtual machines at scale

    Recent Posts

    • Alternatives to creating bootc images from scratch

    • How to update OpenStack Services on OpenShift

    • How to integrate vLLM inference into your macOS and iOS apps

    • How Insights events enhance system life cycle management

    • Meet the Red Hat Node.js team at PowerUP 2025

    What’s up next?

    Learn how to install the Red Hat Developer Hub internal developer platform and learn the concepts and skills you need to install your IDP, configure simple GitHub authorization, and explore templating basics.

    Start the activity
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue