Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to reset my kubectl settings back to default

On my ubuntu laptop I was issuing some kubectl commands including running kubernetes from a local Docker container all was well ... at some point I then issued this command

kubectl config set-cluster test-doc --server=https://104.196.108.118

now my local kubectl fails to execute ... looks like the Server side needs to get reset back to default

kubectl version

Client Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.2", GitCommit:"528f879e7d3790ea4287687ef0ab3f2a01cc2718", GitTreeState:"clean"}
error: couldn't get version/kind; json parse error: json: cannot unmarshal string into Go value of type struct { APIVersion string "json:\"apiVersion,omitempty\""; Kind string "json:\"kind,omitempty\"" }

I deleted and reinstalled the gcloud SDK binaries and ran

mv ~/.config/gcloud ~/.config/gcloud~ignore

gcloud init

gcloud components update kubectl

How do I delete my local kubectl settings (on ubuntu 16.04) and start fresh ?

like image 710
Scott Stensland Avatar asked Apr 27 '16 04:04

Scott Stensland


Video Answer


1 Answers

It's important to note that you've set a kubeconfig setting for your client. When you run kubectl version, you're getting the version for client and the server which in your case seems to be the issue with the version command.

Updating your config

You need to update the setting to the appropriate information. You can use the same command you used to set the server to change it to the correct server.

If you want to wipe the slate clean in terms of client config, you should remove the kubeconfig file(s). In my experience with the gcloud setup, this is just ~/.kube/config.

If you are running the cluster through google cloud engine, you can use gcloud to get the kubeconfig set for you as per the container engine quick start guide. The following assumes that you have defaults for the project, zone, and cluster set.

gcloud container clusters get-credentials CLUSTER_NAME

Removing kubectl - this isn't necessary

If your goal is to wholesale get rid of kubectl, you should remove the component rather than reseting gcloud.

gcloud components remove kubectl

But that won't solve your problem as it doesn't remove or reset ~/.kube/config when I run it on Mac and if you want to keep working with it, you'll need to reinstall kubectl.

like image 104
caseyh Avatar answered Sep 29 '22 16:09

caseyh