This is a cache of https://docs.okd.io/4.10/virt/vm_templates/virt-deploying-vm-template-to-custom-namespace.html. It is a snapshot of the page at 2024-12-01T23:08:39.403+0000.
Deploying a virtual machine <strong>template</strong> to a custom namespace - Virtual machine <strong>template</strong>s | Virtualization | OKD 4.10
×

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 on the Virtualizationtemplates 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 OKD 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