Problem scenario
You run a kubectl command, but you see this message:Error from server (NotAcceptable): the server was unable to respond with a content type that the client supports
What should you do?
Solution
1. Run this command: kubectl version
There should be a "Client Version" and a "Server Version". The two are probably different. Find where your kubectl file is (e.g., in /usr/bin/) with this command: sudo find / -name kubectl
2. Back it up (e.g., sudo mv -i /usr/bin/bak.kubectl.bak
). Make a mental note of this directory location.
3. Download the kubectl that is consistent with the server version. Replace X.Y.Z with the server's version in the following commands:
cd /tmp/
curl -LO https://storage.googleapis.com/kubernetes-release/release/vX.Y.Z/bin/linux/amd64/kubectl
# An example of the above URL may be https://storage.googleapis.com/kubernetes-release/release/v1.15.5/bin/linux/amd64/kubectl # where 1.15.5 is the version associated with the "kubectl version" output for Server Version.
4. Place this kubectl file where the original kubectl file was (e.g., /usr/bin/).
5. Now run the kubectl command (e.g., kubectl get pods
, kubectl get svc
).