You can use the Tanzu CLI to declaratively manage the resources for your Kubernetes Spaces, including configurations, cluster groups, and applications.
Manage resources in a GitOps Project
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
Create files for resources
In the root directory you can create files for your Project resources, including Availability Targets and Spaces.
To create files for your Project resources:
-
Follow the steps in Create a cluster group for run environments.
-
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 now has a structure similar 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 --nested-contexts
Enter
Y
at each command prompt. The resources are created in the Project you configured in thetanzu.yml
file.
You 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.
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
.
-
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.
Content feedback and comments