Connecting to the cluster with a kubeconfig file

Use a downloaded kubeconfig file to connect to the cluster of a project with kubectl.

To run kubectl commands without installing it, click the More Options (three dots) icon next to the kubeconfig file and select Open Terminal. To run the commands from your local host, complete the following steps.

  1. Click the More Options (three dots) icon next to the kubeconfig file in the list, and then select Download. Save the file locally, for example, as ~/Downloads/<cluster-name>-kubeconfig.yaml.
  2. Use the file in one of the following ways.
    • To use the file for the current terminal session only, run the following commands:

      export KUBECONFIG=~/Downloads/<cluster-name>-kubeconfig.yaml
      kubectl cluster-info
      kubectl get nodes
    • To pass the file in a single command, use the --kubeconfig option:

      kubectl get nodes --kubeconfig=~/Downloads/<cluster-name>-kubeconfig.yaml
    • To replace your existing kubeconfig file permanently, run the following commands. Back up the old file first if you still need it:

      mkdir -p ~/.kube
      mv ~/Downloads/<cluster-name>-kubeconfig.yaml ~/.kube/config
  3. To test the connection, run the following commands:
    kubectl get pods -A
    kubectl get services -A
    kubectl cluster-info
    kubectl get nodes