Accessing kubectl CLI from Master and Worker VMs in TKGI
search cancel

Accessing kubectl CLI from Master and Worker VMs in TKGI

book

Article ID: 298509

calendar_today

Updated On:

Products

VMware Tanzu Kubernetes Grid Integrated Edition

Issue/Introduction

In some instances, tkgi get-credentials errors out while fetching kubeconfig for the cluster. However access to kubectl CLI is needed for troubleshooting. To resume troubleshooting users can ssh into the master or worker VMs of the cluster and access kubectl binary and kubeconfigs present on the VMs.

Environment

All Versions of Vmware Tanzu Kubernetes Grid Integrated Edition

Resolution

Execute the following to get access to kubectl CLI from the Kubernetes Master VM. 

bosh ssh -d service-instance_50a78f35-df99-4cf3-8815-7b680577ef59 master/0

master/01850df7-daaa-4b9c-a61f-e921074546ad:~$ sudo su -
master/01850df7-daaa-4b9c-a61f-e921074546ad:~# alias kubectl=/var/vcap/packages/kubernetes/bin/kubectl

master/01850df7-daaa-4b9c-a61f-e921074546ad:~# kubectl get pods -n pks-system

NAME                               READY     STATUS    RESTARTS   AGE
fluent-bit-mwbxd                   1/1       Running   0          1d
fluent-bit-vp66b                   1/1       Running   0          1d
sink-controller-57df674b84-wjp4k   1/1       Running   0          1d

 

Execute the following to get access to kubectl CLI from the Kubernetes Worker VM.

bosh ssh -d service-instance_50a78f35-df99-4cf3-8815-7b680577ef59 worker/0

worker/a3b4ccb6-1d14-4ee4-a1f1-6d5211dfe4b9:~$ sudo su -
worker/a3b4ccb6-1d14-4ee4-a1f1-6d5211dfe4b9:~# alias kubectl="/var/vcap/packages/kubernetes/bin/kubectl --kubeconfig=/var/vcap/jobs/kubelet/config/kubeconfig"

worker/a3b4ccb6-1d14-4ee4-a1f1-6d5211dfe4b9:~# kubectl get pods -n pks-system
NAME                               READY     STATUS    RESTARTS   AGE
fluent-bit-mwbxd                   1/1       Running   0          1d
fluent-bit-vp66b                   1/1       Running   0          1d
sink-controller-57df674b84-wjp4k   1/1       Running   0          1d