After you create the content library and populate it with VM templates, use the vSphere Client to add the library to the namespace. By adding the library to the namespace, you give your DevOps users access to the library. In addition, you can use the Data Center CLI (DCLI) commands to add a writable or read-only content library to the namespace, or assign a read-only library at a cluster level.

Add a VM Content Library to a Namespace Using the vSphere Client

The content library that you add with the vSphere Client is read-only. The DevOps users can access images from this content library, but cannot publish VM images to this library.

You can add multiple content libraries to a single namespace. You can add the same content library to different namespaces.
Note: This procedure applies only to content libraries for VM Service. A content library for Tanzu Kubernetes Grid must be managed from the Tanzu Kubernetes Grid card.

Prerequisites

Required privileges:
  • Namespaces.Modify cluster-wide configuration
  • Namespaces.Modify namespace configuration

Procedure

  1. In the vSphere Client, go to the namespace.
    1. From the vSphere Client home menu, select Workload Management.
    2. Click the Namespaces tab and click the namespace.
  2. Add a content library.
    1. On the VM Service card, click Add Content Library.
    2. Select one or several content libraries and click OK.

Manage VM Content Libraries on a Namespace Using the vSphere Client

After you associate the library with the namespace, you can use the vSphere Client to remove it from the namespace. You can also add more libraries.

Removing a content library from a namespace does not affect VMs that were previously deployed with the library images.
Note: This procedure applies only to content libraries for VM Service. Tanzu Kubernetes Grid content libraries must be managed from the Tanzu Kubernetes Grid card.

Prerequisites

Required privileges:
  • Namespaces.Modify cluster-wide configuration
  • Namespaces.Modify namespace configuration

Procedure

  1. In the vSphere Client, go to the namespace.
    1. From the vSphere Client home menu, select Workload Management.
    2. Click the Namespaces tab and click the namespace.
  2. Add or remove a content library.
    1. On the VM Service card, click Manage Content Library.
    2. Perform one of the following operations.
      Option Description
      Remove a content library Deselect the content library and click OK.
      Add a content library Select one or several content libraries and click OK.

What to do next

OVF templates from the library become available in the Kubernetes namespace as VM images and can be used by DevOps to self-service VMs. See Deploy a Virtual Machine in vSphere IaaS Control Plane.
Note: Only OVF templates from the library show up in the namespaces. Other types of content do not show up in the namespace.

Add a VM Content Library to a Namespace Using Data Center CLI

As a vSphere administrator, you can use the Data Center CLI (DCLI) command to assign the content library to a namespace. When assigning the library, you can make the library associated with the namespace writable. When the library is writable, in addition to viewing the library and the images in the library, DevOps users can publish new VM images to it.

With the DCLI commands, you can add any type of the library, including local, published, and subscribed, to the namespace. However, only local and published can be linked as writable libraries.​ Content libraries and library items are available only in the associated namespace​.

Procedure

  1. Log in to vCenter Server using the root user account.
  2. Type dcli +i to use the DCLI in interactive mode.
  3. Obtain the ID of the content library to be associated with the namespace.
    dcli > namespacemanagement content library list
  4. Run the following command to associate the content library with the namespace.
    The update operation is not incremental. Only libraries specified in the list will be associated with the namespace and the libraries that were added previously will be removed, unless their IDs are specified. For example, if you update '[{"content_library": "CLA", "writable": "true"}]' and then later update '[{"content_library": "CLB", "writable": "true"}]', CLA will be removed and only CLB will be added. If you want both CLA and CLB to be associated, you have to specify both libraries: '[{"content_library": "CLA", "writable": "true"}, {"content_library": "CLB", "writable": "true"}]'.
    dcli > namespaces instances update --namespace namespace_name --content-libraries '[{"content_library": "content_library_ID", "writable": "true | false"}]' 
    Use the following arguments:
    • --namespace namespace_name – Name of the namespace.
    • --content_libraries content_library_ID writable: true | false – ID of the content library to be associated with the namespace and whether the library is writable or not.
    For example,
    dcli > namespaces instances update --namespace lb-edit-ns --content-libraries '[{"content_library": "cl-b585915ddxxxxxxxx", "writable": "true"}]' 
  5. To delete the content library from the namespace, repeat the namespaces instances update command removing the content library entry from the array list.
    For example,
    dcli > namespaces instances update --namespace lb-edit-ns --content-libraries '[]'

Results

The added content library becomes available in the DevOps namespace view.
The DevOps user can run the following commands to verify that the content library has been added or deleted.
kubectl get cl -n lb-edit-ns
   NAMESPACE    NAME                   VSPHERENAME   TYPE    WRITABLE   STORAGETYPE   AGE
   lb-edit-ns   cl-b585915ddxxxxxxxx   Test-ns-cl    Local   true       Datastore     3m9s
kubectl describe cl cl-b585915ddxxxxxxxx -n lb-edit-ns
kubectl get clitem -n lb-edit-ns

Add a VM Content Library to Supervisor Using Data Center CLI

In addition to assigning the content library at a namespace level, the vSphere administrator can use the Data Center CLI (DCLI) command to associate the library with a Supervisor cluster. The content library becomes available to all namespaces in the Supervisor.

You can associate all types of libraries, including local, published, and subscribed.​

Note: The content library associated with the Supervisor is read-only. The DevOps users can only access VM images from this content library, but cannot publish VM images to this library.

Prerequisites

For more information about the DCLI commands, see VMware Data Center CLI.

Procedure

  1. Log in to vCenter Server using the root user account.
  2. Type dcli +i to use the DCLI in interactive mode.
  3. Obtain the name of the Supervisor and the ID of the content library to connect to the Supervisor.
    1. Get the name of the Supervisor from the list of clusters.
      The command lists all clusters available on vCenter Server.
      dcli > namespacemanagement clusters list
    2. List IDs of all content libraries of any type available on vCenter Server.
      dcli > library list
    3. Verify details for the specific library.
      dcli > library get --library-id content_library_ID
  4. Associate one or more content libraries with the Supervisor.
    The update operation is not incremental. Only libraries specified in the list will be associated with the namespace and the libraries that were added previously will be removed, unless their IDs are specified. For example, if you update '[{"content_library": "CLA", "writable": "true"}]' and then later update '[{"content_library": "CLB", "writable": "true"}]', CLA will be removed and only CLB will be added. If you want both CLA and CLB to be associated, you have to specify both libraries: '[{"content_library": "CLA", "writable": "true"}, {"content_library": "CLB", "writable": "true"}]'.
    dcli > namespacemanagement clusters update --cluster cluster_name --content-libraries '[{"content_library": content_library_ID_1}, {"content-library": content_library_ID_2}]'
    Use the following arguments:
    • --cluster cluster_name – Identifier for the Supervisor cluster.
    • --content-libraries content_library_ID – An ID of a content library to be associated with the Supervisor. You can list several IDs.
      For example,
      dcli > namespacemanagement clusters update --cluster cluster_name --content-libraries '[{"content_library": 535d4b3d-xxxx-xxxx-xxxx-xxxxxxxxxxxx}, {"content-library": b5aa7f68-xxxx-xxxx-xxxx-xxxxxxxxxxxx}]'
  5. Verity that the content libraries are connected to the cluster.
    dcli > namespacemanagement clusters get --cluster cluster_name
    The output must include the IDs of the connected content libraries.
  6. To delete the associated content library from the cluster, repeat the namespacemanagement clusters update command removing the content library entry from the content library array list.
    For example,
    dcli > namespacemanagement clusters update --cluster cluster_name --content-libraries '[]'

Results

The newly added content libraries become available in the DevOps cluster view. Any changes that the vSphere administrator makes to the content libraries are reflected in the DevOps view. The DevOps user can run the following commands to list the content libraries and describe their contents:
  • kubectl get ccl – List of all content libraries available at the cluster level. The output can look similar to the following.
    NAME                   VSPHERENAME                          TYPE         STORAGETYPE   AGE
    cl-f28af8153fb849bd7   Kubernetes Service Content Library   Subscribed   Datastore     6d5h
    cl-knounwp7xxxxxxxxx   Image Registry Content Library       Local        Datastore     6d4h
  • kubectl get cclitem – List of all items in the content libraries at the cluster level.
  • kubectl describe ccl NAME – Detailed information for a specific content library at the cluster level.