Tanzu Platform 10.0

Promote built artifacts to and between Spaces in a GitOps workflow

Last Updated March 03, 2025

This topic tells you how to manage resources in a GitOps project to promote artifacts between Kubernetes Spaces in Tanzu Platform.

In these examples the GitOps project at ~/gitops-project has this structure:

.
├── spaces
│   └── space-dev
│   └── space-prod
└── tanzu.yml

For more information about the directory structure, see Manage the resources for your Space by using the Tanzu CLI.

Promote built artifacts to a Space

To promote built artifacts to a Space:

  1. With your current directory as the root of your source code, generate the artifacts you want to promote by running:

    tanzu build --output-dir DIR-PATH
    
  2. Promote the built artifacts to a GitOps-managed Space by running:

    tanzu promote --from-build DIR-PATH --to ~/gitops-project/spaces/space-dev
    

    You can deploy these resources as a part of the GitOps project.

Promote resources from one Space to another

Promote resources from space-dev to space-prod by running the following commands:

cd ~/gitops-project/spaces/space-dev
tanzu promote --to ../space-prod

You can deploy these resources as a part of the GitOps project.

By running the tanzu promote command you can detect fields that might not be shared between environments. For example, if a ContainerApp in space-prod is configured to have eight replicas even though it has only three replicas in space-dev, the ContainerApp continues to have eight replicas in space-prod when subsequent builds are promoted.

For more information, see ContainerApp API reference.

Promote only some resources from one Space to another

You can promote only resources that are associated with a specific ContainerApp. For example, to promote only resources associated with the ContainerApp where-for-dinner-ui from space-dev to space-prod run the following commands:

cd ~/gitops-project/spaces/space-dev
tanzu promote --to ../space-prod --filter ContainerApp/where-for-dinner-ui

To promote multiple applications, run:

tanzu promote --to ../space-prod --filter ContainerApp/where-for-dinner-crawler,ContainerApp/where-for-dinner-availability

Promote resources and copy built artifacts to a registry

You can copy built artifacts to another registry while promoting resources from one Space to another or while promoting built artifacts to a Space. The example in this section shows how to copy build artifacts to a registry while promoting built artifacts from the staging Space to the staging-scanning Space.

  1. Use one of the following methods to authenticate with the registry or registries:

    • In your terminal, use docker login to log in to the registry.
    • Or, set the following environment variables:

      • IMGPKG_REGISTRY_HOSTNAME
      • IMGPKG_REGISTRY_USERNAME
      • IMGPKG_REGISTRY_PASSWORD
      • IMGPKG_REGISTRY_IDENTITY_TOKEN
      • IMGPKG_REGISTRY_REGISTRY_TOKEN

    To authenticate with multiple registries, set the environment variables as follows:

    • IMGPKG_REGISTRY_HOSTNAME_0
    • IMGPKG_REGISTRY_USERNAME_0
    • IMGPKG_REGISTRY_PASSWORD_0
    • IMGPKG_REGISTRY_HOSTNAME_1
    • IMGPKG_REGISTRY_USERNAME_1
    • IMGPKG_REGISTRY_PASSWORD_1
  2. Navigate to the Space from which to promote the build:

    cd ~/gitops-project/spaces/staging
    
  3. Run tanzu promote with the --registry option to copy the build artifacts to the registry during the promote operation.

    tanzu promote --to ../staging-scanning --registry registry.somecorp.com/project/application
    

    Similarly, relocating built artifacts to a Space from build output would look like:

    tanzu promote --from-build ~/build-output --to ~/gitops-project/spaces/space-dev --registry registry.somecorp.com/project/application