问题:

[root@k8s-master yaml_all]# kubectl get po
NAME                     READY   STATUS    RESTARTS   AGE
nginx-648b5cc477-7b5pt   1/1     Running   0          3h41m
nginx-648b5cc477-mplmg   1/1     Running   0          3h41m
nginx-648b5cc477-zw8jq   1/1     Running   0          3h41m

执行下面这条后报错了

[root@k8s-master yaml_all]# kubectl exec -it nginx-648b5cc477-7b5pt bash
error: unable to upgrade connection: Forbidden (user=system:anonymous, verb=create, resource=nodes, subresource=proxy)

临时解决方法:
绑定一个cluster-admin的权限

[root@k8s-master yaml_all]# kubectl create clusterrolebinding system:anonymous --clusterrole=cluster-admin --user=system:anonymous
clusterrolebinding.rbac.authorization.k8s.io/system:anonymous created

[root@k8s-master yaml_all]# kubectl exec -it nginx-648b5cc477-7b5pt -- bash 
root@nginx-648b5cc477-7b5pt:/# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@nginx-648b5cc477-7b5pt:/# exit
exit

转载于:https://blog.51cto.com/11288550/2378291

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐