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.
To manage resources in a GitOps Project:
Set the Tanzu CLI context to your Project.
tanzu project use PROJECT-NAME
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
In the root directory create files for your Project resources, including Availability Targets, cluster groups, and Spaces.
In the clustergroups
directory, add a directory for each cluster group.
In each cluster group directory, add the resources that you want to create in the cluster group.
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 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
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.
NoteYou can also run
tanzu deploy
from within a specific cluster group or Space subdirectory. If you run thetanzu 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.
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.
tanzu project use PROJECT-NAME
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.