×

Red Hat provides preconfigured virtual machine templates that are installed in the openshift namespace. The ssp-operator deploys virtual machine templates to the openshift namespace by default. Templates in the openshift namespace are publicly available to all users. These templates are listed in the Templates tab within the Virtualization page for different operating systems.

Creating a custom namespace for templates

You can create a custom namespace that is used to deploy virtual machine templates for use by anyone who has permissions to access those templates. To add templates to a custom namespace, edit the HyperConverged custom resource (CR), add commonTemplatesNamespace to the spec, and specify the custom namespace for the virtual machine templates. After the HyperConverged CR is modified, the ssp-operator populates the templates in the custom namespace.

Prerequisites
  • Install the OpenShift Container Platform CLI oc.

  • Log in as a user with cluster-admin privileges.

Procedure
  • Use the following command to create your custom namespace:

    $ oc create namespace <mycustomnamespace>

Adding templates to a custom namespace

The ssp-operator deploys virtual machine templates to the openshift namespace by default. Templates in the openshift namespace are publicly availably to all users. When a custom namespace is created and templates are added to that namespace, you can modify or delete virtual machine templates in the openshift namespace. To add templates to a custom namespace, edit the HyperConverged custom resource (CR) which contains the ssp-operator.

Procedure
  1. View the list of virtual machine templates that are available in the openshift namespace.

    $ oc get templates -n openshift
  2. Edit the HyperConverged CR in your default editor by running the following command:

    $ oc edit hco -n openshift-cnv kubevirt-hyperconverged
  3. View the list of virtual machine templates that are available in the custom namespace.

    $ oc get templates -n customnamespace
  4. Add the commonTemplatesNamespace attribute and specify the custom namespace. Example:

    apiVersion: hco.kubevirt.io/v1beta1
    kind: HyperConverged
    metadata:
      name: kubevirt-hyperconverged
    spec:
      commonTemplatesNamespace: customnamespace (1)
    1 The custom namespace for deploying templates.
  5. Save your changes and exit the editor. The ssp-operator adds virtual machine templates that exist in the default openshift namespace to the custom namespace.

Deleting templates from a custom namespace

To delete virtual machine templates from a custom namespace, remove the commonTemplateNamespace attribute from the HyperConverged custom resource (CR) and delete each template from that custom namespace.

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

    $ oc edit hco -n openshift-cnv kubevirt-hyperconverged
  2. Remove the commonTemplateNamespace attribute.

    apiVersion: hco.kubevirt.io/v1beta1
    kind: HyperConverged
    metadata:
      name: kubevirt-hyperconverged
    spec:
      commonTemplatesNamespace: customnamespace (1)
    1 The commonTemplatesNamespace attribute to be deleted.
  3. Delete a specific template from the custom namespace that was removed.

    $ oc delete templates -n customnamespace <template_name>
Verification
  • Verify that the template was deleted from the custom namespace.

    $ oc get templates -n customnamespace

Additional resources