Kubectl always returns a error: yaml: mapping values are not allowed in this context
That the version command already throws an error indicates that there is some default YAML file that gets loaded.
You can use strace kubectl version
to see what file was opened, hopefully this is done just before kubectl
throws the error. I assume there is some global config that it reads (or alternatively a default file in your current directory).
It is of course sloppy programming in kubernetes not to catch such an error, and display the name of the file, and then re-raise the error.
Most of the time when you get an error like this (speaking in general and meaningful terms) it is either because of :-
1). A syntax error (in your case it is not) in the yaml file.
2). Or like the error says "mapping values are not allowed in this context". It means that the keys/values you have used in the yaml, may be syntactically right but not semantically.
Since you're getting the error even upon running kubectl version
, I'd say you've got a yaml syntax error in your kubeconfig file, located at ~/.kube/config
by default.
You could validate its content using a yaml validator like this one.