Kubectl config view gives empty results Kubectl config view gives empty results kubernetes kubernetes

Kubectl config view gives empty results


  • Just to make sure, try running kubectl config view --kubeconfig <PATH_TO_YOUR_CONFIG_FILE>.
  • Make sure your $KUBECONFIG is empty, (or that it points at ~/.kube/config).
  • If you installed kubectl via snap it might possibly be a sand-boxing issue.


I have been struggling with the same problem for a couple of days. The kubeconfig for my Linode cluster simply would not work. kubectl config view -v 8 (verbose max) gave me this output:

I0312 10:01:07.513754   16368 loader.go:379] Config loaded from file:  C:\Users\username\.kube\configapiVersion: v1clusters: nullcontexts: nullcurrent-context: ""kind: Configpreferences: {}users: null

I finally discovered that my config file contained a zero width space (U+200B) at the beginning of one line. It was invisible in every editor I used, including Notepad++ with show all characters enabled. One of my colleagues found it using Vim. You can also find it by trying to convert the file to ASCII using iconv:

$ iconv -t ascii ./configapiVersion: v1kind: Configpreferences: {}iconv: config:4:0: cannot convert

Maybe an obvious thing to check for some, but it's not until you have experienced it. Copying the text into a new file brought it along invisibly as well.

I find it disappointing that kubectl will not at least provide an error message in this situation, instead of failing silently by outputting an empty kubeconfig. (I used kubectl v1.19.5 and v1.20.4).