简体   繁体   English

zsh:可执行文件中的错误 CPU 类型:kubectl (macOS Big Sur)

[英]zsh: bad CPU type in executable: kubectl (macOS Big Sur)

I am trying to install Kubernetes in Mac.我正在尝试在 Mac 中安装 Kubernetes。 I followed these instructions - https://kubernetes.io/docs/tasks/tools/install-kubectl/ (for MacOs)我按照这些说明进行操作 - https://kubernetes.io/docs/tasks/tools/install-kubectl/ (适用于 MacO)

Followed all the 5 steps mentioned in that link遵循该链接中提到的所有 5 个步骤

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显然,当我执行这个 kubectl version --client

zsh: bad CPU type in executable: kubectl

I tried to switch the shell from zsh to sh, bash but nothing helped我试图将 shell 从 zsh 切换到 sh,bash 但没有任何帮助

Your are trying to download a version of kubectl for the darmin/amd64 architecture.您正在尝试为darmin/amd64架构下载kubectl版本。 "Darwin" means, effectively, MacOS, and amd64 refers to Intel and AMD 64-bit processors. “Darwin”实际上是指 MacOS,而amd64指的是 Intel 和 AMD 64 位处理器。

You have an M1 Mac, which famously is built around an ARM processor , unlike the rest of Apple's machines.你有一台 M1 Mac,它以ARM 处理器而闻名,这与 Apple 机器的 rest 不同。

You would need to find kubectl built for darwin/arm64 .您需要找到为darwin/arm64 kubectl As @DavidMaze suggested, you may be able to obtain that by installing the kubernetes-cli package via Homebrew .正如@DavidMaze 建议的那样,您可以通过Homebrew安装kubernetes-cli package 来获得它。

I also got the same problem.我也遇到了同样的问题。 Resolved by following steps:通过以下步骤解决:

  • rm /usr/local/bin/kubectl rm /usr/local/bin/kubectl
  • brew install kubectl酿造安装 kubectl

Now check command:现在检查命令:

  • kubectl version --client kubectl 版本 --client
    you will get output something like this:你会得到 output 是这样的:

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"}客户端版本:version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.2", GitCommit:"092fbfbf53427de67cac1e9fa54aaa09a28371d7", GitTreeState:"clean", BuildDate:"2021-06-16T12:52: 14Z”,GoVersion:“go1.16.5”,编译器:“gc”,平台:“darwin/amd64”}

For Mac M1 - install Rosetta softwareupdate --install-rosetta对于 Mac M1 - 安装 Rosetta softwareupdate --install-rosetta

Working on my M1 Big Sur 11.5.1在我的 M1 Big Sur 11.5.1 上工作

For more info, have a look on this link Rosetta有关更多信息,请查看此链接Rosetta

Check this answer检查这个答案

The problem can have two reasons: 1- you either have a mac book with an apple silicon processor which is not supported by the app you start ( https://support.apple.com/en-gb/HT211814 ) 2- you start a i386 executable in a 64bit operating system问题可能有两个原因:1-您要么有一个带有苹果硅处理器的 mac book,您启动的应用程序不支持( https://support.apple.com/en-gb/HT211814 )2-您开始在 64 位操作系统中的 i386 可执行文件

Solution :解决方案
1- you should install rosetta that makes this integration 1-您应该安装进行此集成的 Rosetta
2- you should check if the app is really developed for a i386 system or not. 2-您应该检查该应用程序是否真的是为 i386 系统开发的。 If so install the 64bit version如果是这样安装64位版本

For me the problem was the 32bit / 64bit mismatch.对我来说,问题是 32 位 / 64 位不匹配。 To see if the app you are starting has a i386 or not you can run:要查看您正在启动的应用程序是否具有 i386,您可以运行:

find `echo $PATH | tr ":" "\n"` -perm +1111 -exec file {} \; | grep i386

installing the 64bit version solved my issue.安装 64 位版本解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM