Manage the resources for your Space by using the Tanzu CLI

You can use the Tanzu CLI to declaratively manage the resources for your Spaces, including configurations, cluster groups, and applications.

Before you begin

Before you manage the resources for your Spaces:

  1. Get the Project UUID for the Project in which you want to manage the application Space resources by running:

    tanzu project list -w
    
  2. Set the context to your Project by running:

    tanzu project use
    

Manage resources in a GitOps Project

To manage resources in a GitOps Project:

  1. In the root directory, create a tanzu.yml file that has content similar to the following:

    apiVersion: config.tanzu.vmware.com/v1
    kind: TanzuConfig
    configuration:
      projectRoot:
        uuid: #<UUID of the Project>
    
  2. In the YAML file, for configuration.projectRoot.uuid enter the UUID of the Project in which you want to manage the application Space resources.

Create files for resources

In the root directory create files for your resources, including Availability Targets, cluster groups, and Spaces:

  1. Create a directory called clustergroups.

  2. In the clustergroups directory, add a directory for each cluster group.

  3. In each cluster-group directory, add the the resources that you want to create in the cluster group.

  4. Create a directory called spaces.

  5. In the spaces directory, add a directory for each Space that you want to create.

  6. In each Space directory, add the resources you want to deploy to the Space. Your Project structure now looks similar to this:

    .
    ├── clustergroups
    │   └── dev-cg
    │       └── package-installs.yaml
    ├── spaces
    │   └── dev-1
    │       └── wfd-ui
    │           ├── cm.yaml
    │           ├── package-install.yaml
    │           └── package.yaml
    ├── app-profile.yaml
    ├── availability-target.yaml
    ├── space-dev-1.yaml
    ├── tanzu.yml
    └── workload-trait.yaml
    
  7. Create the resources in the cluster groups and Spaces defined in the directory structure by running:

    tanzu deploy
    

    The resources are created in the Project you configured in the tanzu.yml file.

  8. Enter Y at each command prompt.

You can also run tanzu deploy from a specific cluster-group or Space subdirectory. If you run the tanzu deploy command in a subdirectory, only the files defined in that cluster group or Space are created or updated.

Apply one-off resources

Run the tanzu deploy command with the --only flag to create one-off resources from specific files that are not managed as part of your GitOps repository.

The following example shows how you can create a Space in your Project by running tanzu deploy.

  1. If you have not already set your Project context, set the Project context to your Project by running:

    tanzu project use
    
  2. Create a space.yaml manifest file for the Space with content similar to the following:

    apiVersion: spaces.tanzu.vmware.com/v1alpha1
    kind: Space
    metadata:
      name: my-first-space
    spec:
      template:
        spec:
          profiles:
          - name: spring-dev.tanzu.vmware.com
          - name: my-custom-networking
          resources:
            limits:
              cpu: 5000m
              memory: 10Gi
      availabilityTargets:
      - name: all-regions.tanzu.vmware.com
        replicas: 1
      updateStrategy:
        type: RollingUpdate
    
  3. Apply the manifest to create the Space in your Project by running:

    tanzu deploy --only space.yaml
    
  4. Enter Y at the command prompt.

  5. Verify that the Space was created in your Project by running:

    tanzu space get <my-first-space>
    

    The Space status is ready: True in the Overview section.

check-circle-line exclamation-circle-line close-line
Scroll to top icon