You can use the Tanzu CLI to declaratively manage the resources for your Spaces, including configurations, cluster groups, and applications.
Before you manage the resources for your Spaces:
Get the Project UUID for the Project in which you want to manage the application Space resources by running:
tanzu project list -w
Set the context to your Project by running:
tanzu project use
To manage resources in a GitOps Project:
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>
In the YAML file, for configuration.projectRoot.uuid
enter the UUID of the Project in which you want to manage the application Space resources.
In the root directory create files for your resources, including Availability Targets, cluster groups, and Spaces:
Create a directory called clustergroups
.
In the clustergroups
directory, add a directory for each cluster group.
In each cluster-group directory, add the the resources that you want to create in the cluster group.
Create a directory called spaces
.
In the spaces
directory, add a directory for each Space that you want to create.
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
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.
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.
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
.
If you have not already set your Project context, set the Project context to your Project by running:
tanzu project use
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
Apply the manifest to create the Space in your Project by running:
tanzu deploy --only space.yaml
Enter Y
at the command prompt.
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.