Fix kubectl on Your Devbox#

I’m very frustrated with the pre-installed Google Cloud tools on our devboxes. I expected Google tools to be perfectly installed on Google VMs. But the installation on Ubuntu 22.04 is really broken. Here’s how to fix them.

Run these commands to remove the broken tools:

sudo snap remove google-cloud-cli 
sudo snap remove kubectl 

After that you should install the tools via apt:


You may get a menu message about the Kernel. Hit “OK” by pressing Enter.

export DEBIAN_FRONTEND=noninteractive
sudo apt-get install -y apt-transport-https ca-certificates gnupg
echo "deb [signed-by=/usr/share/keyrings/] cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl | sudo apt-key --keyring /usr/share/keyrings/ add -
sudo apt-get update -y && sudo apt-get install -y google-cloud-cli kubectl google-cloud-cli-gke-gcloud-auth-plugin


The last command takes a long time to do this step:

Setting up google-cloud-cli (427.0.0-0) ...

Pleae give it 10 minutes or so.

Make sure you tell bash to look for new versions and get the name of your Kubernetes cluster:

$ hash -r 
$ gcloud container clusters list 

Using the name of your cluster and the correct region, re-authenticate kubectl:

$ gcloud container clusters get-credentials cis-92-cluster --region=us-central1 

You should now be able to use kubectl:


If you see errors starting with E0420 it’s because your cluster is sleeping. (Not because it’s high.)

$ kubectl get all