RoleBinding

RoleBinding 引用了一个角色,但自身不包含它。

apiVersion: rbac.authorization.k8s.io/v1

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

RoleBinding

RoleBinding 引用了一个角色,但自身不包含它。它可以引用同一命名空间下的 Role 或全局命名空间下的 ClusterRole。它通过 Subjects 添加了“谁”的信息,并通过其所在的命名空间添加了命名空间信息。给定命名空间中的 RoleBindings 仅在该命名空间中生效。


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

  • kind: RoleBinding

  • metadata (ObjectMeta)

    标准对象的元数据。

  • roleRef (RoleRef),必需

    RoleRef 可以引用当前命名空间中的 Role 或全局命名空间中的 ClusterRole。如果 RoleRef 无法解析,授权器必须返回错误。此字段不可变。

    RoleRef 包含指向正在使用的角色的信息

    • roleRef.apiGroup (string),必需

      APIGroup 是被引用资源的组

    • roleRef.kind (string),必需

      Kind 是被引用资源的类型

    • roleRef.name (string),必需

      Name 是被引用资源的名称

  • subjects ([]Subject)

    原子操作:在合并时将被替换

    Subjects 包含该角色适用于的对象的引用。

    Subject 包含角色绑定适用的对象或用户身份的引用。它可以是一个直接的 API 对象引用,也可以是非对象的值,如用户和组名。

    • subjects.kind (string),必需

      被引用对象的 Kind。此 API 组定义的值包括 "User"、"Group" 和 "ServiceAccount"。如果授权器无法识别 Kind 值,则应报告错误。

    • subjects.name (string),必需

      被引用对象的名称。

    • subjects.apiGroup (string)

      APIGroup 保存被引用 subject 的 API 组。对于 ServiceAccount subjects,默认为 ""。对于 User 和 Group subjects,默认为 "rbac.authorization.k8s.io"。

    • subjects.namespace (string)

      被引用对象的命名空间。如果对象类型是非命名空间类型,如 "User" 或 "Group",并且此值不为空,则授权器应报告错误。

RoleBindingList

RoleBindingList 是 RoleBinding 的集合


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

  • kind: RoleBindingList

  • metadata (ListMeta)

    标准对象的元数据。

  • items ([]RoleBinding),必需

    Items 是 RoleBinding 的列表

操作


get 读取指定的 RoleBinding

HTTP 请求

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

参数

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

    RoleBinding 的名称

  • namespace (路径中): string,必需

    命名空间

  • pretty (查询参数中): string

    pretty

响应

200 (RoleBinding): OK

401: 未授权

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

HTTP 请求

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

参数

响应

200 (RoleBindingList): OK

401: 未授权

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

HTTP 请求

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

参数

响应

200 (RoleBindingList): OK

401: 未授权

create 创建一个 RoleBinding

HTTP 请求

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

参数

响应

200 (RoleBinding): OK

201 (RoleBinding): 已创建

202 (RoleBinding): 已接受

401: 未授权

update 替换指定的 RoleBinding

HTTP 请求

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

参数

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

    RoleBinding 的名称

  • namespace (路径中): string,必需

    命名空间

  • body: RoleBinding,必需

  • dryRun (查询参数中): string

    dryRun

  • fieldManager (查询参数中): string

    fieldManager

  • fieldValidation (查询参数中): string

    fieldValidation

  • pretty (查询参数中): string

    pretty

响应

200 (RoleBinding): OK

201 (RoleBinding): 已创建

401: 未授权

patch 部分更新指定的 RoleBinding

HTTP 请求

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

参数

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

    RoleBinding 的名称

  • namespace (路径中): string,必需

    命名空间

  • body: Patch,必需

  • dryRun (查询参数中): string

    dryRun

  • fieldManager (查询参数中): string

    fieldManager

  • fieldValidation (查询参数中): string

    fieldValidation

  • force (查询参数中): boolean

    force

  • pretty (查询参数中): string

    pretty

响应

200 (RoleBinding): OK

201 (RoleBinding): 已创建

401: 未授权

delete 删除一个 RoleBinding

HTTP 请求

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

参数

响应

200 (Status): OK

202 (Status): 已接受

401: 未授权

deletecollection 删除 RoleBinding 集合

HTTP 请求

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

参数

响应

200 (Status): OK

401: 未授权

本页是自动生成的。

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

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