---
api_metadata:
apiVersion: "rbac.authorization.k8s.io/v1"
import: "k8s.io/api/rbac/v1"
kind: "RoleBinding"
content_type: "api_reference"
description: "RoleBinding 引用一个角色,但不包含它。"
title: "RoleBinding"
weight: 8
auto_generated: false
---
`apiVersion: rbac.authorization.k8s.io/v1`
`import "k8s.io/api/rbac/v1"`
## RoleBinding {#RoleBinding}
RoleBinding 引用一个角色,但不包含它。
RoleBinding 可以引用相同命名空间中的 Role 或全局命名空间中的 ClusterRole。
RoleBinding 通过 Subjects 和所在的命名空间信息添加主体信息。
处于给定命名空间中的 RoleBinding 仅在该命名空间中有效。
- **apiVersion**: rbac.authorization.k8s.io/v1
- **kind**: RoleBinding
- **metadata** (}}">ObjectMeta)
标准的对象元数据。
- **roleRef** (RoleRef),必需
roleRef 可以引用当前命名空间中的 Role 或全局命名空间中的 ClusterRole。
如果无法解析 roleRef,则 Authorizer 必定返回一个错误。
**roleRef 包含指向正被使用的角色的信息。**
- **roleRef.apiGroup** (string),必需
apiGroup 是被引用资源的组
- **roleRef.kind** (string),必需
kind 是被引用的资源的类别
- **roleRef.name** (string),必需
name 是被引用的资源的名称
- **subjects** ([]Subject)
subjects 包含角色所适用的对象的引用。
**Subject 包含对角色绑定所适用的对象或用户标识的引用。其中可以包含直接 API 对象的引用或非对象(如用户名和组名)的值。**
- **subjects.kind** (string),必需
被引用的对象的类别。
这个 API 组定义的值是 `User`、`Group` 和 `ServiceAccount`。
如果 Authorizer 无法识别类别值,则 Authorizer 应报告一个错误。
- **subjects.name** (string),必需
被引用的对象的名称。
- **subjects.apiGroup** (string)
apiGroup 包含被引用主体的 API 组。
对于 ServiceAccount 主体默认为 ""。
对于 User 和 Group 主体,默认为 "rbac.authorization.k8s.io"。
- **subjects.namespace** (string)
被引用的对象的命名空间。
如果对象类别是 “User” 或 “Group” 等非命名空间作用域的对象且该值不为空,
则 Authorizer 应报告一个错误。
## RoleBindingList {#RoleBindingList}
RoleBindingList 是 RoleBinding 的集合。
- **apiVersion**: rbac.authorization.k8s.io/v1
- **kind**: RoleBindingList
- **metadata** (}}">ListMeta)
标准的对象元数据。
- **items** ([]}}">RoleBinding),必需
items 是 RoleBinding 的列表。
## 操作 {#Operations}
### `get` 读取指定的 RoleBinding
#### HTTP 请求
GET /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings/{name}
#### 参数
- **name** (**路径参数**): string,必需
RoleBinding 的名称
- **namespace** (**路径参数**): string,必需
}}">namespace
- **pretty** (**查询参数**): string
}}">pretty
#### 响应
200 (}}">RoleBinding): OK
401: Unauthorized
### `list` 列出或观测类别为 RoleBinding 的对象
#### HTTP 请求
GET /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings
#### 参数
- **namespace** (**路径参数**): string,必需
}}">namespace
- **allowWatchBookmarks** (**查询参数**): boolean
}}">allowWatchBookmarks
- **continue** (**查询参数**): string
}}">continue
- **fieldSelector** (**查询参数**): string
}}">fieldSelector
- **labelSelector** (**查询参数**): string
}}">labelSelector
- **limit** (**查询参数**): integer
}}">limit
- **pretty** (**查询参数**): string
}}">pretty
- **resourceVersion** (**查询参数**): string
}}">resourceVersion
- **resourceVersionMatch** (**查询参数**): string
}}">resourceVersionMatch
- **timeoutSeconds** (**查询参数**): integer
}}">timeoutSeconds
- **watch** (**查询参数**): boolean
}}">watch
#### 响应
200 (}}">RoleBindingList): OK
401: Unauthorized
### `list` 列出或观测类别为 RoleBinding 的对象
#### HTTP 请求
GET /apis/rbac.authorization.k8s.io/v1/rolebindings
#### 参数
- **allowWatchBookmarks** (**查询参数**): boolean
}}">allowWatchBookmarks
- **continue** (**查询参数**): string
}}">continue
- **fieldSelector** (**查询参数**): string
}}">fieldSelector
- **labelSelector** (**查询参数**): string
}}">labelSelector
- **limit** (**查询参数**): integer
}}">limit
- **pretty** (**查询参数**): string
}}">pretty
- **resourceVersion** (**查询参数**): string
}}">resourceVersion
- **resourceVersionMatch** (**查询参数**): string
}}">resourceVersionMatch
- **timeoutSeconds** (**查询参数**): integer
}}">timeoutSeconds
- **watch** (**查询参数**): boolean
}}">watch
#### 响应
200 (}}">RoleBindingList): OK
401: Unauthorized
### `create` 创建 RoleBinding
#### HTTP 请求
POST /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings
#### 参数
- **namespace** (**路径参数**): string,必需
}}">namespace
- **body**: }}">RoleBinding,必需
- **dryRun** (**查询参数**): string
}}">dryRun
- **fieldManager** (**查询参数**): string
}}">fieldManager
- **fieldValidation** (**查询参数**): string
}}">fieldValidation
- **pretty** (**查询参数**): string
}}">pretty
#### 响应
200 (}}">RoleBinding): OK
201 (}}">RoleBinding): Created
202 (}}">RoleBinding): Accepted
401: Unauthorized
### `update` 替换指定的 RoleBinding
#### HTTP 请求
PUT /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings/{name}
#### 参数
- **name** (**路径参数**): string,必需
RoleBinding 的名称
- **namespace** (**路径参数**): string,必需
}}">namespace
- **body**: }}">RoleBinding,必需
- **dryRun** (**查询参数**): string
}}">dryRun
- **fieldManager** (**查询参数**): string
}}">fieldManager
- **fieldValidation** (**查询参数**): string
}}">fieldValidation
- **pretty** (**查询参数**): string
}}">pretty
#### 响应
200 (}}">RoleBinding): OK
201 (}}">RoleBinding): Created
401: Unauthorized
### `patch` 部分更新指定的 RoleBinding
#### HTTP 请求
PATCH /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings/{name}
#### 参数
- **name** (**路径参数**): string,必需
RoleBinding 的名称
- **namespace** (**路径参数**): string,必需
}}">namespace
- **body**: }}">Patch,必需
- **dryRun** (**查询参数**): string
}}">dryRun
- **fieldManager** (**查询参数**): string
}}">fieldManager
- **fieldValidation** (**查询参数**): string
}}">fieldValidation
- **force** (**查询参数**): boolean
}}">force
- **pretty** (**查询参数**): string
}}">pretty
#### 响应
200 (}}">RoleBinding): OK
201 (}}">RoleBinding): Created
401: Unauthorized
### `delete` 删除 RoleBinding
#### HTTP 请求
DELETE /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings/{name}
#### 参数
- **name** (**路径参数**): string,必需
RoleBinding 的名称
- **namespace** (**路径参数**): string,必需
}}">namespace
- **body**: }}">DeleteOptions
- **dryRun** (**查询参数**): string
}}">dryRun
- **gracePeriodSeconds** (**查询参数**): integer
}}">gracePeriodSeconds
- **pretty** (**查询参数**): string
}}">pretty
- **propagationPolicy** (**查询参数**): string
}}">propagationPolicy
#### 响应
200 (}}">Status): OK
202 (}}">Status): Accepted
401: Unauthorized
### `deletecollection` 删除 RoleBinding 的集合
#### HTTP 请求
DELETE /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings
#### 参数
- **namespace** (**路径参数**): string,必需
}}">namespace
- **body**: }}">DeleteOptions
- **continue** (**查询参数**): string
}}">continue
- **dryRun** (**查询参数**): string
}}">dryRun
- **fieldSelector** (**查询参数**): string
}}">fieldSelector
- **gracePeriodSeconds** (**查询参数**): integer
}}">gracePeriodSeconds
- **labelSelector** (**查询参数**): string
}}">labelSelector
- **limit** (**查询参数**): integer
}}">limit
- **pretty** (**查询参数**): string
}}">pretty
- **propagationPolicy** (**查询参数**): string
}}">propagationPolicy
- **resourceVersion** (**查询参数**): string
}}">resourceVersion
- **resourceVersionMatch** (**查询参数**): string
}}">resourceVersionMatch
- **timeoutSeconds** (**查询参数**): integer
}}">timeoutSeconds
#### 响应
200 (}}">Status): OK
401: Unauthorized