角色

Role 是 PolicyRule 的一个命名空间、逻辑分组,可以作为一个单元被 RoleBinding 引用。

apiVersion: rbac.authorization.k8s.io/v1

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

角色

Role 是 PolicyRule 的一个命名空间、逻辑分组,可以作为一个单元被 RoleBinding 引用。


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

  • kind: Role

  • metadata (ObjectMeta)

    标准对象的元数据。

  • rules ([]PolicyRule)

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

    Rules 包含此 Role 的所有 PolicyRule。

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

    • rules.apiGroups ([]string)

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

      APIGroups 是包含资源的 APIGroup 的名称。如果指定了多个 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 引用的 ClusterRoles。规则可以应用于 API 资源(例如“pods”或“secrets”)或非资源 URL 路径(例如“/api”),但不能同时应用于两者。

RoleList

RoleList 是 Roles 的集合。


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

  • kind: RoleList

  • metadata (ListMeta)

    标准对象的元数据。

  • items ([]Role), required

    Items 是 Roles 的列表。

操作


get 读取指定的 Role

HTTP 请求

GET /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/roles/{name}

参数

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

    Role 的名称

  • namespace (在路径中): string,必填

    命名空间

  • pretty (在查询中): string

    pretty

响应

200 (Role): OK

401: 未授权

list 列出或监视 Role 类型的对象

HTTP 请求

GET /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/roles

参数

响应

200 (RoleList): OK

401: 未授权

list 列出或监视 Role 类型的对象

HTTP 请求

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

参数

响应

200 (RoleList): OK

401: 未授权

create 创建一个 Role

HTTP 请求

POST /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/roles

参数

响应

200 (Role): OK

201 (Role): Created

202 (Role): Accepted

401: 未授权

update 替换指定的 Role

HTTP 请求

PUT /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/roles/{name}

参数

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

    Role 的名称

  • namespace (在路径中): string,必填

    命名空间

  • body: Role, required

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • pretty (在查询中): string

    pretty

响应

200 (Role): OK

201 (Role): Created

401: 未授权

patch 部分更新指定的 Role

HTTP 请求

PATCH /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/roles/{name}

参数

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

    Role 的名称

  • namespace (在路径中): string,必填

    命名空间

  • body: Patch,必需

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • force (在查询中): boolean

    force

  • pretty (在查询中): string

    pretty

响应

200 (Role): OK

201 (Role): Created

401: 未授权

delete 删除一个 Role

HTTP 请求

DELETE /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/roles/{name}

参数

响应

200 (Status): OK

202 (Status): 已接受

401: 未授权

deletecollection 删除 Role 的集合

HTTP 请求

DELETE /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/roles

参数

响应

200 (Status): OK

401: 未授权

本页面是自动生成的。

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

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