After management cluster context name change and running 'tanzu mc get' command yields Error: clusters.cluster.x-k8s.io "<management_cluster_context name>" not found
search cancel

After management cluster context name change and running 'tanzu mc get' command yields Error: clusters.cluster.x-k8s.io "<management_cluster_context name>" not found

book

Article ID: 410994

calendar_today

Updated On:

Products

VMware Tanzu Kubernetes Grid Management

Issue/Introduction

After a management cluster context name change using below command:

kubectl config rename-context <old-context-name> <new-context-name>


and then running either of below commands:

tanzu mc get

tanzu management-cluster get


The following error is displayed:

Error: clusters.cluster.x-k8s.io "<management_cluster_context name>" not found

Environment

TKGm 2.5.3

Cause

Changing the management cluster context name with the 'kubectl config rename-context' command will only update the below directory/file:

.kube/config


The management cluster context name will also exist in and need to be correct in the below yamls:

.config/tanzu/config.yaml

.config/tanzu/config-ng.yaml

Resolution

Both the ".kube/config" and the ".config/tanzu/config-ng.yaml" files must be updated with the correct management cluster context name.

Run below command to get the management cluster context name:

kubectl config get-contexts


In the ".kube/config" the context must have the correct management cluster context name similar to below:

...
name: <management-cluster-context-name>
  - cluster:
        certificate-authority-data: LS0t.......
        server: https://##.##.##.##:6443
...
...
- context:
        cluster: <management-cluster-name>
        user: kubernetes-admin
    name: kubernetes-admin@<management-cluster-name>



and in the ".config/tanzu/config-ng.yaml" the context must also have the correct management cluster context name

...
contexts:
     - name: <management-cluster-context-name>
        target: kubernetes
    contextType: kubernetes
       clusterOpts:
       endpoint: https://##.##.##.##:6443
       path: /home/xxxx/.kube/config
       context: <management-cluster-context-name> #---- Change this to the correct management cluster context name
       isManagementCluster: true
       additionalMetadata:
         isPinnipedEndpoint: true
...