Switch cluster context using kubectl command
search cancel

Switch cluster context using kubectl command

book

Article ID: 345713

calendar_today

Updated On:

Products

VMware Telco Cloud Automation

Issue/Introduction

To provide a workaround in case customer/dev faces issue to query kubernetes resoures using kubectl command from bootstrapper VM/tca-cp

Symptoms:
After a few rounds of deploy/undeploy of clusters, cluster context is not set correctly. Querying of cluster resources using kubectl does not work as expected.

Cause

After a few rounds of deploy/undeploy of clusters, cluster context is not set correctly.

Resolution

This will be fixed in Telco Cloud Automation 3.0

Workaround:
As a workaround user needs to switch to the right cluster context using the following steps:

1. SSH to the TCA-CP/bootstrapper VM as admin

2. Switch to root user.

3. Use kubectl command below to query for all the cluster contexts.
 
kubectl config get-contexts

4. Switch to the desired cluster context using the command below.
 
kubectl config use-context context_name

5. Verify context switch operation by querying for k8s resources available within the cluster.
 
kubectl get api-resource-name -n namespace" / "kubectl get api-resource-name -A