Cleaning up kubeconfig

We can still leveragekubectl config to remove configurations in kubeconfig. For cluster sand context, you can delete the neglected one with the subcommands delete-cluster and delete-context. Alternatively, for these three categories, the unset subcommand can complete the deletion:

// delete the customized local context
$ kubectl config delete-cluster local-cluster
deleted cluster local-cluster from $HOME/.kube/config

// unset the local user
// to remove cluster, using property clusters.CLUSTER_NAME; to remove contexts, using property contexts.CONTEXT_NAME
$ kubectl config unset users.myself@local
Property "users.myself@local" unset.

Although the effects of the preceding command would apply to the live kubeconfig right away, an even faster and more reliable way is updating another kubeconfig file for the replacement. A kubeconfig file is the text file new-kubeconfig, the one we just updated, or the one we copied from the initial statement, original-kubeconfig:

// remove all of our practices
$ cp ~/original-kubeconfig ~/.kube/config
// check your kubeconfig to make sure it has been cleaned
$ kubectl config view
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.228.156