RKE2 需要授权端点配置帮助

问题描述 投票:0回答:1

我有一个 rancher 2.6.67 服务器和 RKE2 下游集群。集群是在没有授权的集群端点的情况下创建的。 如何将授权的集群端点添加到 Rancher 创建的 RKE2 集群文章描述了如何将其添加到现有集群中,但是尽管答案看起来很有希望,但我仍然必须错过一些细节,因为它对我不起作用。 这是我所做的: 创建了 /var/lib/rancher/rke2/kube-api-authn-webhook.yaml 文件,其内容为:

apiVersion: v1
kind: Config
clusters:
 - name: Default
  cluster:
    insecure-skip-tls-verify: true
    server: http://127.0.0.1:6440/v1/authenticate
users:
 - name: Default
  user:
    insecure-skip-tls-verify: true
current-context: webhook
contexts:
 - name: webhook
  context:
    user: Default
    cluster: Default

并添加了

  "kube-apiserver-arg": [
    "authentication-token-webhook-config-file=/var/lib/rancher/rke2/kube-api-authn-webhook.yaml"

到 /etc/rancher/rke2/config.yaml.d/50-rancher.yaml 文件。 重新启动 rke2-server 后,我在 Rancher 中找到了网络配置选项卡,并且能够启用授权端点。我的成功到这里就结束了。 我尝试创建一个 serviceaccount 并获取密钥以进行令牌授权,但在直接连接到 master 上的 api 端点时失败。 kube-api-auth pod 记录以下内容:

time="2022-10-06T08:42:27Z" level=error msg="found 1 parts of token"
time="2022-10-06T08:42:27Z" level=info msg="Processing v1Authenticate request..."

日志中也充满了这样的消息:

E1006 09:04:07.868108       1 reflector.go:139] pkg/mod/github.com/rancher/[email protected]/tools/cache/reflector.go:168: Failed to watch *v3.ClusterAuthToken: failed to list *v3.ClusterAuthToken: the server could not find the requested resource (get clusterauthtokens.meta.k8s.io)
E1006 09:04:40.778350       1 reflector.go:139] pkg/mod/github.com/rancher/[email protected]/tools/cache/reflector.go:168: Failed to watch *v3.ClusterAuthToken: failed to list *v3.ClusterAuthToken: the server could not find the requested resource (get clusterauthtokens.meta.k8s.io)
E1006 09:04:45.171554       1 reflector.go:139] pkg/mod/github.com/rancher/[email protected]/tools/cache/reflector.go:168: Failed to watch *v3.ClusterUserAttribute: failed to list *v3.ClusterUserAttribute: the server could not find the requested resource (get clusteruserattributes.meta.k8s.io)

我发现 SA 令牌无法以这种方式工作,因此我尝试使用牧场主用户令牌,但也失败了:

time="2022-10-06T08:37:34Z" level=info msg="  ...looking up token for kubeconfig-user-qq9nrc86vv"
time="2022-10-06T08:37:34Z" level=error msg="clusterauthtokens.cluster.cattle.io \"cattle-system/kubeconfig-user-qq9nrc86vv\" not found"

检查cattle-system命名空间,没有与rancher中创建的用户对应的SA和秘密条目,但是我在cattle-impersonation-system中发现了相关的SA和秘密条目。 我尝试创建一个新用户,但这也只会在cattle-impersonation-system命名空间中产生新条目,因此我认为kube-api-auth错误地假设秘密的位置是cattle-system命名空间。 现在问题:

  • 我可以使用普通 SA 令牌(不是通过 Rancher 服务器创建的令牌)向下游 RKE2 集群进行身份验证吗?如果是的话,怎么办?
  • 添加 webhook 身份验证配置时我做错了什么?如何让它发挥作用?
  • 我注意到,由于我进行了上述修改,我无法从该集群的 rancher UI 下载 kubeconfig 文件。那里出了什么问题?

预先感谢您的任何建议。

authentication token rancher rke2
1个回答
0
投票

这对你有用吗@Seniorsamu

© www.soinside.com 2019 - 2024. All rights reserved.