tanzu context

System commands | Primarily used for: Tanzu CLI

Important: This functionality is in development. As of Tanzu Kubernetes Grid v2.1, you can target only the k8s context type.

The tanzu context manages Tanzu CLI contexts. This command group includes the following commands:

Usage

tanzu context [COMMAND]

Aliases

context, ctx, and contexts

Global Flags

-h, --help

Help text.

tanzu context create

Creates a Tanzu CLI context.

Usage

tanzu context create [FLAGS]

Examples

To create a management cluster context, for example, my-management-cluster using an endpoint:

tanzu context create --endpoint "https://example.com" --name my-management-cluster

To create a management cluster context using a kubeconfig path and context:

tanzu context create --kubeconfig PATH-TO-KUBECONFIG --kubecontext KUBECONFIG-CONTEXT --name my-management-cluster

Note: The command in the example above replaces tanzu login --kubeconfig PATH-TO-KUBECONFIG --context KUBECONFIG-CONTEXT --name SERVER-NAME.

To create a management cluster context using the default kubeconfig path and a kubeconfig context:

tanzu context create --kubecontext KUBECONFIG-CONTEXT --name my-management-cluster

Flags

--endpoint

The endpoint that you are creating the context for.

-h, --help

Help text.

--kubeconfig

The path to the kubeconfig file of the cluster. If only the --kubecontext flag is set, tanzu context create reads the KUBECONFIG environment variable. If the KUBECONFIG environment variable is not set, the default kubeconfig path, $HOME/.kube/config, is used.

--kubecontext

The context in the kubeconfig file to use.

--name

A name for the context that are creating.

tanzu context delete

Deletes a context from the Tanzu CLI.

Note: This command replaces tanzu config server delete.

Usage

tanzu context delete CONTEXT-NAME [FLAGS]

Example

To delete a context named my-management-cluster:

tanzu context delete my-management-cluster

Flags

-h, --help

Help text.

-y, --yes

When specified, tanzu context delete skips the confirmation step.

tanzu context get

Displays the specified context.

Usage

tanzu context get CONTEXT-NAME [FLAGS]

Example

To get a context named my-management-cluster:

tanzu context get my-management-cluster

Flags

-h, --help

Help text.

-o, --output

Output format. Supported values are yaml and json. Default is yaml.

tanzu context list

Lists Tanzu CLI contexts.

Note: This command replaces tanzu config server list.

Usage

tanzu context list [FLAGS]

Example

To list all Tanzu CLI contexts:

tanzu context list

Flags

--current

When specified, the command lists only current active contexts.

-h, --help

Help text.

-o, --output

Output format. Supported values are yaml, json, and table. Default is table.

-t, --target

Context type. Supported value is k8s; tmc context is in development.

tanzu context use

Sets the current context for the Tanzu CLI.

Note: This command replaces tanzu login --server SERVER-NAME.

Usage

tanzu context use CONTEXT-NAME [FLAGS]

Example

To set the current context to my-management-cluster:

tanzu context use my-management-cluster

Flags

-h, --help

Help text.

check-circle-line exclamation-circle-line close-line
Scroll to top icon