Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcloud command changes ownership of the current directory

Tags:

kubectl

gcloud

I'm performing usual operation of fetching kubernetes cluster credentials from GCP. The gcloud command doesn't fetch the credentials and surprisingly updates the ownership of the local directory:

~/tmp/1> ls
~/tmp/1> gcloud container clusters get-credentials production-ng
Fetching cluster endpoint and auth data.
ERROR: (gcloud.container.clusters.get-credentials) Unable to write file [/home/vladimir/tmp/1]: [Errno 21] Is a directory: '/home/vladimir/tmp/1'

~/tmp/1> ls
ls: cannot open directory '.': Permission denied

Other commands, like gcloud container clusters list work fine. I've tried to reinstall the gcloud.

like image 564
Vlad-HC Avatar asked Feb 28 '19 13:02

Vlad-HC


2 Answers

This happens if your KUBECONFIG has an empty entry, like :/Users/acme/.kube/config gcloud resolves the empty value as the current directory, changes permissions and tries to write to it

Reported at https://issuetracker.google.com/issues/143911217

like image 150
csanchez Avatar answered Oct 23 '22 03:10

csanchez


It happened to be a problem with kubectl. Reinstalling it solved this strange issue.

If you, like me, have stuck with strange gcloud behavior, following points could help to track an issue:

  • Checking alias command and if it's really pointing to the intended binary;
  • Launch separate docker container with gsutil and feed it your config files. If the gcloud container clusters get-credentials ... runs smoothly there, than it's the problem with binaries (not configuration):
docker run -it \
       -v $HOME/.config:/root/.config \
       -v $HOME/.kube:/root/.kube google/cloud-sdk:217.0.0-alpine sh
  • Problem with binary can be solved just by reinstalling/updating;
  • If it's a problem with configs, then you could back them up and reinstall kubectl / gsutil from scratch using not just apt-get remove ..., but apt-get purge .... Be aware: purge removes config files!

Hope this would help somebody else.

like image 30
Vlad-HC Avatar answered Oct 23 '22 04:10

Vlad-HC