Login to Tanzu Kubernetes Grid management clusters fails with error "err-unable to read kubeconfig"
search cancel

Login to Tanzu Kubernetes Grid management clusters fails with error "err-unable to read kubeconfig"

book

Article ID: 319317

calendar_today

Updated On:

Products

Tanzu Kubernetes Grid

Issue/Introduction

Symptoms:
  • You are using tanzu CLI to login into a management cluster
  • You have selected login type as Local kubeconfig
  • Your login attempt fails with the error below

root@kube-worker:/data/cal# tanzu login
? Select login type Local kubeconfig
? Enter path to kubeconfig (if any) ~/.kube/config
? Enter kube context to use tkgmgmt-admin@tkgmgmt
? Give the server a name tkgmgmt
✖  failed to login to the management cluster tkgmgmt, err-unable to read kubeconfig
Error: exit status 1
✖  exit status 1


Environment

VMware Tanzu Kubernetes Grid 1.x

Cause

Your login attempt is failing because you are trying to use the relative path to the kubeconfig. Example:
? Enter path to kubeconfig (if any) ~/.kube/config

Resolution

To successfully login to the management cluster you need an absolute path to kubeconfig
Example of correct tanzu login options:

tanzu login
? Select a server + new server
? Select login type Local kubeconfig
? Enter path to kubeconfig (if any) /root/.kube/config
? Enter kube context to use oom-mgmt-admin@oom-mgmt
? Give the server a name oom-mgmt
✔  successfully logged in to management cluster using the kubeconfig oom-mgmt


Alternatively, you can also use the command below. In this command, a relative path can be specified

tanzu login --kubeconfig ~/.kube/config --context tkgmgmt-admin@tkgmgmt --name tkgmgmt
✔ successfully logged in to management cluster using the kubeconfig tkgmgmt