Kubernetes:角色与ClusterRole

Jor*_*rdi 18 kubernetes

a Role或a 之间的区别是ClusterRole什么?

我什么时候应该创建一个或另一个?

我不太清楚它们之间的区别.

her*_*erm 26

文档:

角色只能用于授予对单个命名空间内的资源的访问权限.

示例:列出命名空间中的所有窗格

ClusterRole可用于授予与角色相同的权限,但由于它们是群集范围的,因此它们还可用于授予对以下内容的访问权限:

cluster-scoped resources (like nodes)
non-resource endpoints (like “/healthz”)
namespaced resources (like pods) across all namespaces (needed to run kubectl get pods --all-namespaces, for example)
Run Code Online (Sandbox Code Playgroud)

示例:列出所有命名空间中的所有pod.获取所有节点和公共IP的列表.