Step 1: Get kubeconfig file
root@topgun01 [ ~ ]# tanzu management-cluster kubeconfig get --admin --export-file tkg-vmc-mgmt-c01-admin-kubeconfig.yaml
Credentials of cluster 'tkg-vmc-mgmt-c01' have been saved
You can now access the cluster by running 'kubectl config use-context tkg-vmc-mgmt-c01-admin@tkg-vmc-mgmt-c01' under path 'tkg-vmc-mgmt-c01-admin-kubeconfig.yaml'
(reverse-i-search)`': tanzu management-cluster kubeconfig get^C-export-file tkg-vmc-mgmt-c01-admin-kubeconfig.yaml
You can get the context
root@topgun01 [ ~ ]# cat tkg-vmc-mgmt-c01-admin-kubeconfig.yaml
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5ekNDQWJPZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeE1EZ3hOVEEzTkRJeE5Gb1hEVE14TURneE16QTNORGN4TkZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTmliCnJ5clljOUhYS3Uwd1ZFUmlqcXZlbXlIbEFjYldpQU9GTGFKZUhkQlRhcU85TnB6UW1NQWREbWZ4SExlSXhZZzYKdWtGLzA5U1B4YW9GS3JhaVlXR2Z2VjFHcndBaDRERVN4ZjIyOC9kRGFjcWVhbk1mR2p4YWhmbUdyZEowMVFiSgozbjN6K1N6aGo0TTFlZE90MUhIQ2tnZzBhQ1FVN1NZV29WWGdrb0NhUFhIK0xqQ3JtcVhRTXRVejB4SGpDZGRWCm5YQnFNMUNJZzRVWElqR3g5WXhaOHBDYWlxQkFnVmlBc0c2YlhEdVg2a3IvdWFtbHlDcCt0YWdpYjVLSnh6VlkKdzFySC93WHI5M2tzblRUTFdvYWRzRDM3TjFRSkNrRWxybmFYcytFTDE1cDVRQzNNTVptWnJMYkF3QjAwSTBRNQpaY0NSRFN2MFFXTXJxQ3JqQmxrQ0F3RUFBYU1tTUNRd0RnWURWUjBQQVFIL0JBUURBZ0trTUJJR0ExVWRFd0VCCi93UUlNQVlCQWY4Q0FRQXdEUVlKS29aSWh2Y05BUUVMQlFBRGdnRUJBQnhYeWpVaUl1a2JsSFR4Z015ODJMRTEKaGFIcVdENVA1M0I2bkNZWmlVckxKRG4wcWNteFEwN2JFZU1ud29sblArbUh0QlB1djgyUTBxeWxoN05KSDhtSwpsLy9CTEtWdlFSUkNuUDZ1UmZORE1JS3BBb2hDVld3MGRHZkZmaEd4ODNpU3RPYjBjL0l5RkJtZDl2YXlCZlZvClVaTm9MbGJWSVlNNGpFd21IRVpjWjMrcUlBR3RuSVBJMDR1eFMyRk9SREFSdTZQVEpoWUxZZlgzUDQ2ZTBHL2IKMnE4ZlVQTUhRMXc1eGs1b1JsdklVbnJ4dmFXVDVqVWhNQjFFTm5DaXBnc0hjOHYxS3NubUdkTzNNSXFPV0JDRgpmSmt5SG9IVmRHS25CS21ON24ya01NdXhJR1hoR1dRZ2tDaEY2bmJ1VEZteDFOMUEzc2gzUERPTHVjQWY1dG89Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
server: <https://192.168.2.3:6443>
name: tkg-vmc-mgmt-c01
contexts:
- context:
cluster: tkg-vmc-mgmt-c01
user: tkg-vmc-mgmt-c01-admin
name: tkg-vmc-mgmt-c01-admin@tkg-vmc-mgmt-c01
current-context: tkg-vmc-mgmt-c01-admin@tkg-vmc-mgmt-c01
kind: Config
preferences: {}
users:
- name: tkg-vmc-mgmt-c01-admin
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJR0R1TXhpUjgwVzh3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TVRBNE1UVXdOelF5TVRSYUZ3MHlNakE0TVRVd056UTNNVFZhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3FoaxxxxxxxS0tLQo=
client-key-data: LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFb2dJQkFBS0NBUUVBb2Y0Z3ZxNFNGS0hVR0hSUktRUks0WWJCV2xzcDRhQTJCbzFhZzZaTy82c3VXdGpaClRTcG9qcXBsWHdXbWgvV3J2MEk5WU1nMVRVOStKTElEdEN4amhGZmk2dnRBTHQxaWlET09aSzFyZXVqZnFqaGgKc1d1R2pVR0VTU1hpUzhsN2pLUXlkbHlFNVN5VUpiV0pNbXFsckRUTlNHTEVwdXRvOE1Ecjd2K2VOSVhmNXMvMgpjL3lIc1M4aXByNWZkMmxkcnRlek9kRVMzVmJ5UWh1UU9wVkM2K0NDK3ppaGxCamhSaUx4RTRhMTNDZXFvVU9lClk4V0xtQXFISWxWdUthL1prNiszZjIxQmkySjZvYjZPL1YveG1hVTFwdXVQaUFKeWRORDY5TUwrQWtINUluUEEKby9wRGdwNERmRmlvK29WWFhVTjkxOVVaeGVwZFlDMFlZYVMwWVFJREFRQUJBb0lCQUNrNHh0SmU3MkRxc1ZNcgp2ajlteFR0UWxFRk84NxxxxxEtFWS0tLS0tCg==
root@topgun01 [ ~ ]#
Step 2: Download the file and upload to your desktop
Step 3: Add the mgmt cluster to Tanzu CLI
zhangda@zhangda-a01 ~ % tanzu login
? Select login type Local kubeconfig
? Enter path to kubeconfig (if any) tkg-vmc-mgmt-c01-admin-kubeconfig.yaml
? Enter kube context to use tkg-vmc-mgmt-c01-admin@tkg-vmc-mgmt-c01
? Give the server a name tkg-vmc-mgmt-c01
✔ successfully logged in to management cluster using the kubeconfig tkg-vmc-mgmt-c01
Step 4: Verify
zhangda@zhangda-a01 ~ % tanzu login
? Select a server tkg-vmc-mgmt-c01 ()
✔ successfully logged in to management cluster using the kubeconfig tkg-vmc-mgmt-c01
zhangda@zhangda-a01 ~ % tanzu cluster list
NAME NAMESPACE STATUS CONTROLPLANE WORKERS KUBERNETES ROLES PLAN
tkg-vmc-workload-c01 default running 1/1 3/3 v1.20.5+vmware.1 <none> dev
tkg-vmc-workload-c02 default running 1/1 3/3 v1.20.5+vmware.2 <none> dev
tkg-vmc-workload-c03 default running 1/1 3/3 v1.20.5+vmware.1 <none> prod