gpt4 book ai didi

kubernetes - TLS引导(--token-auth-file),用户 “system:anonymous”无法创建证书签名请求

转载 作者:行者123 更新时间:2023-12-02 11:48:32 24 4
gpt4 key购买 nike

为什么我在api服务器上设置--token-auth-file并在工作程序节点上设置--bootstrap-kubeconfig,为什么我在apiserver和工作程序节点上指定用户名是“kubelet-bootstrap”,却收到错误提示用户“system:anonymous”?

error: failed to run Kubelet: cannot create certificate signing request: certificatesigningrequests.certificates.k8s.io is forbidden: User "system:anonymous" cannot create certificatesigningrequests.certificates.k8s.io at the cluster scope



kubernetes版本v1.8.3

下面是我的配置

apiserver:
/usr/local/bin/kube-apiserver --etcd-servers=http://127.0.0.1:2379
--admission-control=NamespaceLifecycle,LimitRanger,ServiceAccount,ResourceQuota
--service-account-key-file=/srv/kubernetes/pubkey.pem
--service-cluster-ip-range=10.96.0.0/16
--allow-privileged=true
--authorization-mode=RBAC
--enable-bootstrap-token-auth=true
--token-auth-file=/var/lib/kubernetes/bootstrap.csv
--client-ca-file=/var/lib/kubernetes/cacert.pem
--tls-cert-file=/var/lib/kubernetes/servercert.pem
--tls-private-key-file=/var/lib/kubernetes/serverkey.pem
--address=172.18.11.249
--insecure-bind-address=127.0.0.1
--advertise-address=172.18.11.249
--audit-log-maxage=30
--audit-log-maxsize=100
--audit-log-path=/var/log/kube-apiserver.log
--v=4
1>>/var/log/kube-apiserver.log 2>&1

/var/lib/kubernetes/bootstrap.csv
0d681e2438667d2b5236ad7385d80ddc,kubelet-bootstrap,10001,"system:kubelet-bootstrap"


工作节点:
/usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubelet/bootstrap.kubeconfig.yaml 
--pod-manifest-path=/etc/kubernetes/manifests
--node-labels=node-role.kubernetes.io/worker=
--node-ip=172.18.10.16
--allow-privileged
--v=4

/etc/kubelet/bootstrap.kubeconfig.yaml
apiVersion: v1
clusters:
- cluster:
server: https://172.18.11.249:6443/
name: myk8s
contexts:
- context:
cluster: myk8s
name: myk8s
current-context: myk8s
kind: Config
preferences: {}
users:
- name: kubelet-bootstrap
user:
as-user-extra: {}
token: 0d681e2438667d2b5236ad7385d80ddc

来自工作节点的日志

I0821 08:49:50.916993 6232 bootstrap.go:57] Using bootstrap kubeconfig to generate TLS client cert, key and kubeconfig file

error: failed to run Kubelet: cannot create certificate signing request: certificatesigningrequests.certificates.k8s.io is forbidden: User "system:anonymous" cannot create certificatesigningrequests.certificates.k8s.io at the cluster scope



从apiserver记录

I0821 08:05:05.726968 5 rbac.go:116] RBAC DENY: user "system:anonymous" groups ["system:unauthenticated"] cannot "create" resource "certificatesigningrequests.certificates.k8s.io" cluster-wide I0821 08:05:05.727015 5 authorization.go:59] Forbidden: "/apis/certificates.k8s.io/v1beta1/certificatesigningrequests", Reason: ""



谢谢您的帮助

最佳答案

bootstrap.kubeconfig.yaml中的 token 格式看起来与kubeadm生成的常规 token 不同。

根据Authenticating with Bootstrap Tokens文章:

Token Format

Bootstrap Tokens take the form of abcdef.0123456789abcdef. More formally, they must match the regular expression [a-z0-9]{6}.[a-z0-9]{16}.

The first part of the token is the “Token ID” and is considered public information. It is used when referring to a token without leaking the secret part used for authentication. The second part is the “Token Secret” and should only be shared with trusted parties.



考虑阅读 previousthis文章,以了解如何实现Bootstrap Token想法。

关于kubernetes - TLS引导(--token-auth-file),用户 “system:anonymous”无法创建证书签名请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51945435/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com