To use kubectl and tmc (the Tanzu Mission Control CLI) with a provisioned cluster, download the generated configuration file and initialize the connection.

After you have attached or provisioned a new cluster using Tanzu Mission Control, you can connect to it with kubectl using the configuration file that Tanzu Mission Control generates for you.

In addition to provisioned and attached Tanzu Kubernetes Grid clusters, Tanzu Mission Control supports kubeconfig access to the following types of attached public cloud clusters:
  • Amazon Elastic Kubernetes Service (EKS)
  • Azure Kubernetes Service (AKS)
  • Google Kubernetes Engine (GKE)
For more information, see Enable Access to Public Cloud Clusters Through Tanzu Mission Control.

Prerequisites

This procedure assumes that you have a managed cluster, either attached or provisioned, and that you have already performed the following tasks:
  • Install the Kubernetes command-line interface (kubectl).
  • Open a browser window, and log in to the Tanzu Mission Control console.
  • Open a command window, and log in with the Tanzu Mission Control CLI.

Procedure

  1. In the left navigation pane of the Tanzu Mission Control console, click Clusters.
  2. On the Clusters page, click the cluster to which you want to connect.
  3. On the cluster detail page, in the upper right corner, click Access this cluster.
  4. In the resulting popup modal, click Download KUBECONFIG file. and then choose the CLI that you want to use (tmc or tanzu).
  5. Save the downloaded YAML file in a location that is accessible to kubectl (for example, in ~/.kube/config or in a location specified in the KUBECONFIG environment variable).
  6. Run a kubectl command to initialize the configuration. For example, the following command retrieves a list of namespaces in your cluster.
    kubectl get namespaces
    You can optionally use the --kubeconfig flag to specify the location and name of your downloaded kubeconfig YAML file. The command looks something like this:
    kubectl --kubeconfig=/path/to/kubeconfig-my-provisioned-cluster.yml get namespaces
    Note: The path/file value that you pass to the --kubeconfig flag must be an absolute path.
    If you are not logged in with the Tanzu Mission Control CLI, you are prompted to provide an API token to log in. For information about retrieving an API token, see Log In with the Tanzu CLI.