kubernetes kubectl被禁止执行



我做了一个基本的kubernetes安装,并添加了helloworldpod。当我尝试kubectl exec时,我得到以下错误。

kubectl logs hello-world-pod1
Error from server (Forbidden): pods "hello-world-pod1" is forbidden: User "system:node:kubnode1" cannot get resource "pods/log" in API group "" in the namespace "default"
kubectl exec -it hello-world-pod1 -- /bin/sh
Error from server (Forbidden): pods "hello-world-pod1" is forbidden: User "system:node:kw1" cannot create resource "pods/exec" in API group "" in the namespace "default"

并没有任何特殊的安装,只有基本的说明,无法访问基本吊舱的外壳,我研究了互联网,但找不到任何解决方案或错误来源。

这是一个访问问题,与pod本身无关,您需要使用具有访问权限的凭据。您可以使用kubectl auth can-i命令来检查您是否有访问权限。

如果pod没有您尝试执行到的shell,但它不是"shell",则您将得到错误;用户";系统:节点:kw1";无法创建";错误

由于您的案例中出现以下错误:

Error from server: error dialing backend: dial tcp 10.0.2.46:10250: connect: no route to host

我建议禁用所有节点上的防火墙。要修复未禁用工作节点的问题,请运行防火墙:

systemctl disable firewalld && systemctl stop firewalld
-Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1...
-Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.```

另请参阅参考资料:

  • 这个类似的问题
  • 连接到用于容器的非公共IP的文档

最新更新