gpt4 book ai didi

kubernetes 系统 :discovery role mechanism

转载 作者:行者123 更新时间:2023-12-02 11:55:21 25 4
gpt4 key购买 nike

我想了解 system:discovery 角色在 kubernetes 中是如何工作的。我能够在下面看到非资源 url 是 system:discovery 角色中包含的特权

root@kubemas:~# kubectl describe clusterrole system:discovery
Name: system:discovery
Labels: kubernetes.io/bootstrapping=rbac-defaults
Annotations: rbac.authorization.kubernetes.io/autoupdate: true
PolicyRule:
Resources Non-Resource URLs Resource Names Verbs
--------- ----------------- -------------- -----
[/api/*] [] [get]
[/api] [] [get]
[/apis/*] [] [get]
[/apis] [] [get]
[/healthz] [] [get]
[/livez] [] [get]
[/openapi/*] [] [get]
[/openapi] [] [get]
[/readyz] [] [get]
[/version/] [] [get]
[/version] [] [get]

来自 clusterrolebinding 描述,

root@kubemas:~# kubectl describe clusterrolebindings.rbac.authorization.k8s.io system:discovery
Name: system:discovery
Labels: kubernetes.io/bootstrapping=rbac-defaults
Annotations: rbac.authorization.kubernetes.io/autoupdate: true
Role:
Kind: ClusterRole
Name: system:discovery
Subjects:
Kind Name Namespace
---- ---- ---------
Group system:authenticated

我只能看到 system:authenticated 组可以访问非资源 url。如果我执行以下命令,我可以理解,请求用户是 system:anonymous,属于 system:unathenticated 组,因此不允许看到输出

root@kubemas:~# curl -k https://192.168.56.101:6443/api
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {

},
"status": "Failure",
"message": "forbidden: User \"system:anonymous\" cannot get path \"/api\"",
"reason": "Forbidden",
"details": {

},
"code": 403

但是我期望下面的请求会得到同样的结果,我正在尝试获取也是非资源 url 的 kubernetes 版本。但是我能够无错误地获得版本输出。所以这是如何工作的。我是误解了这个机制?

root@kubemas:~# curl -k https://192.168.56.101:6443/version
{
"major": "1",
"minor": "18",
"gitVersion": "v1.18.3",
"gitCommit": "2e7996e3e2712684bc73f0dec0200d64eec7fe40",
"gitTreeState": "clean",
"buildDate": "2020-05-20T12:43:34Z",
"goVersion": "go1.13.9",
"compiler": "gc",
"platform": "linux/amd64"
}root@kubemas:~#

最佳答案

system:public-info-viewer 是可以访问 /version 的集群角色。此 clusterole 绑定(bind)到 system:authenticatedsystem:unauthenticated 组。由于它绑定(bind)到 system:unauthenticated 组,您可以访问它。

来自docs

This clusterole Allows read-only access to non-sensitive information about the cluster. Introduced in Kubernetes v1.14.

kubectl describe clusterrole system:public-info-viewer
Name: system:public-info-viewer
Labels: kubernetes.io/bootstrapping=rbac-defaults
Annotations: rbac.authorization.kubernetes.io/autoupdate: true
PolicyRule:
Resources Non-Resource URLs Resource Names Verbs
--------- ----------------- -------------- -----
[/healthz] [] [get]
[/livez] [] [get]
[/readyz] [] [get]
[/version/] [] [get]
[/version] [] [get]

关于kubernetes 系统 :discovery role mechanism,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62070263/

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