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 on Tanzu Platform for Kubernetes.

Manage resources in a GitOps Project

To manage resources in a GitOps Project:

  1. Set the Tanzu CLI context to your Project.

    tanzu project use PROJECT-NAME
    
  2. Set up GitOps in your Project by entering the root directory and then running:

    tanzu gitops init
    

    This command creates a file called tanzu.yml, which has content similar to the following:

    apiVersion: config.tanzu.vmware.com/v1
    kind: TanzuConfig
    configuration:
      id: config-generated-uuid
      projectRoot:
        uuid: #<UUID of the Project>
    

    The command also creates the following directory structure:

    .
    ├── clustergroups
    ├── spaces
    └── tanzu.yml
    

Create files for resources

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

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

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

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

  4. In each Space directory, add the resources you want to deploy to the Space.

    Your Project directory should have a structure that resembles the following:

    .
    ├── 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
    
  5. Create the resources in the cluster groups and Spaces defined in the directory structure by running:

    tanzu deploy
    

    Enter Y at each command prompt. The resources are created in the Project you configured in the tanzu.yml file.

Note

You can also run tanzu deploy from within 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.

The cluster groups and the Spaces directory must only have subdirectories named after cluster groups and Spaces. The tanzu deploy command causes an error otherwise.

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.

    tanzu project use PROJECT-NAME
    
  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