如何修复错误:用户无法在命名空间中的API组应用程序中获取资源&部署? [英] How to fix error: User cannot get resource "deployments" in API group "apps" in the namespace "default"?
本文介绍了如何修复错误:用户无法在命名空间中的API组应用程序中获取资源&部署?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对角色和身份验证Kubernetes有问题。我在我的裸机服务器上创建了一个单节点(One-Maser)集群,并使该集群监听不同于默认的IP(使用选项";--apiserver-adverise-Address=IP地址&qot;)。但现在我基本上什么也做不了,因为kubectl不起作用。我不能创建我需要的豆荚和服务。当我创建集群时,没有这个IP更改,它可以工作。所以我的问题是如何解决这个问题?这可能是授权问题,但我甚至无法创建群集角色或群集角色绑定,因为出现以下错误:错误:无法创建Clusterrolebindings.rbac.Authization.k8s.io被禁止:用户系统:节点:E4-1;无法在API组中创建资源";在群集作用域rbac.Authization.k8s.io";中...有没有办法以管理员或其他身份登录,或者有没有办法更改配置文件中的某些内容以修复此问题?
推荐答案
根据您提到的标志,我假设您正在使用kubeadm
创建集群。最可能的原因是您使用了错误的.conf
文件。我怀疑您使用的是kubelet.conf
而不是admin.conf
。
kubeadm init
输出的示例。它包含开始使用kubectl
所需遵循的步骤:
Your Kubernetes control-plane has initialized successfully!
To start using your cluster, you need to run the following as a regular user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
You should now deploy a Pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
/docs/concepts/cluster-administration/addons/
You can now join any number of machines by running the following on each node
as root:
kubeadm join <control-plane-host>:<control-plane-port> --token <token> --discovery-token-ca-cert-hash sha256:<hash>
如您所见,其中一个命令是将admin.conf
文件复制到/.kube/config
中,然后kubectl
使用该文件管理群集。
这篇关于如何修复错误:用户无法在命名空间中的API组应用程序中获取资源&部署?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文