I am trying to install Kubernetes in Mac. I followed these instructions - https://kubernetes.io/docs/tasks/tools/install-kubectl/ (for MacOs)
Followed all the 5 steps mentioned in that link
1. curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl"
2.curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl.sha256"
echo "$(<kubectl.sha256) kubectl" | shasum -a 256 --check
output: kubectl: OK
3. chmod +x ./kubectl
4. sudo mv ./kubectl /usr/local/bin/kubectl && \
sudo chown root: /usr/local/bin/kubectl
5. kubectl version --client
Apparently, when I executed this kubectl version --client
zsh: bad CPU type in executable: kubectl
I tried to switch the shell from zsh to sh, bash but nothing helped
Your are trying to download a version of kubectl for the darmin/amd64 architecture. "Darwin" means, effectively, MacOS, and amd64 refers to Intel and AMD 64-bit processors.
You have an M1 Mac, which famously is built around an ARM processor, unlike the rest of Apple's machines.
You would need to find kubectl built for darwin/arm64. As @DavidMaze suggested, you may be able to obtain that by installing the kubernetes-cli package via Homebrew.
I also got the same problem. Resolved by following steps:
Now check command:
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.2", GitCommit:"092fbfbf53427de67cac1e9fa54aaa09a28371d7", GitTreeState:"clean", BuildDate:"2021-06-16T12:52:14Z", GoVersion:"go1.16.5", Compiler:"gc", Platform:"darwin/amd64"}