这是本节的多页打印视图。 点击此处打印.

返回本页常规视图.

Kubernetes API

Kubernetes API 是通过 RESTful 接口提供 Kubernetes 功能服务并负责集群状态存储的应用程序。

Kubernetes 资源和"意向记录"都是作为 API 对象储存的,并可以通过调用 RESTful 风格的 API 进行修改。 API 允许以声明方式管理配置。 用户可以直接和 Kubernetes API 交互,也可以通过 kubectl 这样的工具进行交互。 核心的 Kubernetes API 是很灵活的,可以扩展以支持定制资源。

1 - 工作负载资源

1.1 - PriorityClass

PriorityClass 定义了从优先级类名到优先级数值的映射。

apiVersion: scheduling.k8s.io/v1

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

PriorityClass

PriorityClass 定义了从优先级类名到优先级数值的映射。 该值可以是任何有效的整数。


  • apiVersion: scheduling.k8s.io/v1
  • kind: PriorityClass
  • value (int32),必需

    此优先级的值。这是 Pod 在其 Pod 规约中有此类名称时收到的实际优先级。

  • description (string)

    description 是一个任意字符串,通常提供有关何时应使用此优先级的指南。

  • globalDefault (boolean)

    globalDefault 指定是否应将此 PriorityClass 视为没有任何优先级类的 pod 的默认优先级。 只有一个 PriorityClass 可以标记为 globalDefault。 但是,如果存在多个 PriorityClasses 且其 globalDefault 字段设置为 true, 则将使用此类全局默认 PriorityClasses 的最小值作为默认优先级。

  • preemptionPolicy (string)

    PreemptionPolicy 是抢占优先级较低的 Pod 的策略。 可选值:Never、PreemptLowerPriority。 如果未设置,则默认为 PreemptLowerPriority。

PriorityClassList

PriorityClassList 是优先级类的集合。


  • apiVersion: scheduling.k8s.io/v1
  • kind: PriorityClassList
  • items ([]PriorityClass),必需

    items 是 PriorityClasses 的列表

操作


get 读取特定的 PriorityClass

HTTP 请求

GET /apis/scheduling.k8s.io/v1/priorityclasses/{name}

参数

  • name路径参数): string,必需

    PriorityClass 名称

  • pretty查询参数):string

    pretty

响应

200 (PriorityClass): OK

401: Unauthorized

list 列出或观察 PriorityClass类的对象

HTTP 请求

GET /apis/scheduling.k8s.io/v1/priorityclasses

参数

  • continue查询参数):string

    continue

  • limit查询参数):integer

    limit

  • pretty查询参数):string

    pretty

  • watch查询参数):boolean

    watch

响应

200 (PriorityClassList): OK

401: Unauthorized

create 创建一个 PriorityClass

HTTP 请求

POST /apis/scheduling.k8s.io/v1/priorityclasses

参数

  • dryRun查询参数):string

    dryRun

  • pretty查询参数):string

    pretty

响应

200 (PriorityClass): OK

201 (PriorityClass): Created

202 (PriorityClass): Accepted

401: Unauthorized

update 替换指定的 PriorityClass

HTTP 请求

PUT /apis/scheduling.k8s.io/v1/priorityclasses/{name}

参数

  • name路径参数): string,必需

    PriorityClass 名称

  • dryRun查询参数):string

    dryRun

  • pretty查询参数):string

    pretty

响应

200 (PriorityClass): OK

201 (PriorityClass): Created

401: Unauthorized

patch 部分更新特定的 PriorityClass

HTTP 请求

PATCH /apis/scheduling.k8s.io/v1/priorityclasses/{name}

参数

  • name路径参数): string,必须

    PriorityClass 名称

  • dryRun查询参数):string

    dryRun

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (PriorityClass): OK

201 (PriorityClass): Created

401: Unauthorized

delete 删除一个 PriorityClass

HTTP 请求

DELETE /apis/scheduling.k8s.io/v1/priorityclasses/{name}

参数

  • name路径参数): string,必需

    PriorityClass 名称。

  • dryRun查询参数):string

    dryRun

  • pretty查询参数):string

    pretty

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 PriorityClass 集合

HTTP 请求

DELETE /apis/scheduling.k8s.io/v1/priorityclasses

参数

  • continue查询参数):string

    continue

  • dryRun查询参数):string

    dryRun

  • limit查询参数):integer

    limit

  • pretty查询参数):string

    pretty

响应

200 (Status): OK

401: Unauthorized

2 - Service 资源

3 - 配置和存储资源

4 - 身份认证资源

4.1 - ServiceAccount

ServiceAccount 将以下内容绑定在一起:1. 用户可以理解的名称,也可能是外围系统理解的身份标识 2. 可以验证和授权的主体 3. 一组 secret。

apiVersion: v1

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

ServiceAccount

ServiceAccount 将以下内容绑定在一起:

  • 用户可以理解的名称,也可能是外围系统理解的身份标识
  • 可以验证和授权的主体
  • 一组 secret

ServiceAccountList

ServiceAccountList 是 ServiceAccount 对象的列表


操作


get 读取指定的 ServiceAccount

HTTP 请求

GET /api/v1/namespaces/{namespace}/serviceaccounts/{name}

参数

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

    ServiceAccount 的名称

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

    namespace

  • pretty (查询字符串): string

    pretty

响应

200 (ServiceAccount): OK

401: Unauthorized

list 列出或监控 ServiceAccount 类型的对象

HTTP 请求

GET /api/v1/namespaces/{namespace}/serviceaccounts

参数

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

    namespace

  • continue (查询字符串): string

    continue

  • limit (查询字符串): integer

    limit

  • pretty (查询字符串): string

    pretty

  • watch (查询字符串): boolean

    watch

响应

200 (ServiceAccountList): OK

401: Unauthorized

list 列出或监控 ServiceAccount 类型的对象

HTTP 请求

GET /api/v1/serviceaccounts

参数

  • continue (查询字符串): string

    continue

  • limit (查询字符串): integer

    limit

  • pretty (查询字符串): string

    pretty

  • watch (查询字符串): boolean

    watch

响应

200 (ServiceAccountList): OK

401: Unauthorized

create 创建一个 ServiceAccount

HTTP 请求

POST /api/v1/namespaces/{namespace}/serviceaccounts

参数

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

    namespace

  • dryRun (查询字符串): string

    dryRun

  • pretty (查询字符串): string

    pretty

响应

200 (ServiceAccount): OK

201 (ServiceAccount): Created

202 (ServiceAccount): Accepted

401: Unauthorized

update 替换指定的ServiceAccount

HTTP 请求

PUT /api/v1/namespaces/{namespace}/serviceaccounts/{name}

参数

  • name (位于路径中): string, required

    name of the ServiceAccount

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

    namespace

  • dryRun (查询字符串): string

    dryRun

  • pretty (查询字符串): string

    pretty

响应

200 (ServiceAccount): OK

201 (ServiceAccount): Created

401: Unauthorized

patch 部分更新指定的 ServiceAccount

HTTP 请求

PATCH /api/v1/namespaces/{namespace}/serviceaccounts/{name}

参数

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

    ServiceAccount 的名称

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

    namespace

  • body: Patch, required

  • dryRun (查询字符串): string

    dryRun

  • force (查询字符串): boolean

    force

  • pretty (查询字符串): string

    pretty

响应

200 (ServiceAccount): OK

201 (ServiceAccount): Created

401: Unauthorized

delete 删除一个 ServiceAccount

HTTP 请求

DELETE /api/v1/namespaces/{namespace}/serviceaccounts/{name}

参数

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

    ServiceAccount 的名称

  • dryRun (查询字符串): string

    dryRun

响应

200 (ServiceAccount): OK

202 (ServiceAccount): Accepted

401: Unauthorized

deletecollection 删除 ServiceAccount 的集合

HTTP 请求

DELETE /api/v1/namespaces/{namespace}/serviceaccounts

参数

  • continue (查询字符串): string

    continue

  • dryRun (查询字符串): string

    dryRun

  • limit (查询字符串): integer

    limit

  • pretty (查询字符串): string

    pretty

响应

200 (Status): OK

401: Unauthorized

4.2 - TokenReview

TokenReview 尝试通过验证令牌来确认已知用户。

apiVersion: authentication.k8s.io/v1

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

TokenReview

TokenReview 尝试通过验证令牌来确认已知用户。 注意:TokenReview 请求可能会被 kube-apiserver 中的 webhook 令牌验证器插件缓存。


TokenReviewSpec

TokenReviewPec 是对令牌身份验证请求的描述。


  • audiences ([]string)

    audiences 是带有令牌的资源服务器标识为受众的标识符列表。 受众感知令牌身份验证器将验证令牌是否适用于此列表中的至少一个受众。 如果未提供受众,受众将默认为 Kubernetes API 服务器的受众。

  • token (string)

    token 是不透明的持有者令牌(Bearer Token)。

TokenReviewStatus

TokenReviewStatus 是令牌认证请求的结果。


  • audiences ([]string)

    audiences 是身份验证者选择的与 TokenReview 和令牌兼容的受众标识符。标识符是 TokenReviewSpec 受众和令牌受众的交集中的任何标识符。设置 spec.audiences 字段的 TokenReview API 的客户端应验证在 status.audiences 字段中返回了兼容的受众标识符, 以确保 TokenReview 服务器能够识别受众。如果 TokenReview 返回一个空的 status.audience 字段,其中 status.authenticated 为 “true”, 则该令牌对 Kubernetes API 服务器的受众有效。

  • authenticated (boolean)

    authenticated 表示令牌与已知用户相关联。

  • error (string)

    error 表示无法检查令牌

  • user (UserInfo)

    user 是与提供的令牌关联的 UserInfo。

    <-- UserInfo holds the information about the user needed to implement the user.Info interface. --> UserInfo 保存实现 user.Info 接口所需的用户信息

    • user.extra (map[string][]string)

    验证者提供的任何附加信息。

    • user.groups ([]string)

    此用户所属的组的名称。

    • user.uid (string)

    跨时间标识此用户的唯一值。如果删除此用户并添加另一个同名用户,他们将拥有不同的 UID。

    • user.username (string)

    在所有活动用户中唯一标识此用户的名称。

操作


create 创建一个TokenReview

HTTP 请求

POST /apis/authentication.k8s.io/v1/tokenreviews

参数

响应

200 (TokenReview): OK

201 (TokenReview): Created

202 (TokenReview): Accepted

401: Unauthorized

5 - 鉴权资源

5.1 - LocalSubjectAccessReview

LocalSubjectAccessReview 检查用户或组是否可以在给定的命名空间内执行某操作。

apiVersion: authorization.k8s.io/v1

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

LocalSubjectAccessReview

LocalSubjectAccessReview 检查用户或组是否可以在给定的命名空间内执行某操作。 划分命名空间范围的资源简化了命名空间范围的策略设置,例如权限检查。


  • apiVersion: authorization.k8s.io/v1

  • kind: LocalSubjectAccessReview

  • metadata (ObjectMeta)

    标准的列表元数据。 更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

  • spec (SubjectAccessReviewSpec),必需

    spec 包含有关正在评估的请求的信息。 spec.namespace 必须是你的请求所针对的命名空间。 如果留空,则会被设置默认值。

  • status (SubjectAccessReviewStatus)

    status 由服务器填写,表示请求是否被允许。

操作


create 创建 LocalSubjectAccessReview

HTTP 请求

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

参数

响应

200 (LocalSubjectAccessReview): OK

201 (LocalSubjectAccessReview): Created

202 (LocalSubjectAccessReview): Accepted

401: Unauthorized

5.2 - SelfSubjectAccessReview

SelfSubjectAccessReview 检查当前用户是否可以执行某操作。

apiVersion: authorization.k8s.io/v1

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

SelfSubjectAccessReview

SelfSubjectAccessReview 检查当前用户是否可以执行某操作。 不填写 spec.namespace 表示 “在所有命名空间中”。 Self 是一个特殊情况,因为用户应始终能够检查自己是否可以执行某操作。


  • apiVersion: authorization.k8s.io/v1

  • kind: SelfSubjectAccessReview

  • metadata (ObjectMeta)

    标准的列表元数据。 更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

  • spec (SelfSubjectAccessReviewSpec),必需

    spec 包含有关正在评估的请求的信息。 user 和 group 必须为空。

  • status (SubjectAccessReviewStatus)

    status 由服务器填写,表示请求是否被允许。

SelfSubjectAccessReviewSpec

SelfSubjectAccessReviewSpec 是访问请求的描述。 resourceAuthorizationAttributes 和 nonResourceAuthorizationAttributes 二者必须设置其一,并且只能设置其一。


  • nonResourceAttributes (NonResourceAttributes)

    nonResourceAttributes 描述非资源访问请求的信息。

    nonResourceAttributes 包括提供给 Authorizer 接口进行非资源请求鉴权时所用的属性。

    • nonResourceAttributes.path (string)

      path 是请求的 URL 路径。

    • nonResourceAttributes.verb (string)

      verb 是标准的 HTTP 动作。

  • resourceAttributes (ResourceAttributes)

    resourceAuthorizationAttributes 描述资源访问请求的信息。

    resourceAttributes 包括提供给 Authorizer 接口进行资源请求鉴权时所用的属性。

    • resourceAttributes.group (string)

      group 是资源的 API 组。 "*" 表示所有组。

    • resourceAttributes.name (string)

      name 是 "get" 正在请求或 "delete" 已删除的资源的名称。 ""(空字符串)表示所有资源。

  • resourceAttributes.namespace (string)

    namespace 是正在请求的操作的命名空间。 目前,无命名空间和所有命名空间之间没有区别。 对于 LocalSubjectAccessReviews,默认为 ""(空字符串)。 对于集群范围的资源,默认为 ""(空字符串)。 对于来自 SubjectAccessReview 或 SelfSubjectAccessReview 的命名空间范围的资源,""(空字符串)表示 "all"(所有资源)。

  • resourceAttributes.resource (string)

    resource 是现有的资源类别之一。 "*" 表示所有资源类别。

  • resourceAttributes.subresource (string)

    subresource 是现有的资源类型之一。 "" 表示无。

  • resourceAttributes.verb (string)

    verb 是 kubernetes 资源 API 动作,例如 get、list、watch、create、update、delete、proxy。 "*" 表示所有动作。

  • resourceAttributes.version (string)

    version 是资源的 API 版本。 "*" 表示所有版本。

操作


create 创建 SelfSubjectAccessReview

HTTP 请求

POST /apis/authorization.k8s.io/v1/selfsubjectaccessreviews

参数

响应

200 (SelfSubjectAccessReview): OK

201 (SelfSubjectAccessReview): Created

202 (SelfSubjectAccessReview): Accepted

401: Unauthorized

5.3 - SelfSubjectRulesReview

SelfSubjectRulesReview 枚举当前用户可以在某命名空间内执行的操作集合。

apiVersion: authorization.k8s.io/v1

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

SelfSubjectRulesReview

SelfSubjectRulesReview 枚举当前用户可以在某命名空间内执行的操作集合。 返回的操作列表可能不完整,具体取决于服务器的鉴权模式以及评估过程中遇到的任何错误。 SelfSubjectRulesReview 应由 UI 用于显示/隐藏操作,或让最终用户尽快理解自己的权限。 SelfSubjectRulesReview 不得被外部系统使用以驱动鉴权决策, 因为这会引起混淆代理人(confused deputy)、缓存有效期/吊销(cache lifetime/revocation)和正确性问题。 SubjectAccessReview 和 LocalAccessReview 是遵从 API 服务器所做鉴权决策的正确方式。


  • apiVersion: authorization.k8s.io/v1

  • kind: SelfSubjectRulesReview

  • metadata (ObjectMeta)

    标准的列表元数据。 更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

  • spec (SelfSubjectRulesReviewSpec),必需

    spec 包含有关正在评估的请求的信息。

  • status (SubjectRulesReviewStatus)

    status 由服务器填写,表示用户可以执行的操作的集合。

    SubjectRulesReviewStatus 包含规则检查的结果。 此检查可能不完整,具体取决于服务器配置的 Authorizer 的集合以及评估期间遇到的任何错误。 由于鉴权规则是叠加的,所以如果某个规则出现在列表中,即使该列表不完整,也可以安全地假定该主体拥有该权限。

    • status.incomplete (boolean),必需

      当此调用返回的规则不完整时,incomplete 结果为 true。 这种情况常见于 Authorizer(例如外部 Authorizer)不支持规则评估时。

    • status.nonResourceRules ([]NonResourceRule),必需

      nonResourceRules 是允许主体对非资源执行路径执行的操作列表。 该列表顺序不重要,可以包含重复项,还可能不完整。

      nonResourceRule 包含描述非资源路径的规则的信息。

- **status.nonResourceRules.verbs** ([]string),必需
  
  verb 是 kubernetes 非资源 API 动作的列表,例如 get、post、put、delete、patch、head、options。
  "*" 表示所有动作。

- **status.nonResourceRules.nonResourceURLs** ([]string)
  
  nonResourceURLs 是用户应有权访问的一组部分 URL。
  允许使用 "*",但仅能作为路径中最后一段且必须用于完整的一段。
  "*" 表示全部。
  • status.resourceRules ([]ResourceRule),必需

    resourceRules 是允许主体对资源执行的操作的列表。 该列表顺序不重要,可以包含重复项,还可能不完整。

    resourceRule 是允许主体对资源执行的操作的列表。该列表顺序不重要,可以包含重复项,还可能不完整。

    • status.resourceRules.verbs ([]string),必需

      verb 是 kubernetes 资源 API 动作的列表,例如 get、list、watch、create、update、delete、proxy。 "*" 表示所有动作。

- **status.resourceRules.apiGroups** ([]string)
  
  apiGroups 是包含资源的 APIGroup 的名称。
  如果指定了多个 API 组,则允许对任何 API 组中枚举的资源之一请求任何操作。
  "*" 表示所有 APIGroup。

- **status.resourceRules.resourceNames** ([]string)
  
  resourceNames 是此规则所适用的资源名称白名单,可选。
  空集合意味着允许所有资源。
  "*" 表示所有资源。

- **status.resourceRules.resources** ([]string)
  
  resources 是此规则所适用的资源的列表。
  "*" 表示指定 APIGroup 中的所有资源。
  "*/foo" 表示指定 APIGroup 中所有资源的子资源 "foo"。
  • status.evaluationError (string)

    evaluationError 可以与 rules 一起出现。 它表示在规则评估期间发生错误,例如 Authorizer 不支持规则评估以及 resourceRules 和/或 nonResourceRules 可能不完整。

SelfSubjectRulesReviewSpec

SelfSubjectRulesReviewSpec 定义 SelfSubjectRulesReview 的规范。


  • namespace (string)

    namespace 是要评估规则的命名空间。 必需。

操作


create 创建 SelfSubjectRulesReview

HTTP 请求

POST /apis/authorization.k8s.io/v1/selfsubjectrulesreviews

参数

响应

200 (SelfSubjectRulesReview): OK

201 (SelfSubjectRulesReview): Created

202 (SelfSubjectRulesReview): Accepted

401: Unauthorized

5.4 - SubjectAccessReview

SubjectAccessReview 检查用户或组是否可以执行某操作。

apiVersion: authorization.k8s.io/v1

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

SubjectAccessReview

SubjectAccessReview 检查用户或组是否可以执行某操作。


  • apiVersion: authorization.k8s.io/v1

  • kind: SubjectAccessReview

  • metadata (ObjectMeta)

标准的列表元数据。 更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

SubjectAccessReviewSpec

SubjectAccessReviewSpec 是访问请求的描述。 resourceAuthorizationAttributes 和 nonResourceAuthorizationAttributes 二者必须设置其一,并且只能设置其一。


  • extra (map[string][]string)

    extra 对应于来自鉴权器的 user.Info.GetExtra() 方法。 由于这是针对 Authorizer 的输入,所以它需要在此处反映。

  • groups ([]string)

    groups 是你正在测试的组。

  • nonResourceAttributes (NonResourceAttributes)

    nonResourceAttributes 描述非资源访问请求的信息。

    nonResourceAttributes 包括提供给 Authorizer 接口进行非资源请求鉴权时所用的属性。

    • nonResourceAttributes.path (string)

      path 是请求的 URL 路径。

    • nonResourceAttributes.verb (string)

      verb 是标准的 HTTP 动作。

  • resourceAttributes (ResourceAttributes)

    resourceAuthorizationAttributes 描述资源访问请求的信息。

    resourceAttributes 包括提供给 Authorizer 接口进行资源请求鉴权时所用的属性。

    • resourceAttributes.group (string)

      group 是资源的 API 组。 "*" 表示所有资源。

    • resourceAttributes.name (string)

      name 是 "get" 正在请求或 "delete" 已删除的资源。 ""(空字符串)表示所有资源。

  • resourceAttributes.namespace (string)

    namespace 是正在请求的操作的命名空间。 目前,无命名空间和所有命名空间之间没有区别。 对于 LocalSubjectAccessReviews,默认为 ""(空字符串)。 对于集群范围的资源,默认为 ""(空字符串)。 对于来自 SubjectAccessReview 或 SelfSubjectAccessReview 的命名空间范围的资源, ""(空字符串)表示 "all"(所有资源)。

  • resourceAttributes.resource (string)

    resource 是现有的资源类别之一。 "*" 表示所有资源类别。

  • resourceAttributes.subresource (string)

    subresource 是现有的资源类别之一。 "" 表示无子资源。

  • resourceAttributes.verb (string)

    verb 是 kubernetes 资源的 API 动作,例如 get、list、watch、create、update、delete、proxy。 "*" 表示所有动作。

  • resourceAttributes.version (string)

    version 是资源的 API 版本。 "*" 表示所有版本。

  • uid (string)

    有关正在请求的用户的 UID 信息。

  • user (string)

    user 是你正在测试的用户。 如果你指定 “user” 而不是 “groups”,它将被解读为“如果 user 不是任何组的成员,将会怎样”。

SubjectAccessReviewStatus

SubjectAccessReviewStatus


  • allowed (boolean),必需

    allowed 是必需的。 如果允许该操作,则为 true,否则为 false。

  • denied (boolean)

    denied 是可选的。 如果拒绝该操作,则为 true,否则为 false。 如果 allowed 和 denied 均为 false,则 Authorizer 对是否鉴权操作没有意见。 如果 allowed 为 true,则 denied 不能为 true。

  • evaluationError (string)

    evaluationError 表示鉴权检查期间发生一些错误。 出现错误的情况下完全有可能继续确定鉴权状态。 例如,RBAC 可能缺少一个角色,但仍存在足够多的角色进行绑定,进而了解请求有关的原因。

  • reason (string)

    reason 是可选的。 它表示为什么允许或拒绝请求。

操作


create 创建 SubjectAccessReview

HTTP 请求

POST /apis/authorization.k8s.io/v1/subjectaccessreviews

参数

响应

200 (SubjectAccessReview): OK

201 (SubjectAccessReview): Created

202 (SubjectAccessReview): Accepted

401: Unauthorized

5.5 - 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 的 rules。 如果设置了 aggregationRule,则 rules 将由控制器管理,对 rules 的直接变更会被该控制器阻止。

    aggregationRule 描述如何定位并聚合其它 ClusterRole 到此 ClusterRole

    • aggregationRule.clusterRoleSelectors ([]LabelSelector)

      clusterRoleSelectors 包含一个选择器的列表,用于查找 ClusterRole 并创建规则。 如果发现任何选择器匹配的 ClusterRole,将添加其对应的权限。

  • rules ([]PolicyRule)

    rules 包含了这个 ClusterRole 的所有 PolicyRule。

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

    • rules.apiGroups ([]string)

      apiGroups 是包含资源的 apiGroup 的名称。 如果指定了多个 API 组,则允许针对任何 API 组中的其中一个枚举资源来请求任何操作。

    • rules.resources ([]string)

      resources 是此规则所适用的资源的列表。“*” 表示所有资源。

    • rules.verbs ([]string),必需

      verbs 是适用于此规则中所包含的所有 ResourceKinds 的动作。 “*” 表示所有动作。

    • rules.resourceNames ([]string)

      resourceNames 是此规则所适用的资源名称白名单,可选。 空集合意味着允许所有资源。

    • rules.nonResourceURLs ([]string)

      nonResourceURLs 是用户应有权访问的一组部分 URL。 允许使用 “*”,但仅能作为路径中最后一段且必须用于完整的一段, 因为非资源 URL 没有划分命名空间。 此字段仅适用于从 ClusterRoleBinding 引用的 ClusterRole。 rules 可以应用到 API 资源(如 “pod” 或 “secret”)或非资源 URL 路径(如 “/api”), 但不能同时应用于两者。

ClusterRoleList

ClusterRoleList 是 ClusterRole 的集合。


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

  • kind: ClusterRoleList

  • metadata (ListMeta)

    标准的对象元数据。

  • items ([]ClusterRole),必需

    items 是 ClusterRole 的列表。

操作


get 读取指定的 ClusterRole

HTTP 请求

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

参数

  • name (路径参数): string,必需

    ClusterRole 的名称

  • pretty (查询参数): string

    pretty

响应

200 (ClusterRole): OK

401: Unauthorized

list 列出或观测类别为 ClusterRole 的对象

HTTP 请求

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

参数

响应

200 (ClusterRoleList): OK

401: Unauthorized

create 创建一个 ClusterRole

HTTP 请求

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

参数

响应

200 (ClusterRole): OK

201 (ClusterRole): Created

202 (ClusterRole): Accepted

401: Unauthorized

update 替换指定的 ClusterRole

HTTP 请求

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

参数

  • name (路径参数): string,必需

    ClusterRole 的名称

  • body: ClusterRole,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (ClusterRole): OK

201 (ClusterRole): Created

401: Unauthorized

patch 部分更新指定的 ClusterRole

HTTP 请求

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

参数

  • name (路径参数): string,必需

    ClusterRole 的名称

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (ClusterRole): OK

201 (ClusterRole): Created

401: Unauthorized

delete 删除一个 ClusterRole

HTTP 请求

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

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 ClusterRole 的集合

HTTP 请求

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

参数

响应

200 (Status): OK

401: Unauthorized

5.6 - ClusterRoleBinding

ClusterRoleBinding 引用 ClusterRole,但不包含它。

apiVersion: rbac.authorization.k8s.io/v1

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

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 组定义的值是 UserGroupServiceAccount。 如果 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 是 ClusterRoleBinding 的集合。


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

  • kind: ClusterRoleBindingList

  • metadata (ListMeta)

    标准的对象元数据。

  • items ([]ClusterRoleBinding),必需

    items 是 ClusterRoleBindings 的列表。

操作


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

参数

响应

200 (ClusterRoleBindingList): OK

401: Unauthorized

create 创建 ClusterRoleBinding

HTTP 请求

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

参数

响应

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,必需

响应

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,必需

响应

200 (ClusterRoleBinding): OK

201 (ClusterRoleBinding): Created

401: Unauthorized

delete 删除 ClusterRoleBinding

HTTP 请求

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

参数

  • name (路径参数): string,必需

    ClusterRoleBinding 的名称

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 ClusterRoleBinding 的集合

HTTP 请求

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

参数

响应

200 (Status): OK

401: Unauthorized

5.7 - Role

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

apiVersion: rbac.authorization.k8s.io/v1

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

Role

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 组中的其中一个枚举资源来请求任何操作。

    • rules.resources ([]string)

      resources 是此规则所适用的资源的列表。 “*” 表示所有资源。

  • rules.verbs ([]string),必需

    verbs 是适用于此规则中所包含的所有 ResourceKinds 的动作。 “*” 表示所有动作。

  • rules.resourceNames ([]string)

    resourceNames 是此规则所适用的资源名称白名单,可选。 空集合意味着允许所有资源。

  • rules.nonResourceURLs ([]string)

    nonResourceURLs 是用户应有权访问的一组部分 URL。 允许使用 “*”,但仅能作为路径中最后一段且必须用于完整的一段, 因为非资源 URL 没有划分命名空间。 此字段仅适用于从 ClusterRoleBinding 引用的 ClusterRole。 rules 可以应用到 API 资源(如 “pod” 或 “secret”)或非资源 URL 路径(如 “/api”), 但不能同时应用于两者。

RoleList

RoleList 是 Role 的集合。


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

  • kind: RoleList

  • metadata (ListMeta)

标准的对象元数据。

  • items ([]Role),必需

    items 是 Role 的列表。

操作


get 读取指定的 Role

HTTP 请求

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

参数

  • name (路径参数): string,必需

    Role 的名称

  • namespace (路径参数): string,必需

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (Role): OK

401: Unauthorized

list 列出或观测类别为 Role 的对象

HTTP 请求

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

参数

响应

200 (RoleList): OK

401: Unauthorized

list 列出或观测类别为 Role 的对象

HTTP 请求

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

参数

响应

200 (RoleList): OK

401: Unauthorized

create 创建 Role

HTTP 请求

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

参数

响应

200 (Role): OK

201 (Role): Created

202 (Role): Accepted

401: Unauthorized

update 替换指定的 Role

HTTP 请求

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

参数

  • name (路径参数): string,必需

    Role 的名称

  • namespace (路径参数): string,必需

    namespace

  • body: Role,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (Role): OK

201 (Role): Created

401: Unauthorized

patch 部分更新指定的 Role

HTTP 请求

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

参数

  • name (路径参数): string,必需

    Role 的名称

  • namespace (路径参数): string,必需

    namespace

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (Role): OK

201 (Role): Created

401: Unauthorized

delete 删除 Role

HTTP 请求

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

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 Role 的集合

HTTP 请求

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

参数

响应

200 (Status): OK

401: Unauthorized

5.8 - RoleBinding

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

apiVersion: rbac.authorization.k8s.io/v1

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

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 组定义的值是 UserGroupServiceAccount。 如果 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 是 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,必需

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (RoleBinding): OK

401: Unauthorized

list 列出或观测类别为 RoleBinding 的对象

HTTP 请求

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

参数

响应

200 (RoleBindingList): OK

401: Unauthorized

list 列出或观测类别为 RoleBinding 的对象

HTTP 请求

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

参数

响应

200 (RoleBindingList): OK

401: Unauthorized

create 创建 RoleBinding

HTTP 请求

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

参数

响应

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}

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 RoleBinding 的集合

HTTP 请求

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

参数

响应

200 (Status): OK

401: Unauthorized

6 - 策略资源

7 - 扩展资源

8 - 集群资源

8.1 - Namespace

Namespace 为名字提供作用域。

apiVersion: v1

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

Namespace

Namespace 为名字提供作用域。使用多个命名空间是可选的。


NamespaceSpec

NamespaceSpec 用于描述 Namespace 的属性。


NamespaceStatus

NamespaceStatus 表示 Namespace 的当前状态信息。


  • conditions ([]NamespaceCondition)

    补丁策略:基于 type 健合并

    表示命名空间当前状态的最新可用状况。

    NamespaceCondition 包含命名空间状态的详细信息。

    • conditions.status (string),必需

      状况(condition)的状态,取值为 True、False 或 Unknown 之一。

    • conditions.type (string), 必需

      命名空间控制器状况的类型。

    • conditions.lastTransitionTime (Time)

      Time 是对 time.Time 的封装。Time 支持对 YAML 和 JSON 进行正确封包。为 time 包的许多函数方法提供了封装器。

    • conditions.message (string)

    • conditions.reason (string)

  • phase (string)

    phase 是命名空间的当前生命周期阶段。更多信息: https://kubernetes.io/docs/tasks/administer-cluster/namespaces/

NamespaceList

NamespaceList 是一个命名空间列表。


操作


get 读取指定的 Namespace

HTTP 请求

GET /api/v1/namespaces/{name}

参数

  • name (路径参数):string,必需

    Namespace 的名称

  • pretty (查询参数):string

    pretty

响应

200 (Namespace):OK

401:Unauthorized

get 读取指定 Namespace 的状态

HTTP 请求

GET /api/v1/namespaces/{name}/status

参数

  • name (路径参数):string,必需

    Namespace 的名称

  • pretty (查询参数):string

    pretty

响应

200 (Namespace):OK

401:Unauthorized

list 列出或者检查类别为 Namespace 的对象

HTTP 请求

GET /api/v1/namespaces

参数

  • continue (查询参数):string

    continue

  • limit (查询参数):integer

    limit

  • pretty (查询参数):string

    pretty

  • watch (查询参数):boolean

    watch

响应

200 (NamespaceList):OK

401:Unauthorized

create 创建一个 Namespace

HTTP 请求

POST /api/v1/namespaces

参数

  • dryRun (查询参数):string

    dryRun

  • pretty (查询参数):string

    pretty

响应

200 (Namespace):OK

201 (Namespace):Created

202 (Namespace):Accepted

401:Unauthorized

update 替换指定的 Namespace

HTTP 请求

PUT /api/v1/namespaces/{name}

参数

  • name (路径参数):string,必需

    Namespace 的名称

  • body: Namespace, 必需

  • dryRun (查询参数):string

    dryRun

  • pretty (查询参数):string

    pretty

响应

200 (Namespace):OK

201 (Namespace):Created

401:Unauthorized

update 替换指定 Namespace 的终结器

HTTP 请求

PUT /api/v1/namespaces/{name}/finalize

参数

  • name (路径参数):string,必需

    Namespace 的名称

  • body: Namespace,必需

  • dryRun (查询参数):string

    dryRun

  • pretty (查询参数):string

    pretty

响应

200 (Namespace):OK

201 (Namespace):Created

401:Unauthorized

update 替换指定 Namespace 的状态

HTTP 请求

PUT /api/v1/namespaces/{name}/status

参数

  • name (路径阐述):string,必需

    Namespace 的名称

  • body: Namespace,必需

  • dryRun (查询参数):string

    dryRun

  • pretty (查询参数):string

    pretty

响应

200 (Namespace):OK

201 (Namespace):Created

401: Unauthorized

patch 部分更新指定的 Namespace

HTTP 请求

PATCH /api/v1/namespaces/{name}

参数

  • name (路径参数):string,必需

    Namespace 的名称

  • dryRun (查询参数):string

    dryRun

  • force (查询参数):boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (Namespace):OK

201 (Namespace):Created

401: Unauthorized

patch 部分更新指定 Namespace 的状态

HTTP 请求

PATCH /api/v1/namespaces/{name}/status

参数

  • name (路径参数):string,必需

    Namespace 的名称

  • dryRun (查询参数):string

    dryRun

  • force (查询参数): boolean

    force

  • pretty (查询参数):string

    pretty

响应

200 (Namespace):OK

201 (Namespace):Created

401:Unauthorized

delete 删除一个 Namespace

HTTP 请求

DELETE /api/v1/namespaces/{name}

参数

  • name (路径参数):string,必需

    Namespace 的名称

  • body: DeleteOptions

  • dryRun (查询参数):string

    dryRun

  • pretty (查询参数):string

    pretty

响应

200 (Status):OK

202 (Status):Accepted

401:Unauthorized

8.2 - Binding

Binding 将一个对象与另一个对象联系起来; 例如,一个 Pod 被调度程序绑定到一个节点。

apiVersion: v1

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

Binding

Binding 将一个对象与另一个对象联系起来; 例如,一个 Pod 被调度程序绑定到一个节点。 已在 1.7 版本弃用,请使用 Pod 的 binding 子资源。


  • apiVersion: v1

  • kind: Binding

  • metadata (ObjectMeta)

标准对象的元数据, 更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

  • target (ObjectReference), 必需

    要绑定到标准对象的目标对象。

操作


create 创建一个 Binding

HTTP 请求

POST /api/v1/namespaces/{namespace}/bindings

参数

响应

200 (Binding): OK

201 (Binding): Created

202 (Binding): Accepted

401: Unauthorized

create 创建 Pod 的绑定

HTTP 请求

POST /api/v1/namespaces/{namespace}/pods/{name}/binding

参数

  • name (路径参数): string, 必需

    Binding 的名称

  • namespace (路径参数): string, 必需

    namespace

  • body: Binding, 必需

响应

200 (Binding): OK

201 (Binding): Created

202 (Binding): Accepted

401: Unauthorized

9 - 公共定义

9.1 - DeleteOptions

删除 API 对象时可以提供 DeleteOptions。

import "k8s.io/apimachinery/pkg/apis/meta/v1"

删除 API 对象时可以提供 DeleteOptions。


  • dryRun ([]string)

    该值如果存在,则表示不应保留修改。 无效或无法识别的 dryRun 指令将导致错误响应并且不会进一步处理请求。有效值为:

    • All:处理所有试运行阶段(Dry Run Stages)
  • gracePeriodSeconds (int64)

    表示对象被删除之前的持续时间(以秒为单位)。 值必须是非负整数。零值表示立即删除。如果此值为 nil,则将使用指定类型的默认宽限期。如果未指定,则为每个对象的默认值。

  • orphanDependents (boolean)

    已弃用:该字段将在 1.7 中弃用,请使用 propagationPolicy 字段。 该字段表示依赖对象是否应该是孤儿。如果为 true/false,对象的 finalizers 列表中会被添加上或者移除掉 “orphan” 终结器(Finalizer)。 可以设置此字段或者设置 propagationPolicy 字段,但不能同时设置以上两个字段。

  • preconditions (Preconditions)

    先决条件必须在执行删除之前完成。如果无法满足这些条件,将返回 409(冲突)状态。

    执行操作(更新、删除等)之前必须满足先决条件。

    • preconditions.resourceVersion (string)

      指定目标资源版本(resourceVersion)。

    • preconditions.uid (string)

      指定目标 UID。

  • propagationPolicy (string)

    表示是否以及如何执行垃圾收集。可以设置此字段或 orphanDependents 字段,但不能同时设置二者。 默认策略由 metadata.finalizers 中现有终结器(Finalizer)集合和特定资源的默认策略决定。 可接受的值为:Orphan - 令依赖对象成为孤儿对象;Background - 允许垃圾收集器在后台删除依赖项;Foreground - 一个级联策略,前台删除所有依赖项。

9.2 - LabelSelector

标签选择器是对一组资源的标签查询。

import "k8s.io/apimachinery/pkg/apis/meta/v1"

标签选择器是对一组资源的标签查询。

matchLabelsmatchExpressions 的结果按逻辑与的关系组合。 一个 empty 标签选择器匹配所有对象。一个 null 标签选择器不匹配任何对象。


  • matchExpressions ([]LabelSelectorRequirement)

    matchExpressions 是标签选择器要求的列表,这些要求的结果按逻辑与的关系来计算。

    标签选择器要求是包含值、键和关联键和值的运算符的选择器。

    • matchExpressions.key (string), 必填

      补丁策略:按照键 key 合并

      key 是选择器应用的标签键。

    • matchExpressions.operator (string),必填

      operator 表示键与一组值的关系。有效的运算符包括 InNotInExistsDoesNotExist

    • matchExpressions.values ([]string)

      values 是一个字符串值数组。如果运算符为 InNotIn,则 values 数组必须为非空。

      如果运算符是 ExistsDoesNotExist,则 values 数组必须为空。

      该数组在策略性合并补丁(Strategic Merge Patch)期间被替换。

  • matchLabels (map[string]string)

    matchLabels 是 {key,value} 键值对的映射。

    matchLabels 映射中的单个 {key,value} 键值对相当于 matchExpressions 的一个元素,其键字段为 key,运算符为 Invalues 数组仅包含 value

    所表达的需求最终要按逻辑与的关系组合。

9.3 - ListMeta

ListMeta 描述了合成资源必须具有的元数据,包括列表和各种状态对象。

import "k8s.io/apimachinery/pkg/apis/meta/v1"

ListMeta 描述了合成资源必须具有的元数据,包括列表和各种状态对象。 一个资源仅能有 {ObjectMeta, ListMeta} 中的一个。


  • continue (string)

    如果用户对返回的条目数量设置了限制,则 continue 可能被设置,表示服务器有更多可用的数据。 该值是不透明的,可用于向提供此列表服务的端点发出另一个请求,以检索下一组可用的对象。 如果服务器配置已更改或时间已过去几分钟,则可能无法继续提供一致的列表。 除非你在错误消息中收到此令牌(token),否则使用此 continue 值时返回的 resourceVersion 字段应该和第一个响应中的值是相同的。

  • remainingItemCount (int64)

    remainingItemCount 是列表中未包含在此列表响应中的后续项目的数量。 如果列表请求包含标签或字段选择器,则剩余项目的数量是未知的,并且在序列化期间该字段将保持未设置和省略。 如果列表是完整的(因为它没有分块或者这是最后一个块),那么就没有剩余的项目,并且在序列化过程中该字段将保持未设置和省略。 早于 v1.15 的服务器不设置此字段。remainingItemCount 的预期用途是估计集合的大小。 客户端不应依赖于设置准确的 remainingItemCount

  • selfLink (string)

    selfLink 表示此对象的 URL,由系统填充,只读。

    已弃用:selfLink 是一个遗留的只读字段,不再由系统填充。

9.4 - LocalObjectReference

LocalObjectReference 包含足够的信息,可以让你在同一命名空间内找到引用的对象。

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

LocalObjectReference 包含足够的信息,可以让你在同一命名空间(namespace)内找到引用的对象。


9.5 - NodeSelectorRequirement

节点选择器是要求包含键、值和关联键和值的运算符的选择器

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

节点选择器是要求包含键、值和关联键和值的运算符的选择器。


  • key (string), 必选

    选择器适用的标签键。

  • operator (string), 必选

    表示键与一组值的关系的运算符。有效的运算符包括:In、NotIn、Exists、DoesNotExist、Gt 和 Lt。

  • values ([]string)

    字符串数组。如果运算符为 In 或 NotIn,则数组必须为非空。 如果运算符为 Exists 或 DoesNotExist,则数组必须为空。 如果运算符为 Gt 或 Lt,则数组必须有一个元素,该元素将被译为整数。 该数组在合并计划补丁时将被替换。

9.6 - ObjectFieldSelector

ObjectFieldSelector 选择对象的 APIVersioned 字段。

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

ObjectFieldSelector 选择对象的 APIVersioned 字段。


  • fieldPath (string), 必需的

    在指定 API 版本中要选择的字段的路径。

  • apiVersion (string)

    fieldPath 写入时所使用的模式版本,默认为 "v1"。

9.7 - ObjectMeta

ObjectMeta 是所有持久化资源必须具有的元数据,其中包括用户必须创建的所有对象。

import "k8s.io/apimachinery/pkg/apis/meta/v1"

ObjectMeta 是所有持久化资源必须具有的元数据,其中包括用户必须创建的所有对象。


  • name (string)

    name 在命名空间内必须是唯一的。创建资源时需要,尽管某些资源可能允许客户端请求自动地生成适当的名称。 名称主要用于创建幂等性和配置定义。无法更新。 更多信息: http://kubernetes.io/docs/user-guide/identifiers#names

  • generateName (string)

    generateName 是一个可选前缀,由服务器使用,仅在未提供 name 字段时生成唯一名称。 如果使用此字段,则返回给客户端的名称将与传递的名称不同。该值还将与唯一的后缀组合。 提供的值与 name 字段具有相同的验证规则,并且可能会根据所需的后缀长度被截断,以使该值在服务器上唯一。

    如果指定了此字段并且生成的名称存在,则服务器将不会返回 409 ——相反,它将返回 201 Created 或 500, 原因是 ServerTimeout 指示在分配的时间内找不到唯一名称,客户端应重试(可选,在 Retry-After 标头中指定的时间之后)。

    仅在未指定 name 时应用。更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#idempotency

  • namespace (string)

    namespace 定义了一个值空间,其中每个名称必须唯一。空命名空间相当于 “default” 命名空间,但 “default” 是规范表示。 并非所有对象都需要限定在命名空间中——这些对象的此字段的值将为空。

    必须是 DNS_LABEL。无法更新。更多信息: http://kubernetes.io/docs/user-guide/namespaces

  • labels (map[string]string)

    可用于组织和分类(确定范围和选择)对象的字符串键和值的映射。 可以匹配 ReplicationControllers 和 Service 的选择器。更多信息: http://kubernetes.io/docs/user-guide/labels

  • annotations (map[string]string)

    annotations 是一个非结构化的键值映射,存储在资源中,可以由外部工具设置以存储和检索任意元数据。 它们不可查询,在修改对象时应保留。更多信息: http://kubernetes.io/docs/user-guide/annotations

系统字段

  • finalizers ([]string)

    在从注册表中删除对象之前该字段必须为空。 每个条目都是负责的组件的标识符,各组件将从列表中删除自己对应的条目。 如果对象的 deletionTimestamp 非空,则只能删除此列表中的条目。 终结器可以按任何顺序处理和删除。没有按照顺序执行, 因为它引入了终结器卡住的重大风险。finalizers 是一个共享字段, 任何有权限的参与者都可以对其进行重新排序。如果按顺序处理终结器列表, 那么这可能导致列表中第一个负责终结器的组件正在等待列表中靠后负责终结器的组件产生的信号(字段值、外部系统或其他), 从而导致死锁。在没有强制排序的情况下,终结者可以在它们之间自由排序, 并且不容易受到列表中排序更改的影响。

  • managedFields ([]ManagedFieldsEntry)

    managedFields 将 workflow-id 和版本映射到由该工作流管理的字段集。 这主要用于内部管理,用户通常不需要设置或理解该字段。 工作流可以是用户名、控制器名或特定应用路径的名称,如 “ci-cd”。 字段集始终存在于修改对象时工作流使用的版本。

    ManagedFieldsEntry 是一个 workflow-id,一个 FieldSet,也是该字段集适用的资源的组版本。

    • managedFields.apiVersion (string)

      apiVersion 定义此字段集适用的资源的版本。 格式是 “group/version”,就像顶级 apiVersion 字段一样。 必须跟踪字段集的版本,因为它不能自动转换。

    • managedFields.fieldsType (string)

      FieldsType 是不同字段格式和版本的鉴别器。 目前只有一个可能的值:“FieldsV1”

    • managedFields.fieldsV1 (FieldsV1)

      FieldsV1 包含类型 “FieldsV1” 中描述的第一个 JSON 版本格式。

      FieldsV1 以 JSON 格式将一组字段存储在像 Trie 这样的数据结构中。

      每个键或是 . 表示字段本身,并且始终映射到一个空集, 或是一个表示子字段或元素的字符串。该字符串将遵循以下四种格式之一:

      1. f:<name>,其中 <name> 是结构中字段的名称,或映射中的键
      2. v:<value>,其中 <value> 是列表项的精确 json 格式值
      3. i:<index>,其中 <index> 是列表中项目的位置
      4. k:<keys>,其中 <keys> 是列表项的关键字段到其唯一值的映射 如果一个键映射到一个空的 Fields 值,则该键表示的字段是集合的一部分。

      确切的格式在 sigs.k8s.io/structured-merge-diff 中定义。

    • managedFields.manager (string)

      manager 是管理这些字段的工作流的标识符。

    • managedFields.operation (string)

      operation 是导致创建此 managedFields 表项的操作类型。 此字段的仅有合法值是 “Apply” 和 “Update”。

    • managedFields.subresource (string)

      subresource 是用于更新该对象的子资源的名称,如果对象是通过主资源更新的,则为空字符串。 该字段的值用于区分管理者,即使他们共享相同的名称。例如,状态更新将不同于使用相同管理者名称的常规更新。 请注意,apiVersion 字段与 subresource 字段无关,它始终对应于主资源的版本。

    • managedFields.time (Time)

      time 是设置这些字段的时间戳。如果 operation 为 “Apply”,则它应始终为空

      time 是 time.Time 的包装类,支持正确地序列化为 YAML 和 JSON。 为 time 包提供的许多工厂方法提供了包装类。

  • ownerReferences ([]OwnerReference)

    补丁策略:在键 uid 上执行合并操作

    此对象所依赖的对象列表。如果列表中的所有对象都已被删除,则该对象将被垃圾回收。 如果此对象由控制器管理,则此列表中的条目将指向此控制器,controller 字段设置为 true。 管理控制器不能超过一个。

    OwnerReference 包含足够可以让你识别拥有对象的信息。 拥有对象必须与依赖对象位于同一命名空间中,或者是集群作用域的,因此没有命名空间字段。

只读字段

  • creationTimestamp (Time)

    creationTimestamp 是一个时间戳,表示创建此对象时的服务器时间。 不能保证在单独的操作中按发生前的顺序设置。 客户端不得设置此值。它以 RFC3339 形式表示,并采用 UTC。

    由系统填充。只读。列表为空。更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

    time 是 time.Time 的包装类,支持正确地序列化为 YAML 和 JSON。 为 time 包提供的许多工厂方法提供了包装类。

  • deletionGracePeriodSeconds (int64)

    此对象从系统中删除之前允许正常终止的秒数。 仅当设置了 deletionTimestamp 时才设置。 只能缩短。只读。

  • deletionTimestamp (Time)

    deletionTimestamp 是删除此资源的 RFC 3339 日期和时间。 该字段在用户请求优雅删除时由服务器设置,客户端不能直接设置。 一旦 finalizers 列表为空,该资源预计将在此字段中的时间之后被删除 (不再从资源列表中可见,并且无法通过名称访问)。 只要 finalizers 列表包含项目,就阻止删除。一旦设置了 deletionTimestamp, 该值可能不会被取消设置或在未来进一步设置,尽管它可能会缩短或在此时间之前可能会删除资源。 例如,用户可能要求在 30 秒内删除一个 Pod。 Kubelet 将通过向 Pod 中的容器发送优雅的终止信号来做出反应。 30 秒后,Kubelet 将向容器发送硬终止信号(SIGKILL), 并在清理后从 API 中删除 Pod。在网络存在分区的情况下, 此对象可能在此时间戳之后仍然存在,直到管理员或自动化进程可以确定资源已完全终止。 如果未设置,则未请求优雅删除该对象。

    请求优雅删除时由系统填充。只读。更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

    “Time 是 time.Time 的包装类,支持正确地序列化为 YAML 和 JSON。 为 time 包提供的许多工厂方法提供了包装类。”

  • generation (int64)

    表示期望状态的特定生成的序列号。由系统填充。只读。

  • resourceVersion (string)

    一个不透明的值,表示此对象的内部版本,客户端可以使用该值来确定对象是否已被更改。 可用于乐观并发、变更检测以及对资源或资源集的监听操作。 客户端必须将这些值视为不透明的,且未更改地传回服务器。 它们可能仅对特定资源或一组资源有效。

    由系统填充。只读。客户端必须将值视为不透明。 更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency

  • selfLink (string)

    selfLink 是表示此对象的 URL。由系统填充。只读。

    已弃用。Kubernetes 将在 1.20 版本中停止传播该字段,并计划在 1.21 版本中删除该字段。

  • uid (string)

    UID 是该对象在时间和空间上的唯一值。它通常由服务器在成功创建资源时生成,并且不允许使用 PUT 操作更改。

    由系统填充。只读。更多信息: http://kubernetes.io/docs/user-guide/identifiers#uids

忽略字段

  • clusterName (string)

    已弃用:clusterName 是一个总是被系统清除并且从未使用过的遗留字段;它将在 1.25 中完全删除。 go 结构体中的对应字段名称已更改,以帮助客户端检测意外使用。

9.8 - ObjectReference

ObjectReference 包含足够的信息,可以让你检查或修改引用的对象。

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

ObjectReference包含足够的信息,允许你检查或修改引用的对象。


9.9 - Patch

提供 Patch 是为了给 Kubernetes PATCH 请求正文提供一个具体的名称和类型。

import "k8s.io/apimachinery/pkg/apis/meta/v1"

提供 Patch 是为了给 Kubernetes PATCH 请求正文提供一个具体的名称和类型。


9.10 - Quantity

数量(Quantity)是数字的定点表示。

import "k8s.io/apimachinery/pkg/api/resource"

数量(Quantity)是数字的定点表示。 除了 String() 和 AsInt64() 的访问接口之外, 它以 JSON 和 YAML形式提供方便的打包和解包方法。

序列化格式如下:

<quantity>        ::= <signedNumber><suffix>
  (注意 <suffix> 可能为空,例如 <decimalSI> 的 "" 情形。) </br>
<digit>           ::= 0 | 1 | ... | 9 </br>
<digits>          ::= <digit> | <digit><digits> </br>
<number>          ::= <digits> | <digits>.<digits> | <digits>. | .<digits> </br>
<sign>            ::= "+" | "-" </br>
<signedNumber>    ::= <number> | <sign><number> </br>
<suffix>          ::= <binarySI> | <decimalExponent> | <decimalSI> </br>
<binarySI>        ::= Ki | Mi | Gi | Ti | Pi | Ei 
  (国际单位制度;查阅: http://physics.nist.gov/cuu/Units/binary.html)</br>
<decimalSI>       ::= m | "" | k | M | G | T | P | E 
  (注意,1024 = 1ki 但 1000 = 1k;我没有选择大写。) </br>
<decimalExponent> ::= "e" <signedNumber> | "E" <signedNumber> </br>

无论使用三种指数形式中哪一种,没有数量可以表示大于 263-1 的数,也不可能超过 3 个小数位。 更大或更精确的数字将被截断或向上取整。(例如:0.1m 将向上取整为 1m。) 如果将来我们需要更大或更小的数量,可能会扩展。

当从字符串解析数量时,它将记住它具有的后缀类型,并且在序列化时将再次使用相同类型。

在序列化之前,数量将以“规范形式”放置。这意味着指数或者后缀将被向上或向下调整(尾数相应增加或减少),并确保:

  1. 没有精度丢失
  2. 不会输出小数数字
  3. 指数(或后缀)尽可能大。 除非数量是负数,否则将省略正负号。

例如:

  • 1.5 将会被序列化成 “1500m”
  • 1.5Gi 将会被序列化成 “1536Mi”

请注意,数量永远不会在内部以浮点数表示。这是本设计的重中之重。

只要它们格式正确,非规范值仍将解析,但将以其规范形式重新输出。(所以应该总是使用规范形式,否则不要执行 diff 比较。)

这种格式旨在使得很难在不撰写某种特殊处理代码的情况下使用这些数字,进而希望实现者也使用定点实现。


9.11 - ResourceFieldSelector

ResourceFieldSelector 表示容器资源(CPU,内存)及其输出格式。

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

ResourceFieldSelector 表示容器资源(CPU,内存)及其输出格式。


  • resource (string), 必选

    必选:选择的资源

  • containerName (string)

    容器名称:对卷必选,对环境变量可选

  • divisor (Quantity)

    指定所曝光资源的输出格式,默认值为“1”

9.12 - Status

状态(Status)是不返回其他对象的调用的返回值。

import "k8s.io/apimachinery/pkg/apis/meta/v1"

状态(Status)是不返回其他对象的调用的返回值。


  • apiVersion (string)

    APIVersion 定义对象表示的版本化模式。 服务器应将已识别的模式转换为最新的内部值,并可能拒绝无法识别的值。 更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources

  • code (int32)

    此状态的建议 HTTP 返回代码,如果未设置,则为 0。

  • details (StatusDetails)

    与原因(Reason)相关的扩展数据。每个原因都可以定义自己的扩展细节。 此字段是可选的,并且不保证返回的数据符合任何模式,除非由原因类型定义。

    StatusDetails 是一组附加属性,可以由服务器设置以提供有关响应的附加信息。 状态对象的原因字段定义将设置哪些属性。 客户端必须忽略与每个属性的定义类型不匹配的字段,并且应该假定任何属性可能为空、无效或未定义。

    • details.causes ([]StatusCause)

      Causes 数组包含与 StatusReason 故障相关的更多详细信息。 并非所有 StatusReasons 都可以提供详细的原因。

      StatusCause 提供有关 api.Status 失败的更多信息,包括遇到多个错误的情况。

      • details.causes.field (string)

        导致此错误的资源字段,由其 JSON 序列化命名。 可能包括嵌套属性的点和后缀表示法。数组是从零开始索引的。 由于字段有多个错误,字段可能会在一系列原因中出现多次。可选。

        示例:

        • “name”:当前资源上的字段 “name”
        • “items[0].name”:“items” 中第一个数组条目上的字段 “name”
      • details.causes.message (string)

        对错误原因的可读描述。该字段可以按原样呈现给读者。

      • details.causes.reason (string)

        错误原因的机器可读描述。如果此值为空,则没有可用信息。

    • details.group (string)

      与状态 StatusReason 关联的资源的组属性。

    • details.kind (string)

      与状态 StatusReason 关联的资源的种类属性。 在某些操作上可能与请求的资源种类不同。 更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds

    • details.name (string)

      与状态 StatusReason 关联的资源的名称属性(当有一个可以描述的名称时)。

    • details.retryAfterSeconds (int32)

      如果指定,则应重试操作前的时间(以秒为单位)。 一些错误可能表明客户端必须采取替代操作——对于这些错误,此字段可能指示在采取替代操作之前等待多长时间。

    • details.uid (string)

      资源的 UID(当有单个可以描述的资源时)。 更多信息: http://kubernetes.io/docs/user-guide/identifiers#uids

  • kind (string)

    Kind 是一个字符串值,表示此对象表示的 REST 资源。 服务器可以从客户端提交请求的端点推断出这一点。 无法更新。驼峰式规则。 更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds

  • message (string)

    此操作状态的人类可读描述。

  • metadata (ListMeta)

    标准列表元数据。 更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds

  • reason (string)

    机器可读的说明,说明此操作为何处于“失败”状态。 如果此值为空,则没有可用信息。 Reason 澄清了 HTTP 状态代码,但不会覆盖它。

  • status (string)

    操作状态。“Success”或“Failure” 之一。 更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status

9.13 - TypedLocalObjectReference

TypedLocalObjectReference 包含足够的信息,可以让你在同一个名称空间中定位指定类型的引用对象。

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

TypedLocalObjectReference 包含足够的信息,可以让你在同一个名称空间中定位特定类型的引用对象。


  • kind (string), 必需

    Kind 是被引用的资源的类型

  • name (string), 必需

    Name 是被引用的资源的名称

  • apiGroup (string)

    APIGroup 是被引用资源的组。如果不指定 APIGroup,则指定的 Kind 必须在核心 API 组中。对于任何其它第三方类型,都需要 APIGroup。

10 - 常用参数

allowWatchBookmarks

allowWatchBookmarks 字段请求类型为 BOOKMARK 的监视事件。 没有实现书签的服务器可能会忽略这个标志,并根据服务器的判断发送书签。 客户端不应该假设书签会在任何特定的时间间隔返回,也不应该假设服务器会在会话期间发送任何书签事件。 如果当前请求不是 watch 请求,则忽略该字段。


continue

当需要从服务器检索更多结果时,应该设置 continue 选项。由于这个值是服务器定义的, 客户端只能使用先前查询结果中具有相同查询参数的 continue 值(continue值除外), 服务器可能拒绝它识别不到的 continue 值。 如果指定的 continue 值不再有效,无论是由于过期(通常是 5 到 15 分钟) 还是服务器上的配置更改,服务器将响应 "410 ResourceExpired" 错误和一个 continue 令牌。

如果客户端需要一个一致的列表,它必须在没有 continue 字段的情况下重新发起 list 请求。 否则,客户端可能会发送另一个带有 410 错误令牌的 list 请求,服务器将响应从下一个键开始的列表, 但列表数据来自最新的快照,这与之前 的列表结果不一致。第一个列表请求之后的对象创建,修改,或删除的对象将被包含在响应中, 只要他们的键是在“下一个键”之后。

当 watch 字段为 true 时,不支持此字段。客户端可以从服务器返回的最后一个 resourceVersion 值开始监视,就不会错过任何修改。


dryRun

表示不应该持久化所请求的修改。无效或无法识别的 dryRun 指令将导致错误响应, 并且服务器不再对请求进行进一步处理。有效值为:

  • All: 将处理所有的演练阶段

fieldManager

fieldManager 是与进行这些更改的参与者或实体相关联的名称。 长度小于或128个字符且仅包含可打印字符,如 https://golang.org/pkg/unicode/#IsPrint 所定义。


fieldSelector

根据返回对象的字段限制返回对象列表的选择器。默认为返回所有字段。


fieldValidation

fieldValidation 指示服务器如何处理请求(POST/PUT/PATCH)中包含未知或重复字段的对象, 前提是 ServerSideFieldValidation 特性门控也已启用。

有效值为:

  • Ignore:这将忽略从对象中默默删除的所有未知字段,并将忽略除解码器遇到的最后一个重复字段之外的所有字段。 这是在 v1.23 之前的默认行为,也是当 ServerSideFieldValidation 特性门控被禁用时的默认行为。
  • Warn:这将针对从对象中删除的各个未知字段以及所遇到的各个重复字段,分别通过标准警告响应头发出警告。 如果没有其他错误,请求仍然会成功,并且只会保留所有重复字段中的最后一个。 这是启用 ServerSideFieldValidation 特性门控时的默认值。
  • Strict:如果从对象中删除任何未知字段,或者存在任何重复字段,将使请求失败并返回 BadRequest 错误。

force

Force 将“强制”应用请求。这意味着用户将重新获得他人拥有的冲突领域。 对于非应用补丁请求,Force 标志必须不设置。


gracePeriodSeconds

删除对象前的持续时间(秒数)。值必须为非负整数。取值为 0 表示立即删除。 如果该值为 nil,将使用指定类型的默认宽限期。如果没有指定,默认为每个对象的设置值。0 表示立即删除。


labelSelector

通过标签限制返回对象列表的选择器。默认为返回所有对象。


limit

limit 是一个列表调用返回的最大响应数。如果有更多的条目,服务器会将列表元数据上的 'continue' 字段设置为一个值,该值可以用于相同的初始查询来检索下一组结果。

设置 limit 可能会在所有请求的对象被过滤掉的情况下返回少于请求的条目数量(下限为零), 并且客户端应该只根据 continue 字段是否存在来确定是否有更多的结果可用。 服务器可能选择不支持 limit 参数,并将返回所有可用的结果。 如果指定了 limit 并且 continue 字段为空,客户端可能会认为没有更多的结果可用。 如果 watch 为 true,则不支持此字段。

服务器保证在使用 continue 时返回的对象将与不带 limit 的列表调用相同,—— 也就是说,在发出第一个请求后所创建、修改或删除的对象将不包含在任何后续的继续请求中。

这有时被称为一致性快照,确保使用 limit 的客户端在分块接收非常大的结果的客户端能够看到所有可能的对象。 如果对象在分块列表期间被更新,则返回计算第一个列表结果时存在的对象版本。


namespace

对象名称和身份验证范围,例如用于团队和项目。


pretty

如果设置为 'true' ,那么输出是规范的打印。


propagationPolicy

该字段决定是否以及如何执行垃圾收集。可以设置此字段或 OrphanDependents,但不能同时设置。 默认策略由 metadata.finalizers 和特定资源的默认策略设置决定。可接受的值是:

  • 'Orphan':孤立依赖项;
  • 'Background':允许垃圾回收器后台删除依赖;
  • 'Foreground':一个级联策略,前台删除所有依赖项。

resourceVersion

resourceVersion 对请求所针对的资源版本设置约束。 详情请参见 https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions

默认不设置


resourceVersionMatch

resourceVersionMatch 字段决定如何将 resourceVersion 应用于列表调用。 强烈建议对设置了 resourceVersion 的列表调用设置 resourceVersion 匹配, 具体请参见 https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions

默认不设置


timeoutSeconds

list/watch 调用的超时秒数。这选项限制调用的持续时间,无论是否有活动。


watch

监视对所述资源的更改,并将其这类变更以添加、更新和删除通知流的形式返回。指定 resourceVersion。