Manages Tanzu CLI contexts. A Tanzu CLI context is a combination of a user identity and a server identity. Each context is associated with a context type: kubernetes
or k8s
, mission-control
or tmc
, tanzu
, and application-engine
.
For commands from the Tanzu CLI context
plugin with target mission-control
, see context in the Tanzu Mission Control Plug-ins documentations
System commands: context
| Primarily used for: Tanzu CLI
Syntax:
tanzu context [COMMAND]
context
, ctx
, and contexts
create Create a Tanzu CLI context
current Display the current context
delete Delete a context from the config
get Display a context from the config
list List contexts
unset Unset the active context so that it is not used by default
use Set the context to be used by default
-h, --help
Help text.
Creates a Tanzu CLI context.
tanzu context create CONTEXT-NAME [FLAGS]
To create a Tanzu Kubernetes Grid (TKG) management cluster context, for example, my-management-cluster
, using an endpoint:
tanzu context create my-management-cluster --endpoint "https://example.com" --endpoint-ca-certificate PATH-TO-CA-CERTIFICATE
To create a TKG management cluster context using a kubeconfig
path and context:
tanzu context create my-management-cluster --kubeconfig PATH-TO-KUBECONFIG --kubecontext KUBECONFIG-CONTEXT
Note: The command in the example above replaces tanzu login --kubeconfig PATH-TO-KUBECONFIG --context KUBECONFIG-CONTEXT --name SERVER-NAME
.
To create a TKG management cluster context using the default kubeconfig
path and a kubeconfig
context:
tanzu context create my-management-cluster --kubecontext KUBECONFIG-CONTEXT
--endpoint
The endpoint that you are creating the context for.
--endpoint-ca-certificate
The path to the endpoint CA bundle for TLS verification.
-h, --help
Help text.
--insecure-skip-tls-verify
Skip TLS certificate verification when creating a context using --endpoint
.
--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. You can set multiple file paths in the KUBECONFIG
environment variable, for example, export KUBECONFIG=~/temp/mc-kubeconfig:~/temp/my-admin-kubeconfig
. 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.
-t, --type
Context type. Supported values are kubernetes
or k8s
, mission-control
or tmc
, tanzu
, and application-engine
.
Displays the current context.
tanzu context current
--short
Prints the context in compact form. See the Tanzu CLI Quick Start Guide for how to use this option to show your current context in your shell prompt.
Deletes a context from the Tanzu CLI. It also:
kubeconfig
context associated with the CLI context, when applicable.Note: This command replaces tanzu config server delete
.
tanzu context delete CONTEXT-NAME [FLAGS]
To delete a context named my-management-cluster
:
tanzu context delete my-management-cluster
-h, --help
Help text.
-y, --yes
When specified, tanzu context delete
skips the confirmation step.
Displays the specified context.
tanzu context get CONTEXT-NAME [FLAGS]
To get a context named my-management-cluster
:
tanzu context get my-management-cluster
-h, --help
Help text.
-o, --output
Output format. Supported values are yaml
and json
. Default is yaml
.
Lists Tanzu CLI contexts.
Note: This command replaces tanzu config server list
.
tanzu context list [FLAGS]
To list all Tanzu CLI contexts:
tanzu context list
--current
When specified, the command lists only active contexts.
-h, --help
Help text.
-o, --output
Output format. Supported values are yaml
, json
, and table
. Default is table
.
-t, --type
Context type. When this flag is set, the command lists contexts only for the specified context type. Supported values are kubernetes
or k8s
, mission-control
or tmc
, tanzu
, and application-engine
.
Unsets the specified context. It also deactivates all Tanzu CLI plugins associated with the context.
tanzu context unset CONTEXT-NAME [FLAGS]
To unset a context named my-management-cluster
:
tanzu context unset my-management-cluster
-h, --help
Help text.
-t, --type
The context type with which the specified context is associated. Supported values are kubernetes
or k8s
, mission-control
or tmc
, tanzu
, and application-engine
.
Sets the current context for the Tanzu CLI. If any required CLI plugins associated with the context are not installed, tanzu context use
installs them.
Note: This command replaces tanzu login --server SERVER-NAME
.
tanzu context use CONTEXT-NAME [FLAGS]
To set the current context to my-management-cluster
:
tanzu context use my-management-cluster
-h, --help
Help text.