我成功安装了 microk8s 并启用了仪表板。
我进入了要求配置或令牌登录的屏幕。问题是我无法获取此令牌。我读过很多教程,但它们大多采用相同的方法,这对我来说不起作用。
例子:
- https://jhooq.com/setting-up-kubernetes-dashboard/#kubernetes-dashboard-local-cluster
- https://docs.aws.amazon.com/eks/latest/userguide/dashboard-tutorial.html
问题是我总是收到这个“在 kube-system 命名空间中找不到资源”错误,所以我无法获取令牌:
kadmin@kubernetes-master:~$ kubectl create serviceaccount k8sadmin -n kube-system
error: failed to create serviceaccount: serviceaccounts "k8sadmin" already exists
kadmin@kubernetes-master:~$ kubectl create clusterrolebinding k8sadmin --clusterrole=cluster-admin --serviceaccount=kube-system:k8sadmin
error: failed to create clusterrolebinding: clusterrolebindings.rbac.authorization.k8s.io "k8sadmin" already exists
kadmin@kubernetes-master:~$ kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | (grep k8sadmin || echo "$_") | awk '{print $1}') | grep token: | awk '{print $2}'
No resources found in kube-system namespace.
Error from server (NotFound): secrets "k8sadmin" not found
答案1
我找到了解决方案。我必须执行:
kubectl create token eks-admin --namespace kube-system
...并输出令牌。