Kubectl: [v1.18.0] kubectl's version cannot be retrieved WITHOUT a kube config or additional params

Created on 4 Apr 2020  路  12Comments  路  Source: kubernetes/kubectl

It should be possible to check the kubectl version WITHOUT having a valid or any kubeconfig file.

However, now it just throws an error and does NOT display the version in use (v1.18):

 # kubectl version
W0404 15:19:07.071657   17635 loader.go:223] Config not found: /root/.kube/config
error: Missing or incomplete configuration info.  Please point to an existing, complete config file:

  1. Via the command-line flag --kubeconfig
  2. Via the KUBECONFIG environment variable
  3. In your home directory as ~/.kube/config

To view or setup config directly use the 'config' command.
arekubectl kinbug sicli

Most helpful comment

if you use --client=true it will work:

kubectl version --client=true
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.0", GitCommit:"9e991415386e4cf155a24b1da15becaa390438d8", GitTreeState:"clean", BuildDate:"2020-03-25T14:58:59Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"linux/amd64"}

I agree that it would be nice to print the client version though even if there is no config file.

All 12 comments

if you use --client=true it will work:

kubectl version --client=true
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.0", GitCommit:"9e991415386e4cf155a24b1da15becaa390438d8", GitTreeState:"clean", BuildDate:"2020-03-25T14:58:59Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"linux/amd64"}

I agree that it would be nice to print the client version though even if there is no config file.

when you just use version without any options it should fetch client and server version and fetching server version without kubeconfig file would not be possible, so i think this is expected behaviour

-srini

I think a local tool should be able to print its version without any external dependencies or extra parameters.

If it does not have a kubeconfig, it should print the client version and throw the same error after that.

If you specify --client=true, it should still print just the client version - the same goes for --server=true.

It actually should not act like this... My PR will fix this:https://github.com/kubernetes/kubernetes/pull/89913

even after https://github.com/kubernetes/kubernetes/pull/89913, this is still not working as it did in 1.17

edit: might be my local build... verifying...

will be fixed in 1.18 by https://github.com/kubernetes/kubernetes/pull/90244

/assign @soltysh

/kind bug

/sig cli
/area kubectl

Seems to be fixed now.

/close

@seans3: Closing this issue.

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

you can run this command : export KUBERNETES_MASTER=http://127.0.0.1:8080 on master role

Was this page helpful?
0 / 5 - 0 ratings