As a DevOps user, you can create a Supervisor Namespace and create infrastructure resources within the namespace using CCI kubectl commands. These examples show how to create a Supervisor Namespace and add a VM to the namespace.

Prerequisites

  • Verify that a Automation administrator has set up the Cloud Consumption Interface infrastructure. See Setting up the CCI infrastructure using kubectl.
  • Verify that you are member of at least one project in Automation Service Broker.
  • Verify that you are at least an organization member in Automation with the Automation Service Broker User service role.
  • Verify that you have:
    • Downloaded the CCI kubectl plug-in.
    • Obtained an API token for the User service role and assigned it as a variable.
      TOKEN='<your_API_token>'
    • Used your token to log in to the CCI server.
    See Preparing to use the Command Line Interface to perform CCI tasks.

Create a Supervisor Namespace

This example shows how to create a Supervisor Namespace named ns-for-devops-example.

Using kubectl commands, you collect information for the following resources:
  • Project
  • Region Binding
  • Supervisor Namespace Class Binding
Then you add the metadata and specifications to a YAML file to create the Supervisor Namespace.
  1. Set the default context to CCI.
    kubectl config use-context cci
  2. List available projects.
    kubectl get projects
    The result lists the projects that you are in.
    NAME          SHARED RESOURCES
    cci-document   true
  3. List the regions in cci-document.
    kubectl get regionbinding -n cci-document
    The result shows all the regions in the project.
    NAME        AGE
    us-docs-1   2d13h
  4. List the supervisor namespace classes in cci-document.
    kubectl get supervisornamespaceclassbinding -n cci-document
    The result shows all the supervisor namespace classes in the project.
    NAME         AGE
    docs-class   2d13h
  5. Create a YAML file for the Supervisor Namespace that you want to create. The following example creates a namespace with:
    • cci-document for the project.
    • us-docs-1 for the region.
    • docs-class for the namespace class.
    apiVersion: infrastructure.cci.vmware.com/v1alpha1
    kind: SupervisorNamespace
    metadata:
      name: ns-for-devops-example
      namespace: cci-document
    spec:
      description: Create_Namespace_example
      regionName: us-docs-1
      className: docs-class
  6. With the YAML file as input, create a supervisor namespace. In this example, the YAML file is in the same directory as the kubectl application.
    kubectl create -f Create_Supervisor_Namespace.YAML
  7. Check the status of the supervisor namespace in cci-document.
    kubectl describe supervisornamespace ns-for-devops-example -n cci-document
    When the result shows Status: True and Type: Ready, the supervisor namespace is ready to use and appears in the UI:
    • For Automation Service Broker, go to Consume > Supervisor Namespace.
    • For Automation Assembler, go to Infrastructure > Resources > Supervisors.
    Name:         ns-for-devops-example
    Namespace:    cci-document
    Labels:       <none>
    Annotations:  infrastructure.cci.vmware.com/wcp-address: 192.168.0.2
    API Version:  infrastructure.cci.vmware.com/v1alpha1
    Kind:         SupervisorNamespace
    Metadata:
      Creation Timestamp:  2023-07-31T17:30:49Z
      UID:                 b2f65844-d545-4a5f-976d-381e079275b1
    Spec:
      Class Name:  docs-class
      Class Parameters:
      Description:  Create_Namespace_example
      Region Name:  us-docs-1
    Status:
      Conditions:
        Last Transition Time:  2023-07-31T17:30:50Z
        Status:                True
        Type:                  Ready
      Phase:                   Created
    Events:                    <none>
  8. If you want to delete the supervisor namespace, provide the name of the namespace, the name of the project, and include the --force flag.
    kubectl delete supervisornamespace ns-for-devops-example -n cci-document --force

Add a VM to the Supervisor Namespace

This example shows how to create a VM named VM-for-devops-example.

Using kubectl commands, you collect information for the following resources:
  • Virtual Machine Class
  • Virtual Machine Image
  • Storage Class
Then you add resource specifications to a YAML file to create the VM.
  1. Log in to the CCI server again and verify that you see the newly created Supervisor Namespace in the response.
    kubectl cci login --server api.mgmt.cloud.vmware.com --token $TOKEN
    Logging into api.mgmt.cloud.vmware.com
    Getting supervisor namespaces
    Successfully logged into api.mgmt.cloud.vmware.com
    Created kubeconfig contexts:
             cci
             cci:cci-document:ns-7lan
             cci:cci-document:ns-for-devops-example
             cci:supervisor:gp-namespace
  2. Set the default context so that you do not need to specify the namespace with context in every command.
    kubectl config use-context cci:cci-document:ns-for-devops-example
    The result confirms that the context has been switched and every subsequent command will be in the context of cci:cci-document:ns-for-devops-example.
    Switched to context "cci:cci-document:ns-for-devops-example".
  3. List available virtual machine classes.
    kubectl get virtualmachineclassess
    Select one of the virtual machine classes from the result.
    NAME                  CPU   MEMORY   AGE
    best-effort-2xlarge   8     64Gi     2d15h
    best-effort-4xlarge   16    128Gi    2d15h
    best-effort-8xlarge   32    128Gi    2d15h
    best-effort-large     4     16Gi     2d15h
    best-effort-medium    2     8Gi      2d15h
    best-effort-small     2     4Gi      2d15h
    best-effort-xlarge    4     32Gi     2d15h
    best-effort-xsmall    2     2Gi      2d15h
    guaranteed-2xlarge    8     64Gi     2d15h
    guaranteed-4xlarge    16    128Gi    2d15h
    guaranteed-8xlarge    32    128Gi    2d15h
    guaranteed-large      4     16Gi     2d15h
    guaranteed-medium     2     8Gi      2d15h
    guaranteed-small      2     4Gi      2d15h
    guaranteed-xlarge     4     32Gi     2d15h
    guaranteed-xsmall     2     2Gi      2d15h
  4. List available virtual machine images.
    kubectl get virtualmachineimages
    Select the image that you want to use.
    NAME                    PROVIDER-NAME              CONTENT-LIBRARY-NAME   IMAGE-NAME                                              VERSION         OS-TYPE                 FORMAT   AGE
    vmi-02549e2ab956621e9   clitem-02549e2ab956621e9   cl-c7a511c539dddc1f1   groovy-20210415.1-with-ovt-11.3                                         ubuntu64Guest           OVF      143m
    vmi-041ff2740d6aee34a   clitem-041ff2740d6aee34a   cl-c7a511c539dddc1f1   ubuntu-20-1633387172196-v1.1                                            ubuntu64Guest           OVF      143m
    vmi-1cc3c618d0ead1129   clitem-1cc3c618d0ead1129   cl-c7a511c539dddc1f1   jammy-server-cloudimg-amd64                                             ubuntu64Guest           OVF      143m
    
  5. To list available storage policies, use the command to get resource quotas.
    kubectl get resourcequota
    The first section of the request is the storage policy.
    NAME                                 AGE     REQUEST                                                                                         LIMIT
    ns-for-devops-example-storagequota   6m22s   wcpglobal-storage-profile.storageclass.storage.k8s.io/requests.storage: 0/9223372036854775807
    
  6. Create a YAML file for the VM that you want to add to the Supervisor Namespace. The following example creates a VM with:
    • ns-for-devops-example for the namespace.
    • vmi-02549e2ab956621e9 for the VM image.
    • guaranteed-small for the VM class.
    • wcpglobal-storage-profile for the storage policy.
    apiVersion: vmoperator.vmware.com/v1alpha1
    kind: VirtualMachine
    metadata:
      name: VM-for-devops-example
      namespace: ns-for-devops-example
    spec:
      imageName: vmi-02549e2ab956621e9
      className: guaranteed-small  
      storageClass: wcpglobal-storage-profile  
      powerState: poweredOn
  7. With the YAML file as input, create a VM in the supervisor namespace. In this example, the YAML file is in the same directory as the kubectl application.
    kubectl create -f Create_VM.YAML
  8. Check the status of the VM creation in ns-for-devops-example.
    kubectl describe virtualmachine vm-for-devops-example -n ns-for-devops-example
    When the result shows three Status: True for Type: GuestCustomization, Type: VirtualMachinePrereqReady, and Type: VirtualMachineTools , the VM has been successfully created in the supervisor namespace.
    Name:         vm-for-devops-example
    Namespace:    ns-for-devops-example
    Labels:       topology.kubernetes.io/zone=domain-c50
    Annotations:  virtualmachine.vmoperator.vmware.com/first-boot-done: true
    API Version:  vmoperator.vmware.com/v1alpha1
    Kind:         VirtualMachine
    Metadata:
      Creation Timestamp:  2023-08-15T00:30:55Z
      Finalizers:
        virtualmachine.vmoperator.vmware.com
      Generation:        1
      Resource Version:  19196052
      UID:               f2460f3c-225b-460b-8d11-95a1bdaebe72
    Spec:
      Class Name:  guaranteed-small
      Image Name:  vmi-02549e2ab956621e9
      Network Interfaces:
        Network Type:  vsphere-distributed
      Power Off Mode:  hard
      Power State:     poweredOn
      Restart Mode:    hard
      Storage Class:   wcpglobal-storage-profile
      Suspend Mode:    hard
    Status:
      Bios UUID:              421eb2b5-04ef-f3e1-8d17-f8e73a2576b2
      Change Block Tracking:  false
      Conditions:
        Last Transition Time:  2023-08-15T00:32:30Z
        Status:                True
        Type:                  GuestCustomization
        Last Transition Time:  2023-08-15T00:31:55Z
        Status:                True
        Type:                  VirtualMachinePrereqReady
        Last Transition Time:  2023-08-15T00:32:20Z
        Status:                True
        Type:                  VirtualMachineTools
      Host:                    10.186.234.28
      Instance UUID:           501ea6c0-c0cb-b03c-08e6-324642f923d1
      Network Interfaces:
        Connected:  true
        Ip Addresses:
          192.168.128.11/16
          fe80::250:56ff:fe9e:ff48/64
        Mac Address:  00:50:56:9e:ff:48
      Phase:          Created
      Power State:    poweredOn
      Unique ID:      vm-104
      Vm Ip:          192.168.128.11
      Zone:           domain-c50
    Events:           <none>
  9. If you want to delete the VM, provide the name of the VM, the name of the namespace, and include the --force flag.
    kubectl delete virtualmachine vm-for-devops-example -n ns-for-devops-example --force