--- api_metadata: apiVersion: "rbac.authorization.k8s.io/v1" import: "k8s.io/api/rbac/v1" kind: "ClusterRoleBinding" content_type: "api_reference" description: "ClusterRoleBinding 引用 ClusterRole,但不包含它。" title: "ClusterRoleBinding" weight: 6 auto_generated: false --- `apiVersion: rbac.authorization.k8s.io/v1` `import "k8s.io/api/rbac/v1"` ## ClusterRoleBinding {#ClusterRoleBinding} ClusterRoleBinding 引用 ClusterRole,但不包含它。 它可以引用全局命名空间中的 ClusterRole,并通过 Subject 添加主体信息。
- **apiVersion**: rbac.authorization.k8s.io/v1 - **kind**: ClusterRoleBinding - **metadata** (}}">ObjectMeta) 标准对象的元数据。 - **roleRef** (RoleRef),必需 RoleRef 只能引用全局命名空间中的 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 应报告一个错误。 ## ClusterRoleBindingList {#ClusterRoleBindingList} ClusterRoleBindingList 是 ClusterRoleBinding 的集合。
- **apiVersion**: rbac.authorization.k8s.io/v1 - **kind**: ClusterRoleBindingList - **metadata** (}}">ListMeta) 标准的对象元数据。 - **items** ([]}}">ClusterRoleBinding),必需 items 是 ClusterRoleBindings 的列表。 ## 操作 {#Operations}
### `get` 读取指定的 ClusterRoleBinding #### HTTP 请求 GET /apis/rbac.authorization.k8s.io/v1/clusterrolebindings/{name} #### 参数 - **name** (**路径参数**): string,必需 ClusterRoleBinding 的名称 - **pretty** (**查询参数**): string }}">pretty #### 响应 200 (}}">ClusterRoleBinding): OK 401: Unauthorized ### `list` 列出或观测类别为 ClusterRoleBinding 的对象 #### HTTP 请求 GET /apis/rbac.authorization.k8s.io/v1/clusterrolebindings #### 参数 - **allowWatchBookmarks** (**查询参数**): boolean }}">allowWatchBookmarks - **continue** (**查询参数**): string }}">continue - **fieldSelector** (**查询参数**): string }}">fieldSelector - **labelSelector** (**查询参数**): string }}">labelSelector - **limit** (**查询参数**): integer }}">limit - **pretty** (**查询参数**): string }}">pretty - **resourceVersion** (**查询参数**): string }}">resourceVersion - **resourceVersionMatch** (**查询参数**): string }}">resourceVersionMatch - **sendInitialEvents** (**查询参数**): boolean }}">sendInitialEvents - **timeoutSeconds** (**查询参数**): integer }}">timeoutSeconds - **watch** (**查询参数**): boolean }}">watch #### 响应 200 (}}">ClusterRoleBindingList): OK 401: Unauthorized ### `create` 创建 ClusterRoleBinding #### HTTP 请求 POST /apis/rbac.authorization.k8s.io/v1/clusterrolebindings #### 参数 - **body**: }}">ClusterRoleBinding,必需 - **dryRun** (**查询参数**): string }}">dryRun - **fieldManager** (**查询参数**): string }}">fieldManager - **fieldValidation** (**查询参数**): string }}">fieldValidation - **pretty** (**查询参数**): string }}">pretty #### 响应 200 (}}">ClusterRoleBinding): OK 201 (}}">ClusterRoleBinding): Created 202 (}}">ClusterRoleBinding): Accepted 401: Unauthorized ### `update` 替换指定的 ClusterRoleBinding #### HTTP 请求 PUT /apis/rbac.authorization.k8s.io/v1/clusterrolebindings/{name} #### 参数 - **name** (**路径参数**): string,必需 ClusterRoleBinding 的名称 - **body**: }}">ClusterRoleBinding,必需 - **dryRun** (**查询参数**): string }}">dryRun - **fieldManager** (**查询参数**): string }}">fieldManager - **fieldValidation** (**查询参数**): string }}">fieldValidation - **pretty** (**查询参数**): string }}">pretty #### 响应 200 (}}">ClusterRoleBinding): OK 201 (}}">ClusterRoleBinding): Created 401: Unauthorized ### `patch` 部分更新指定的 ClusterRoleBinding #### HTTP 请求 PATCH /apis/rbac.authorization.k8s.io/v1/clusterrolebindings/{name} #### 参数 - **name** (**路径参数**): string,必需 ClusterRoleBinding 的名称 - **body**: }}">Patch,必需 - **dryRun** (**查询参数**): string }}">dryRun - **fieldManager** (**查询参数**): string }}">fieldManager - **fieldValidation** (**查询参数**): string }}">fieldValidation - **force** (**查询参数**): boolean }}">force - **pretty** (**查询参数**): string }}">pretty #### 响应 200 (}}">ClusterRoleBinding): OK 201 (}}">ClusterRoleBinding): Created 401: Unauthorized ### `delete` 删除 ClusterRoleBinding #### HTTP 请求 DELETE /apis/rbac.authorization.k8s.io/v1/clusterrolebindings/{name} #### 参数 - **name** (**路径参数**): string,必需 ClusterRoleBinding 的名称 - **body**: }}">DeleteOptions - **dryRun** (**查询参数**): string }}">dryRun - **gracePeriodSeconds** (**查询参数**): integer }}">gracePeriodSeconds - **pretty** (**查询参数**): string }}">pretty - **propagationPolicy** (**查询参数**): string }}">propagationPolicy #### 响应 200 (}}">Status): OK 202 (}}">Status): Accepted 401: Unauthorized ### `deletecollection` 删除 ClusterRoleBinding 的集合 #### HTTP 请求 DELETE /apis/rbac.authorization.k8s.io/v1/clusterrolebindings #### 参数 - **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 - **sendInitialEvents** (**查询参数**): boolean }}">sendInitialEvents - **timeoutSeconds** (**查询参数**): integer }}">timeoutSeconds #### 响应 200 (}}">Status): OK 401: Unauthorized