如何修复“错误:“kubectl”的未知命令“join””

如何修复“错误:“kubectl”的未知命令“join””

我尝试使用 kubectl join 命令将工作节点加入 Kubernetes 集群。尝试通过运行以下命令来解决该问题。

要解决此问题,您需要更新 kubectl 命令行工具以匹配 Kubernetes 集群的版本。

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl"

下载最新版本的 kubectl 后,您需要使其可执行并将其移动到 PATH 中的某个位置:

chmod +x kubectl
sudo mv kubectl /usr/local/bin/kubectl

命令下面的新建议方法也不起作用。

sudo snap install kubectl --classic

要查看系统上安装的当前 Kubernetes 版本,可以使用 kubectl version 命令。

ubuntu@master:~$ sudo kubectl version
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.4+k3s1", GitCommit:"8d0255af07e95b841952563253d27b0d10bd72f0", GitTreeState:"clean", BuildDate:"2023-04-20T00:33:38Z", GoVersion:"go1.19.8", Compiler:"gc", Platform:"linux/arm"}
Kustomize Version: v4.5.7
Server Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.4+k3s1", GitCommit:"8d0255af07e95b841952563253d27b0d10bd72f0", GitTreeState:"clean", BuildDate:"2023-04-20T00:33:38Z", GoVersion:"go1.19.8", Compiler:"gc", Platform:"linux/arm"}

*To view the current version of kubectl, you can use the kubectl version command.*

ubuntu@master:~$ **sudo kubectl version --client**
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.4+k3s1", GitCommit:"8d0255af07e95b841952563253d27b0d10bd72f0", GitTreeState:"clean", BuildDate:"2023-04-20T00:33:38Z", GoVersion:"go1.19.8", Compiler:"gc", Platform:"linux/arm"}
Kustomize Version: v4.5.7

ubuntu@worker:~$ **kubectl version --client**
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.1", GitCommit:"4c9411232e10168d7b050c49a1b59f6df9d7ea4b", GitTreeState:"clean", BuildDate:"2023-04-14T13:21:19Z", GoVersion:"go1.20.3", Compiler:"gc", Platform:"linux/arm"}
Kustomize Version: v5.0.1

# Linux master 6.2.0-1004-raspi #5-Ubuntu SMP PREEMPT Mon Apr  3 10:50:45 UTC 2023 armv7l armv7l armv7l GNU/Linux
# Linux worker 6.2.0-1004-raspi #5-Ubuntu SMP PREEMPT Mon Apr  3 11:15:14 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux

答案1

您运行了错误的命令;要将节点加入集群,您需要使用kubeadm join。注意,不是。kubeadmkubectl

相关内容