When cluster operations fails, you need access to the cluster through kubectl CLI. However, in some instances, pks get-credentials
errors out while fetching kubeconfig for the cluster.
An alternate way to resume troubleshooting is to SSH into the Master or Worker VMs of the cluster, see the kubectl binary, and see the kubeconfigs present on the VMs. This article details the procedure to setup the kubectl CLI.
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