Rancher的普通用户如何使用kubectl从外部访问集群

Rancher Server 设置

  • Rancher 版本:2.7.5
  • 安装选项:Helm
    • Local 集群的类型和版本:RKE2 1.26.7

用户信息

  • 登录用户的角色:项目所有者

问题描述:
如何让Rancher的项目所有者用户如何使用kubectl从外部访问集群?
项目所有者用户可以在Rancher的Kubectl Shell中使用kubectl管理项目命名空间的资源。如果将该用户的KubeConfig保存至集群外部主机的~/.kube/config,执行kubectl get pod查看项目命名空间的pod会出现错误信息:

[gitlab-runner@localhost ~]$ kubectl get pod -n test
E1005 18:12:17.931387  109742 memcache.go:265] couldn't get current server API group list: the server could not find the requested resource
E1005 18:12:17.945431  109742 memcache.go:265] couldn't get current server API group list: the server could not find the requested resource
E1005 18:12:17.957814  109742 memcache.go:265] couldn't get current server API group list: the server could not find the requested resource
E1005 18:12:17.972268  109742 memcache.go:265] couldn't get current server API group list: the server could not find the requested resource
E1005 18:12:17.983172  109742 memcache.go:265] couldn't get current server API group list: the server could not find the requested resource
Error from server (NotFound): the server could not find the requested resource

我使用目前最新的 rancher v2.7.8 未重现,操作步骤如下:

  1. 创建 v1.26.8+rke2r1 集群

  2. 导航到 用户 & 认证 创建用户 test 用户,全局用户为 普通用户

  3. 导航到 集群管理 菜单,选择对应的集群,添加成员角色为:成员


4. 保存集群
5. 使用 test 用户重新登录 rancher ,并通过 UI 提供的下载 kubeconfig 下载 kubeconfig,并通过 kubectl 访问集群

你可以尝试升级到最新版,如果还不好用,请排查是否操作步骤不对,然后描述详细的重现步骤

@wang 什么原因?

  1. 导航到 集群管理 菜单,选择对应的集群,添加成员角色为:成员

没有在集群管理添加用户。

你这里不是说是 “项目所有者” 了么……