ClusterRole

ClusterRole 是 PolicyRule 的集群级逻辑分组,可被 RoleBinding 或 ClusterRoleBinding 以一个单元的形式引用。

apiVersion: rbac.authorization.k8s.io/v1

import "k8s.io/api/rbac/v1"

ClusterRole

ClusterRole 是 PolicyRule 的集群级逻辑分组,可被 RoleBinding 或 ClusterRoleBinding 以一个单元的形式引用。


  • apiVersion: rbac.authorization.k8s.io/v1

  • kind: ClusterRole

  • metadata (ObjectMeta)

    标准对象的元数据。

  • aggregationRule (AggregationRule)

    AggregationRule 是一个可选字段,用于描述如何构建此 ClusterRole 的规则。如果设置了 AggregationRule,则这些规则由控制器管理,对规则的直接修改会被控制器覆盖。

    AggregationRule 描述了如何定位要聚合到 ClusterRole 中的 ClusterRole

    • aggregationRule.clusterRoleSelectors ([]LabelSelector)

      原子:将在合并期间被替换

      ClusterRoleSelectors 包含一个选择器列表,用于查找 ClusterRole 并创建规则。如果任何选择器匹配,则该 ClusterRole 的权限将被添加。

  • rules ([]PolicyRule)

    原子:将在合并期间被替换

    Rules 包含了此 ClusterRole 的所有 PolicyRule。

    PolicyRule 包含了描述策略规则的信息,但不包含关于该规则适用于谁或适用于哪个命名空间的信息。

    • rules.apiGroups ([]string)

      原子:将在合并期间被替换

      APIGroups 是包含资源的 API 组名称。如果指定了多个 API 组,则针对任何 API 组中列出的资源所请求的任何操作都将被允许。"" 代表核心 API 组,"*" 代表所有 API 组。

    • rules.resources ([]string)

      原子:将在合并期间被替换

      Resources 是此规则适用的资源列表。'*' 代表所有资源。

    • rules.verbs ([]string), required

      原子:将在合并期间被替换

      Verbs 是适用于此规则中包含的所有 ResourceKinds 的动词列表。'*' 代表所有动词。

    • rules.resourceNames ([]string)

      原子:将在合并期间被替换

      ResourceNames 是规则适用的名称的白名单。一个空集意味着允许所有内容。

    • rules.nonResourceURLs ([]string)

      原子:将在合并期间被替换

      NonResourceURLs 是一组用户应有权访问的部分 URL。允许使用 '*',但仅作为路径中完整且最终的步骤。由于非资源 URL 不区分命名空间,因此该字段仅适用于被 ClusterRoleBinding 引用的 ClusterRole。规则要么应用于 API 资源(如 "pods" 或 "secrets"),要么应用于非资源 URL 路径(如 "/api"),但不能同时应用于两者。

ClusterRoleList

ClusterRoleList 是 ClusterRole 的集合


  • apiVersion: rbac.authorization.k8s.io/v1

  • kind: ClusterRoleList

  • metadata (ListMeta)

    标准对象的元数据。

  • items ([]ClusterRole), required

    Items 是 ClusterRole 的列表

操作


get 读取指定的 ClusterRole

HTTP 请求

GET /apis/rbac.authorization.k8s.io/v1/clusterroles/{name}

Parameters

  • name (在路径中): string, 必需

    ClusterRole 的名称

  • pretty (在查询中): string

    pretty

响应

200 (ClusterRole): OK

401: 未授权

list 列出或监听 ClusterRole 类型的对象

HTTP 请求

GET /apis/rbac.authorization.k8s.io/v1/clusterroles

Parameters

响应

200 (ClusterRoleList): OK

401: 未授权

create 创建一个 ClusterRole

HTTP 请求

POST /apis/rbac.authorization.k8s.io/v1/clusterroles

Parameters

响应

200 (ClusterRole): OK

201 (ClusterRole): Created

202 (ClusterRole): Accepted

401: 未授权

update 替换指定的 ClusterRole

HTTP 请求

PUT /apis/rbac.authorization.k8s.io/v1/clusterroles/{name}

Parameters

  • name (在路径中): string, 必需

    ClusterRole 的名称

  • body: ClusterRole, required

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • pretty (在查询中): string

    pretty

响应

200 (ClusterRole): OK

201 (ClusterRole): Created

401: 未授权

patch 部分更新指定的 ClusterRole

HTTP 请求

PATCH /apis/rbac.authorization.k8s.io/v1/clusterroles/{name}

Parameters

  • name (在路径中): string, 必需

    ClusterRole 的名称

  • body: Patch, 必需

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • force (in query): boolean

    force

  • pretty (在查询中): string

    pretty

响应

200 (ClusterRole): OK

201 (ClusterRole): Created

401: 未授权

delete 删除一个 ClusterRole

HTTP 请求

DELETE /apis/rbac.authorization.k8s.io/v1/clusterroles/{name}

Parameters

响应

200 (Status): 确定

202 (Status): 已接受

401: 未授权

deletecollection 删除 ClusterRole 的集合

HTTP 请求

DELETE /apis/rbac.authorization.k8s.io/v1/clusterroles

Parameters

响应

200 (Status): 确定

401: 未授权


上次修改时间:2025 年 4 月 9 日下午 6:36 PST:更新 v1.32 的 API 参考文档 (a3b579d035)

本页面是自动生成的。

如果您打算报告此页面的问题,请在您的问题描述中提及该页面是自动生成的。修复可能需要在 Kubernetes 项目的其他地方进行。