Kubernetes: /usr/local/bin/kubectl is version 1.19.0, and is incompatible with Kubernetes 1.16.2

9/2/2020

I am setting up Kubernetes for the first on my local machine using Minikube.

I installed kubectl on my local machine using:

curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl

However, when I run the command:

minikube start

I get the following error:

🎉  minikube 1.12.3 is available! Download it: https://github.com/kubernetes/minikube/releases/tag/v1.12.3
💡  To disable this notice, run: 'minikube config set WantUpdateNotification false'

🙄  minikube v1.5.2 on Ubuntu 18.04
💡  Tip: Use 'minikube start -p <name>' to create a new cluster, or 'minikube delete' to delete this one.
🔄  Starting existing virtualbox VM for "minikube" ...
⌛  Waiting for the host to be provisioned ...
🐳  Preparing Kubernetes v1.16.2 on Docker '18.09.9' ...
🔄  Relaunching Kubernetes using kubeadm ... 
⌛  Waiting for: apiserver
🏄  Done! kubectl is now configured to use "minikube"
⚠️  /usr/local/bin/kubectl is version 1.19.0, and is incompatible with Kubernetes 1.16.2. You will need to update /usr/local/bin/kubectl or use 'minikube kubectl' to connect with this cluster

I don't seem to understand what the error means by:

⚠️  /usr/local/bin/kubectl is version 1.19.0, and is incompatible with Kubernetes 1.16.2. You will need to update /usr/local/bin/kubectl or use 'minikube kubectl' to connect with this cluster

I can't remember installing minikube or Kubernetes before now on my local machine.

-- Promise Preston
kubernetes

1 Answer

9/2/2020

I finally figured it out what the issue was.

I ran the command kubectl version and I got the following output:

Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.0", 

GitCommit:"e19964183377d0ec2052d1f1fa930c4d7575bd50", GitTreeState:"clean", 

BuildDate:"2020-08-26T14:30:33Z", GoVersion:"go1.15", Compiler:"gc", Platform:"linux/amd64"}


Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.2", 

GitCommit:"c97fe5036ef3df2967d086711e6c0c405941e14b", GitTreeState:"clean", 

BuildDate:"2019-10-15T19:09:08Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}

It showed me the date when I installed Kubernetes using minikube installer, which was sometime in 2019 when I was trying out Kubenetes initially.

Here's how I fixed it:

There are 2 solutions:

Solution 1

Uninstall older/previous versions of Kubernetes using minikube on the Linux machine:

minikube stop; minikube delete
docker stop (docker ps -aq)
rm -r ~/.kube ~/.minikube
sudo rm /usr/local/bin/localkube /usr/local/bin/minikube
systemctl stop '*kubelet*.mount'
sudo rm -rf /etc/kubernetes/
docker system prune -af --volumes

Or on Mac:

minikube stop; minikube delete &&
docker stop $(docker ps -aq) &&
rm -rf ~/.kube ~/.minikube &&
sudo rm -rf /usr/local/bin/localkube /usr/local/bin/minikube &&
launchctl stop '*kubelet*.mount' &&
launchctl stop localkube.service &&
launchctl disable localkube.service &&
sudo rm -rf /etc/kubernetes/ &&
docker system prune -af --volumes

Reinstall a new copy of minikube:

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb

sudo dpkg -i minikube_latest_amd64.deb

And then run the command below to pull a new base image of Kubernetes:

minkube start

This pulls a new image of Kubernetes, and also configures kubectl to use minikube.

Solution 2:

Run the command below to downgrade kubectl to the same version as Kubenetes on the local machine:

minikube kubectl

This will install the kubectl compatible version for Kubernetes using minikube

That's all.

I hope this helps

-- Promise Preston
Source: StackOverflow