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

返回本页常规视图.

Kubernetes API

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

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

1 - 工作负载资源

1.1 - Pod

Pod 是可以在主机上运行的容器的集合。

apiVersion: v1

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

Pod

Pod 是可以在主机上运行的容器的集合。此资源由客户端创建并调度到主机上。


  • apiVersion: v1

  • kind: Pod

PodSpec

PodSpec 是对 Pod 的描述。


容器

  • containers ([]Container),必需

    补丁策略:基于 name 键合并

    属于 Pod 的容器列表。当前无法添加或删除容器。Pod 中必须至少有一个容器。无法更新。

  • initContainers ([]Container)

    补丁策略:基于 name 键合并

    属于 Pod 的 Init 容器列表。Init 容器在容器启动之前按顺序执行。 如果任何一个 Init 容器发生故障,则认为该 Pod 失败,并根据其 restartPolicy 处理。 Init 容器或普通容器的名称在所有容器中必须是唯一的。 Init 容器不可以有生命周期操作、就绪态探针、存活态探针或启动探针。 在调度过程中会考虑 Init 容器的资源需求,方法是查找每种资源类型的最高请求/限制, 然后使用该值的最大值或正常容器的资源请求的总和。 对资源限制以类似的方式应用于 Init 容器。当前无法添加或删除 Init 容器。无法更新。更多信息: https://kubernetes.io/zh-cn/docs/concepts/workloads/pods/init-containers/

  • ephemeralContainers ([]EphemeralContainer)

    补丁策略:基于 name 键合并

    在此 Pod 中运行的临时容器列表。临时容器可以在现有的 Pod 中运行,以执行用户发起的操作,例如调试。 此列表在创建 Pod 时不能指定,也不能通过更新 Pod 规约来修改。 要将临时容器添加到现有 Pod,请使用 Pod 的 ephemeralcontainers 子资源。

  • enableServiceLinks (boolean)

    enableServiceLinks 指示是否应将有关服务的信息注入到 Pod 的环境变量中,服务连接的语法与 Docker links 的语法相匹配。可选。默认为 true。

  • os (PodOS)

    指定 Pod 中容器的操作系统。如果设置了此属性,则某些 Pod 和容器字段会受到限制。

    如果 os 字段设置为 linux,则必须不能设置以下字段:

    • securityContext.windowsOptions

    如果 os 字段设置为 windows,则必须不能设置以下字段:

    • spec.hostPID
    • spec.hostIPC
    • spec.hostUsers
    • spec.securityContext.seLinuxOptions
    • spec.securityContext.seccompProfile
    • spec.securityContext.fsGroup
    • spec.securityContext.fsGroupChangePolicy
    • spec.securityContext.sysctls
    • spec.shareProcessNamespace
    • spec.securityContext.runAsUser
    • spec.securityContext.runAsGroup
    • spec.securityContext.supplementalGroups
    • spec.containers[*].securityContext.seLinuxOptions
    • spec.containers[*].securityContext.seccompProfile
    • spec.containers[*].securityContext.capabilities
    • spec.containers[*].securityContext.readOnlyRootFilesystem
    • spec.containers[*].securityContext.privileged
    • spec.containers[*].securityContext.allowPrivilegeEscalation
    • spec.containers[*].securityContext.procMount
    • spec.containers[*].securityContext.runAsUser
    • spec.containers[*].securityContext.runAsGroup

    PodOS 定义一个 Pod 的操作系统参数。

调度

  • nodeName (string)

    nodeName 是将此 Pod 调度到特定节点的请求。 如果字段值不为空,调度器只是直接将这个 Pod 调度到所指定节点上,假设节点符合资源要求。

  • affinity (Affinity)

    如果指定了,则作为 Pod 的调度约束。

    Affinity 是一组亲和性调度规则。

    • affinity.nodeAffinity (NodeAffinity)

      描述 Pod 的节点亲和性调度规则。

    • affinity.podAffinity (PodAffinity)

      描述 Pod 亲和性调度规则(例如,将此 Pod 与其他一些 Pod 放在同一节点、区域等)。

    • affinity.podAntiAffinity (PodAntiAffinity)

      描述 Pod 反亲和性调度规则(例如,避免将此 Pod 与其他一些 Pod 放在相同的节点、区域等)。

  • tolerations ([]Toleration)

    如果设置了此字段,则作为 Pod 的容忍度。

    这个 Toleration 所附加到的 Pod 能够容忍任何使用匹配运算符 <operator> 匹配三元组 <key,value,effect> 所得到的污点。

    • tolerations.key (string)

      key 是容忍度所适用的污点的键名。此字段为空意味着匹配所有的污点键。 如果 key 为空,则 operator 必须为 Exists;这种组合意味着匹配所有值和所有键。

    • tolerations.operator (string)

      operator 表示 key 与 value 之间的关系。有效的 operator 取值是 ExistsEqual。默认为 EqualExists 相当于 value 为某种通配符,因此 Pod 可以容忍特定类别的所有污点。

    • tolerations.value (string)

      value 是容忍度所匹配的污点值。如果 operator 为 Exists,则此 value 值应该为空, 否则 value 值应该是一个正常的字符串。

    • tolerations.effect (string)

      effect 指示要匹配的污点效果。空值意味著匹配所有污点效果。如果要设置此字段,允许的值为 NoSchedulePreferNoScheduleNoExecute 之一。

    • tolerations.tolerationSeconds (int64)

      tolerationSeconds 表示容忍度(effect 必须是 NoExecute,否则此字段被忽略)容忍污点的时间长度。 默认情况下,此字段未被设置,这意味着会一直能够容忍对应污点(不会发生驱逐操作)。 零值和负值会被系统当做 0 值处理(立即触发驱逐)。

  • schedulerName (string)

    如果设置了此字段,则 Pod 将由指定的调度器调度。如果未指定,则使用默认调度器来调度 Pod。

  • runtimeClassName (string)

    runtimeClassName 引用 node.k8s.io 组中的一个 RuntimeClass 对象,该 RuntimeClass 将被用来运行这个 Pod。 如果没有 RuntimeClass 资源与所设置的类匹配,则 Pod 将不会运行。 如果此字段未设置或为空,将使用 "旧版" RuntimeClass。 "旧版" RuntimeClass 可以视作一个隐式的运行时类,其定义为空,会使用默认运行时处理程序。 更多信息: https://git.k8s.io/enhancements/keps/sig-node/585-runtime-class

  • priorityClassName (string)

    如果设置了此字段,则用来标明 Pod 的优先级。 "system-node-critical""system-cluster-critical" 是两个特殊关键字, 分别用来表示两个最高优先级,前者优先级更高一些。 任何其他名称都必须通过创建具有该名称的 PriorityClass 对象来定义。 如果未指定此字段,则 Pod 优先级将为默认值。如果没有默认值,则为零。

  • priority (int32)

    优先级值。各种系统组件使用该字段来确定 Pod 的优先级。当启用 Priority 准入控制器时, 该控制器会阻止用户设置此字段。准入控制器基于 priorityClassName 设置来填充此字段。 字段值越高,优先级越高。

  • preemptionPolicy (string)

    preemptionPolicy 是用来抢占优先级较低的 Pod 的策略。取值为 "Never""PreemptLowerPriority" 之一。 如果未设置,则默认为 "PreemptLowerPriority"

  • topologySpreadConstraints ([]TopologySpreadConstraint)

    补丁策略:基于 topologyKey 键合并

    映射:topologyKey, whenUnsatisfiable 键组合的唯一值 將在合并期间保留

    TopologySpreadConstraints 描述一组 Pod 应该如何跨拓扑域来分布。调度器将以遵从此约束的方式来调度 Pod。 所有 topologySpreadConstraints 条目会通过逻辑与操作进行组合。

    TopologySpreadConstraint 指定如何在规定的拓扑下分布匹配的 Pod。

    • topologySpreadConstraints.maxSkew (int32),必需

      maxSkew 描述 Pod 可能分布不均衡的程度。当 whenUnsatisfiable=DoNotSchedule 时, 此字段值是目标拓扑中匹配的 Pod 数量与全局最小值之间的最大允许差值。 全局最小值是候选域中匹配 Pod 的最小数量,如果候选域的数量小于 minDomains,则为零。 例如,在一个包含三个可用区的集群中,maxSkew 设置为 1,具有相同 labelSelector 的 Pod 分布为 2/2/1: 在这种情况下,全局最小值为 1。

      | zone1 | zone2 | zone3 |
      | PP    | PP    |  P    |
      
      • 如果 maxSkew 为 1,传入的 Pod 只能调度到 "zone3",变成 2/2/2; 将其调度到 "zone1"("zone2")将使"zone1"("zone2")上的实际偏差(Actual Skew)为 3-1,进而违反 maxSkew 限制(1)。
      • 如果 maxSkew 为 2,则可以将传入的 Pod 调度到任何区域。

      whenUnsatisfiable=ScheduleAnyway 时,此字段被用来给满足此约束的拓扑域更高的优先级。

      此字段是一个必填字段。默认值为 1,不允许为 0。

    • topologySpreadConstraints.topologyKey (string),必需

      topologyKey 是节点标签的键名。如果节点的标签中包含此键名且键值亦相同,则被认为在相同的拓扑域中。 我们将每个 <键, 值> 视为一个 "桶(Bucket)",并尝试将数量均衡的 Pod 放入每个桶中。 我们定义域(Domain)为拓扑域的特定实例。 此外,我们定义一个候选域(Eligible Domain)为其节点与 nodeAffinityPolicy 和 nodeTaintsPolicy 的要求匹配的域。 例如,如果 topologyKey 是 "kubernetes.io/hostname",则每个 Node 都是该拓扑的域。 而如果 topologyKey 是 "topology.kubernetes.io/zone",则每个区域都是该拓扑的一个域。 这是一个必填字段。

    • topologySpreadConstraints.whenUnsatisfiable (string),必需

      whenUnsatisfiable 表示如果 Pod 不满足分布约束,如何处理它。

      • DoNotSchedule(默认):告诉调度器不要调度它。
      • ScheduleAnyway:告诉调度器将 Pod 调度到任何位置,但给予能够降低偏差的拓扑更高的优先级。

      当且仅当该 Pod 的每个可能的节点分配都会违反某些拓扑对应的 "maxSkew" 时, 才认为传入 Pod 的约束是 "不可满足的"。

      例如,在一个包含三个区域的集群中,maxSkew 设置为 1,具有相同 labelSelector 的 Pod 分布为 3/1/1:

      | zone1 | zone2 | zone3 |
      | P P P | P     | P     |
      

      如果 whenUnsatisfiable 设置为 DoNotSchedule,则传入的 Pod 只能调度到 "zone2"("zone3"), Pod 分布变成 3/2/1(3/1/2),因为 "zone2"("zone3")上的实际偏差(Actual Skew) 为 2-1, 满足 maxSkew 约束(1)。 换句话说,集群仍然可以不平衡,但调度器不会使其更加地不平衡。

      这是一个必填字段。

    • topologySpreadConstraints.labelSelector (LabelSelector)

      labelSelector 用于识别匹配的 Pod。对匹配此标签选择算符的 Pod 进行计数, 以确定其相应拓扑域中的 Pod 数量。

    • topologySpreadConstraints.matchLabelKeys ([]string)

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

    matchLabelKeys 是一组 Pod 标签键,用于通过计算 Pod 分布方式来选择 Pod。 新 Pod 标签中不存在的键将被忽略。这些键用于从新来的 Pod 标签中查找值,这些键值标签与 labelSelector 进行逻辑与运算, 通过计算 Pod 的分布方式来选择现有 Pod 的组。matchLabelKeys 和 labelSelector 中禁止存在相同的键。未设置 labelSelector 时无法设置 matchLabelKeys。 新来的 Pod 标签中不存在的键将被忽略。null 或空的列表意味着仅与 labelSelector 匹配。

    这是一个 Beta 字段,需要启用 MatchLabelKeysInPodTopologySpread 特性门控(默认启用)。

    • topologySpreadConstraints.minDomains (int32)

      minDomains 表示符合条件的域的最小数量。当符合拓扑键的候选域个数小于 minDomains 时, Pod 拓扑分布特性会将 "全局最小值" 视为 0,然后进行偏差的计算。 当匹配拓扑键的候选域的数量等于或大于 minDomains 时,此字段的值对调度没有影响。 因此,当候选域的数量少于 minDomains 时,调度程序不会将超过 maxSkew 个 Pods 调度到这些域。 如果字段值为 nil,所表达的约束为 minDomains 等于 1。 字段的有效值为大于 0 的整数。当字段值不为 nil 时,whenUnsatisfiable 必须为 DoNotSchedule

      例如,在一个包含三个区域的集群中,maxSkew 设置为 2,minDomains 设置为 5,具有相同 labelSelector 的 Pod 分布为 2/2/2:

      | zone1 | zone2 | zone3 |
      | PP    | PP    | PP    |
      

      域的数量小于 5(minDomains 取值),因此"全局最小值"被视为 0。 在这种情况下,无法调度具有相同 labelSelector 的新 Pod,因为如果基于新 Pod 计算的偏差值将为 3(3-0)。将这个 Pod 调度到三个区域中的任何一个,都会违反 maxSkew 约束。

      此字段是一个 Beta 字段,需要启用 MinDomainsInPodTopologySpread 特性门控(默认被启用)。

    • topologySpreadConstraints.nodeAffinityPolicy (string)

      nodeAffinityPolicy 表示我们在计算 Pod 拓扑分布偏差时将如何处理 Pod 的 nodeAffinity/nodeSelector。 选项为:

      • Honor:只有与 nodeAffinity/nodeSelector 匹配的节点才会包括到计算中。
      • Ignore:nodeAffinity/nodeSelector 被忽略。所有节点均包括到计算中。

      如果此值为 nil,此行为等同于 Honor 策略。 这是通过 NodeInclusionPolicyInPodTopologySpread 特性标志默认启用的 Beta 级别特性。

    • topologySpreadConstraints.nodeTaintsPolicy (string)

    nodeTaintsPolicy 表示我们在计算 Pod 拓扑分布偏差时将如何处理节点污点。选项为:

    • Honor:包括不带污点的节点以及新来 Pod 具有容忍度且带有污点的节点。
    • Ignore:节点污点被忽略。包括所有节点。

    如果此值为 nil,此行为等同于 Ignore 策略。 这是通过 NodeInclusionPolicyInPodTopologySpread 特性标志默认启用的 Beta 级别特性。

  • overhead (map[string]Quantity)

    overhead 表示与用指定 RuntimeClass 运行 Pod 相关的资源开销。 该字段将由 RuntimeClass 准入控制器在准入时自动填充。 如果启用了 RuntimeClass 准入控制器,则不得在 Pod 创建请求中设置 overhead 字段。 RuntimeClass 准入控制器将拒绝已设置 overhead 字段的 Pod 创建请求。 如果在 Pod 规约中配置并选择了 RuntimeClass,overhead 字段将被设置为对应 RuntimeClass 中定义的值, 否则将保持不设置并视为零。更多信息: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md

生命周期

  • terminationGracePeriodSeconds (int64)

    可选字段,表示 Pod 需要体面终止的所需的时长(以秒为单位)。字段值可以在删除请求中减少。 字段值必须是非负整数。零值表示收到 kill 信号则立即停止(没有机会关闭)。 如果此值为 nil,则将使用默认宽限期。 宽限期是从 Pod 中运行的进程收到终止信号后,到进程被 kill 信号强制停止之前,Pod 可以继续存在的时间(以秒为单位)。 应该将此值设置为比你的进程的预期清理时间更长。默认为 30 秒。

  • activeDeadlineSeconds (int64)

    在系统将主动尝试将此 Pod 标记为已失败并杀死相关容器之前,Pod 可能在节点上活跃的时长; 时长计算基于 startTime 计算(以秒为单位)。字段值必须是正整数。

  • readinessGate ([]PodReadinessGate)

    如果设置了此字段,则将评估所有就绪门控(Readiness Gate)以确定 Pod 就绪状况。 当所有容器都已就绪,并且就绪门控中指定的所有状况的 status 都为 "true" 时,Pod 被视为就绪。 更多信息: https://git.k8s.io/enhancements/keps/sig-network/580-pod-readiness-gates

    PodReadinessGate 包含对 Pod 状况的引用

    • readinessGates.conditionType (string),必需

      conditionType 是指 Pod 的状况列表中类型匹配的状况。

主机名和名称解析

  • hostname (string)

    指定 Pod 的主机名。如果此字段未指定,则 Pod 的主机名将设置为系统定义的值。

  • setHostnameAsFQDN (boolean)

    如果为 true,则 Pod 的主机名将配置为 Pod 的 FQDN,而不是叶名称(默认值)。 在 Linux 容器中,这意味着将内核的 hostname 字段(struct utsname 的 nodename 字段)设置为 FQDN。 在 Windows 容器中,这意味着将注册表项 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters 的 hostname 键设置为 FQDN。如果 Pod 没有 FQDN,则此字段不起作用。 默认为 false。

  • subdomain (string)

    如果设置了此字段,则完全限定的 Pod 主机名将是 <hostname>.<subdomain>.<Pod 名字空间>.svc.<集群域名>。 如果未设置此字段,则该 Pod 将没有域名。

  • hostAliases ([]HostAlias)

    补丁策略:基于 ip 键合并

    hostAliases 是一个可选的列表属性,包含要被注入到 Pod 的 hosts 文件中的主机和 IP 地址。 这仅对非 hostNetwork Pod 有效。

    HostAlias 结构保存 IP 和主机名之间的映射,这些映射将作为 Pod 的 hosts 文件中的条目注入。

    • hostAliases.hostnames ([]string)

      指定 IP 地址对应的主机名。

    • hostAliases.ip (string)

      主机文件条目的 IP 地址。

  • dnsConfig (PodDNSConfig)

    指定 Pod 的 DNS 参数。此处指定的参数将被合并到基于 dnsPolicy 生成的 DNS 配置中。

    PodDNSConfig 定义 Pod 的 DNS 参数,这些参数独立于基于 dnsPolicy 生成的参数。

    • dnsConfig.nameservers ([]string)

      DNS 名字服务器的 IP 地址列表。此列表将被追加到基于 dnsPolicy 生成的基本名字服务器列表。 重复的名字服务器将被删除。

    • dnsConfig.options ([]PodDNSConfigOption)

      DNS 解析器选项列表。此处的选项将与基于 dnsPolicy 所生成的基本选项合并。重复的条目将被删除。 options 中所给出的解析选项将覆盖基本 dnsPolicy 中出现的对应选项。

      PodDNSConfigOption 定义 Pod 的 DNS 解析器选项。

      • dnsConfig.options.name (string)

        必需字段。

      • dnsConfig.options.value (string)

        选项取值。

    • dnsConfig.searches ([]string)

      用于主机名查找的 DNS 搜索域列表。这一列表将被追加到基于 dnsPolicy 生成的基本搜索路径列表。 重复的搜索路径将被删除。

  • dnsPolicy (string)

    为 Pod 设置 DNS 策略。默认为 "ClusterFirst"。 有效值为 "ClusterFirstWithHostNet""ClusterFirst""Default""None"。 dnsConfig 字段中给出的 DNS 参数将与使用 dnsPolicy 字段所选择的策略合并。 要针对 hostNetwork 的 Pod 设置 DNS 选项,你必须将 DNS 策略显式设置为 "ClusterFirstWithHostNet"

主机名字空间

  • hostNetwork (boolean)

    为此 Pod 请求主机层面联网支持。使用主机的网络名字空间。 如果设置了此选项,则必须指定将使用的端口。默认为 false。

  • hostPID (boolean)

    使用主机的 PID 名字空间。可选:默认为 false。

  • hostIPC (boolean)

    使用主机的 IPC 名字空间。可选:默认为 false。

  • shareProcessNamespace (boolean)

    在 Pod 中的所有容器之间共享单个进程名字空间。设置了此字段之后,容器将能够查看来自同一 Pod 中其他容器的进程并发出信号, 并且每个容器中的第一个进程不会被分配 PID 1。hostPIDshareProcessNamespace 不能同时设置。 可选:默认为 false。

服务账号

安全上下文

  • securityContext (PodSecurityContext)

    SecurityContext 包含 Pod 级别的安全属性和常见的容器设置。 可选:默认为空。每个字段的默认值见类型描述。

    PodSecurityContext 包含 Pod 级别的安全属性和常用容器设置。 一些字段也存在于 container.securityContext 中。container.securityContext 中的字段值优先于 PodSecurityContext 的字段值。

    • securityContext.runAsUser (int64)

      运行容器进程入口点(Entrypoint)的 UID。如果未指定,则默认为镜像元数据中指定的用户。 也可以在 SecurityContext 中设置。 如果同时在 SecurityContext 和 PodSecurityContext 中设置,则在对应容器中所设置的 SecurityContext 值优先。 注意,spec.os.name 为 "windows" 时不能设置此字段。

    • securityContext.runAsNonRoot (boolean)

      指示容器必须以非 root 用户身份运行。如果为 true,kubelet 将在运行时验证镜像, 以确保它不会以 UID 0(root)身份运行。如果镜像中确实使用 root 账号启动,则容器无法被启动。 如果此字段未设置或为 false,则不会执行此类验证。也可以在 SecurityContext 中设置。 如果同时在 SecurityContext 和 PodSecurityContext 中设置,则在 SecurityContext 中指定的值优先。

    • securityContext.runAsGroup (int64)

      运行容器进程入口点(Entrypoint)的 GID。如果未设置,则使用运行时的默认值。 也可以在 SecurityContext 中设置。如果同时在 SecurityContext 和 PodSecurityContext 中设置, 则在对应容器中设置的 SecurityContext 值优先。 注意,spec.os.name 为 "windows" 时不能设置该字段。

    • securityContext.supplementalGroups ([]int64)

      此字段包含将应用到每个容器中运行的第一个进程的组列表。 容器进程的组成员身份取决于容器的主 GID、fsGroup(如果指定了的话) 和在容器镜像中为容器进程的 uid 定义的组成员身份,以及这里所给的列表。

      如果未指定,则不会向任何容器添加其他组。 注意,在容器镜像中为容器进程的 uid 定义的组成员身份仍然有效, 即使它们未包含在此列表中也是如此。 注意,当 spec.os.namewindows 时,不能设置此字段。

    • securityContext.fsGroup (int64)

      应用到 Pod 中所有容器的特殊补充组。某些卷类型允许 kubelet 将该卷的所有权更改为由 Pod 拥有:

      1. 文件系统的属主 GID 将是 fsGroup 字段值
      2. setgid 位已设置(在卷中创建的新文件将归 fsGroup 所有)
      3. 权限位将与 rw-rw---- 进行按位或操作

      如果未设置此字段,kubelet 不会修改任何卷的所有权和权限。 注意,spec.os.name 为 "windows" 时不能设置此字段。

    • securityContext.fsGroupChangePolicy (string)

      fsGroupChangePolicy 定义了在卷被在 Pod 中暴露之前更改其属主和权限的行为。 此字段仅适用于支持基于 fsGroup 的属主权(和权限)的卷类型。它不会影响临时卷类型, 例如:secretconfigmapemptydir。 有效值为 "OnRootMismatch""Always"。如果未设置,则使用 "Always"。 注意,spec.os.name 为 "windows" 时不能设置此字段。

    • securityContext.seccompProfile (SeccompProfile)

      此 Pod 中的容器使用的 seccomp 选项。注意,spec.os.name 为 "windows" 时不能设置此字段。

      SeccompProfile 定义 Pod 或容器的 seccomp 配置文件设置。只能设置一个配置文件源。

      • securityContext.seccompProfile.type (string),必需

        type 标明将应用哪种 seccomp 配置文件。有效的选项有:

        • Localhost - 应使用在节点上的文件中定义的配置文件。
        • RuntimeDefault - 应使用容器运行时默认配置文件。
        • Unconfined - 不应应用任何配置文件。
      • securityContext.seccompProfile.localhostProfile (string)

        localhostProfile 指示应使用在节点上的文件中定义的配置文件。该配置文件必须在节点上预先配置才能工作。 必须是相对于 kubelet 配置的 seccomp 配置文件位置的下降路径。 仅当 type 为 "Localhost" 时才必须设置。不得为任何其他类别设置此字段。

    • securityContext.seLinuxOptions (SELinuxOptions)

      应用于所有容器的 SELinux 上下文。如果未设置,容器运行时将为每个容器分配一个随机 SELinux 上下文。 也可以在 SecurityContext 中设置。 如果同时在 SecurityContext 和 PodSecurityContext 中设置,则在对应容器中设置的 SecurityContext 值优先。 注意,spec.os.name 为 "windows" 时不能设置该字段。

      SELinuxOptions 是要应用于容器的标签

      • securityContext.seLinuxOptions.level (string)

        level 是应用于容器的 SELinux 级别标签。

      • securityContext.seLinuxOptions.role (string)

        role 是应用于容器的 SELinux 角色标签。

      • securityContext.seLinuxOptions.type (string)

        type 是适用于容器的 SELinux 类型标签。

      • securityContext.seLinuxOptions.user (string)

        user 是应用于容器的 SELinux 用户标签。

    • securityContext.sysctls ([]Sysctl)

      sysctls 包含用于 Pod 的名字空间 sysctl 列表。具有不受(容器运行时)支持的 sysctl 的 Pod 可能无法启动。 注意,spec.os.name 为 "windows" 时不能设置此字段。

      Sysctl 定义要设置的内核参数

      • securityContext.sysctls.name (string),必需

        要设置的属性的名称。

      • securityContext.sysctls.value (string),必需

        要设置的属性值。

    • securityContext.windowsOptions (WindowsSecurityContextOptions)

      要应用到所有容器上的、特定于 Windows 的设置。 如果未设置此字段,将使用容器的 SecurityContext 中的选项。 如果同时在 SecurityContext 和 PodSecurityContext 中设置,则在 SecurityContext 中指定的值优先。 注意,spec.os.name 为 "linux" 时不能设置该字段。

      WindowsSecurityContextOptions 包含特定于 Windows 的选项和凭据。

      • securityContext.windowsOptions.gmsaCredentialSpec (string)

        gmsaCredentialSpec 是 GMSA 准入 Webhook 内嵌由 gmsaCredentialSpecName 字段所指定的 GMSA 凭证规约内容的地方。

      • securityContext.windowsOptions.gmsaCredentialSpecName (string)

        gmsaCredentialSpecName 是要使用的 GMSA 凭证规约的名称。

      • securityContext.windowsOptions.hostProcess (boolean)

        hostProcess 确定容器是否应作为"主机进程"容器运行。 一个 Pod 的所有容器必须具有相同的有效 hostProcess 值(不允许混合设置了 hostProcess 的容器和未设置 hostProcess 容器)。 此外,如果 hostProcess 为 true,则 hostNetwork 也必须设置为 true。

      • securityContext.windowsOptions.runAsUserName (string)

        Windows 中用来运行容器进程入口点的用户名。如果未设置,则默认为镜像元数据中指定的用户。 也可以在 PodSecurityContext 中设置。 如果同时在 SecurityContext 和 PodSecurityContext 中设置,则在 SecurityContext 中指定的值优先。

Alpha 级别

  • hostUsers (boolean)

    使用主机的用户名字空间。可选:默认为 true。如果设置为 true 或不存在,则 Pod 将运行在主机的用户名字空间中, 当 Pod 需要仅对主机用户名字空间可用的一个特性时这会很有用,例如使用 CAP_SYS_MODULE 加载内核模块。 当设置为 false 时,会为该 Pod 创建一个新的用户名字空间。 设置为 false 对于缓解容器逃逸漏洞非常有用,可防止允许实际在主机上没有 root 特权的用户以 root 运行他们的容器。 此字段是 Alpha 级别的字段,只有启用 UserNamespacesSupport 特性的服务器才能使用此字段。

  • resourceClaims ([]PodResourceClaim)

    补丁策略:retainKeys,基于键 name 合并

    映射:键 name 的唯一值将在合并过程中保留

resourceClaims 定义了在允许 Pod 启动之前必须分配和保留哪些 ResourceClaims。 这些资源将可供那些按名称使用它们的容器使用。

这是一个 Alpha 特性的字段,需要启用 DynamicResourceAllocation 特性门控来开启此功能。

此字段不可变更。

PodResourceClaim 通过 ClaimSource 引用一个 ResourceClaim。 它为 ClaimSource 添加一个名称,作为 Pod 内 ResourceClaim 的唯一标识。 需要访问 ResourceClaim 的容器可使用此名称引用它。

  • resourceClaims.name (string), 必需

    在 Pod 中,name 是此资源声明的唯一标识。此字段值必须是 DNS_LABEL。

  • resourceClaims.source (ClaimSource)

    source 描述了在哪里可以找到 resourceClaim

    ClaimSource 描述对 ResourceClaim 的引用。

    应该设置且仅设置如下字段之一。此类型的消费者必须将空对象视为具有未知值。

    • resourceClaims.source.resourceClaimName (string)

      resourceClaimName 是与此 Pod 位于同一命名空间中的 ResourceClaim 对象的名称。

    • resourceClaims.source.resourceClaimTemplateName (string)

      resourceClaimTemplateName 是与此 Pod 位于同一命名空间中的 ResourceClaimTemplate 对象的名称。

      该模板将用于创建一个新的 ResourceClaim,新的 ResourceClaim 将被绑定到此 Pod。 删除此 Pod 时,ResourceClaim 也将被删除。 Pod 名称和资源名称,连同生成的组件,将用于为 ResourceClaim 形成唯一名称, 该名称将记录在 pod.status.resourceClaimStatuses 中。

      不属于此 Pod 但与此名称重名的现有 ResourceClaim 不会被用于此 Pod, 以避免错误地使用不相关的资源。Pod 的调度和启动动作会因此而被阻塞, 直到不相关的 ResourceClaim 被删除。

      此字段是不可变更的,创建 ResourceClaim 后控制平面不会对相应的 ResourceClaim 进行任何更改。

  • schedulingGates ([]PodSchedulingGate)

    补丁策略:基于 name 键合并

    映射:键 name 的唯一值将在合并过程中保留

    schedulingGates 是一个不透明的值列表,如果指定,将阻止调度 Pod。 如果 schedulingGates 不为空,则 Pod 将保持 SchedulingGated 状态,调度程序将不会尝试调度 Pod。

    SchedulingGates 只能在 Pod 创建时设置,并且只能在创建之后删除。

    此特性为 Beta 特性,需要通过 PodSchedulingReadiness 特性门控启用。

    PodSchedulingGate 与 Pod 相关联以保护其调度。

    • schedulingGates.name (string),必需

      调度门控的名称,每个调度门控的 name 字段取值必须唯一。

已弃用

  • serviceAccount (string)

    deprecatedServiceAccount 是 serviceAccountName 的弃用别名。此字段已被弃用:应改用 serviceAccountName。

容器

要在 Pod 中运行的单个应用容器。


  • name (string),必需

    指定为 DNS_LABEL 的容器的名称。Pod 中的每个容器都必须有一个唯一的名称 (DNS_LABEL)。无法更新。

镜像

Entrypoint

  • workingDir (string)

    容器的工作目录。如果未指定,将使用容器运行时的默认值,默认值可能在容器镜像中配置。无法更新。

端口

  • ports([]ContainerPort)

    补丁策略:基于 containerPort 键合并

    映射:键 containerPort, protocol 组合的唯一值将在合并期间保留

    要从容器暴露的端口列表。此处不指定端口不会阻止该端口被暴露。 任何侦听容器内默认 "0.0.0.0" 地址的端口都可以从网络访问。使用策略合并补丁来修改此数组可能会破坏数据。 更多细节请参阅 https://github.com/kubernetes/kubernetes/issues/108255。 无法更新。

    ContainerPort 表示单个容器中的网络端口。

    • ports.containerPort (int32),必需

      要在 Pod 的 IP 地址上公开的端口号。这必须是有效的端口号,0 < x < 65536。

    • ports.hostIP (string)

      绑定外部端口的主机 IP。

    • ports.hostPort (int32)

      要在主机上公开的端口号。如果指定,此字段必须是一个有效的端口号,0 < x < 65536。 如果设置了 hostNetwork,此字段值必须与 containerPort 匹配。大多数容器不需要设置此字段。

    • ports.name (string)

      如果设置此字段,这必须是 IANA_SVC_NAME 并且在 Pod 中唯一。 Pod 中的每个命名端口都必须具有唯一的名称。服务可以引用的端口的名称。

    • ports.protocol (string)

      端口协议。必须是 UDPTCPSCTP。默认为 TCP

环境变量

  • env([]EnvVar)

    补丁策略:基于 name 键合并

    要在容器中设置的环境变量列表。无法更新。

    EnvVar 表示容器中存在的环境变量。

    • env.name (string),必需

      环境变量的名称。必须是 C_IDENTIFIER。

    • env.value (string)

      变量引用 $(VAR_NAME) 使用容器中先前定义的环境变量和任何服务环境变量进行扩展。 如果无法解析变量,则输入字符串中的引用将保持不变。 $$ 会被简化为 $,这允许转义 $(VAR_NAME) 语法:即 "$$(VAR_NAME)" 将产生字符串字面值 "$(VAR_NAME)"。 无论变量是否存在,转义引用都不会被扩展。默认为 ""。

    • env.valueFrom (EnvVarSource)

      环境变量值的来源。如果 value 值不为空,则不能使用。

      EnvVarSource 表示 envVar 值的来源。

      • env.valueFrom.configMapKeyRef (ConfigMapKeySelector)

        选择某个 ConfigMap 的一个主键。

      • env.valueFrom.fieldRef (ObjectFieldSelector)

        选择 Pod 的一个字段:支持 metadata.namemetadata.namespacemetadata.labels['<KEY>']metadata.annotations['<KEY>']spec.nodeNamespec.serviceAccountNamestatus.hostIP status.podIPstatus.podIPs

      • env.valueFrom.resourceFieldRef (ResourceFieldSelector)

        选择容器的资源:目前仅支持资源限制和请求(limits.cpulimits.memorylimits.ephemeral-storagerequests.cpurequests.memoryrequests.ephemeral-storage)。

      • env.valueFrom.secretKeyRef (SecretKeySelector)

        在 Pod 的名字空间中选择 Secret 的主键。

        SecretKeySelector 选择一个 Secret 的主键。

  • envFrom ([]EnvFromSource)

    用来在容器中填充环境变量的数据源列表。在源中定义的键必须是 C_IDENTIFIER。 容器启动时,所有无效主键都将作为事件报告。 当一个键存在于多个源中时,与最后一个来源关联的值将优先。 由 env 定义的条目中,与此处键名重复者,以 env 中定义为准。无法更新。

    EnvFromSource 表示一组 ConfigMaps 的来源

    • envFrom.configMapRef (ConfigMapEnvSource)

      要从中选择主键的 ConfigMap。

      ConfigMapEnvSource 选择一个 ConfigMap 来填充环境变量。目标 ConfigMap 的 data 字段的内容将键值对表示为环境变量。

    • envFrom.prefix (string)

      附加到 ConfigMap 中每个键名之前的可选标识符。必须是 C_IDENTIFIER。

    • envFrom.secretRef (SecretEnvSource)

      要从中选择主键的 Secret。

      SecretEnvSource 选择一个 Secret 来填充环境变量。 目标 Secret 的 data 字段的内容将键值对表示为环境变量。

  • volumeMounts ([]VolumeMount)

    补丁策略:基于 mountPath 键合并

    要挂载到容器文件系统中的 Pod 卷。无法更新。

    VolumeMount 描述在容器中安装卷。

    • volumeMounts.mountPath (string),必需

      容器内卷的挂载路径。不得包含 ':'。

    • volumeMounts.name (string),必需

      此字段必须与卷的名称匹配。

    • volumeMounts.mountPropagation (string)

      mountPropagation 确定挂载如何从主机传播到容器,及如何反向传播。 如果未设置,则使用 MountPropagationNone。该字段在 1.10 中是 Beta 版。

    • volumeMounts.readOnly (boolean)

      如果为 true,则以只读方式挂载,否则(false 或未设置)以读写方式挂载。默认为 false。

    • volumeMounts.subPath (string)

      卷中的路径,容器中的卷应该这一路径安装。默认为 ""(卷的根)。

    • volumeMounts.subPathExpr (string)

      应安装容器卷的卷内的扩展路径。行为类似于 subPath,但环境变量引用 $(VAR_NAME) 使用容器的环境进行扩展。默认为 ""(卷的根)。subPathExprsubPath 是互斥的。

  • volumeDevices ([]VolumeDevice)

    补丁策略:基于 devicePath 键合并

    volumeDevices 是容器要使用的块设备列表。

    volumeDevice 描述了容器内原始块设备的映射。

    • volumeDevices.devicePath (string),必需

      devicePath 是设备将被映射到的容器内的路径。

    • volumeDevices.name (string),必需

      name 必须与 Pod 中的 persistentVolumeClaim 的名称匹配

资源

  • resources(ResourceRequirements)

    此容器所需的计算资源。无法更新。更多信息: https://kubernetes.io/zh-cn/docs/concepts/configuration/manage-resources-containers/

    ResourceRequirements 描述计算资源需求。

    • resources.claims ([]ResourceClaim)

      映射:键 name 的唯一值将在合并过程中保留

      claims 列出此容器使用的资源名称,资源名称在 spec.resourceClaims 中定义。

      这是一个 Alpha 特性字段,需要启用 DynamicResourceAllocation 功能门控开启此特性。

      此字段不可变更,只能在容器级别设置。

      ResourceClaim 引用 PodSpec.resourceClaims 中的一项。

      • resources.claims.name (string),必需

        name 必须与使用该字段 Pod 的 pod.spec.resourceClaims 中的一个条目的名称相匹配。它使该资源在容器内可用。

  • resizePolicy ([]ContainerResizePolicy)

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

    容器的资源调整策略。

    ContainerResizePolicy 表示容器的资源大小调整策略

    • resizePolicy.resourceName (string), 必需

      该资源调整策略适用的资源名称。支持的值:cpu、memory。

    • resizePolicy.restartPolicy (string), 必需

      重启策略,会在调整指定资源大小时使用该策略。如果未指定,则默认为 NotRequired。

生命周期

  • lifecycle (Lifecycle)

    管理系统应对容器生命周期事件采取的行动。无法更新。

    Lifecycle 描述管理系统为响应容器生命周期事件应采取的行动。 对于 postStart 和 preStop 生命周期处理程序,容器的管理会阻塞,直到操作完成, 除非容器进程失败,在这种情况下处理程序被中止。

    • lifecycle.preStop (LifecycleHandler)

      preStop 在容器因 API 请求或管理事件(如存活态探针/启动探针失败、抢占、资源争用等)而终止之前立即调用。 如果容器崩溃或退出,则不会调用处理程序。Pod 的终止宽限期倒计时在 preStop 钩子执行之前开始。 无论处理程序的结果如何,容器最终都会在 Pod 的终止宽限期内终止(除非被终结器延迟)。 容器的其他管理会阻塞,直到钩子完成或达到终止宽限期。更多信息: https://kubernetes.io/zh-cn/docs/concepts/containers/container-lifecycle-hooks/#container-hooks

  • terminationMessagePath (string)

    可选字段。挂载到容器文件系统的一个路径,容器终止消息写入到该路径下的文件中。 写入的消息旨在成为简短的最终状态,例如断言失败消息。如果大于 4096 字节,将被节点截断。 所有容器的总消息长度将限制为 12 KB。默认为 /dev/termination-log。无法更新。

  • terminationMessagePolicy (string)

    指示应如何填充终止消息。字段值 File 将使用 terminateMessagePath 的内容来填充成功和失败的容器状态消息。 如果终止消息文件为空并且容器因错误退出,FallbackToLogsOnError 将使用容器日志输出的最后一块。 日志输出限制为 2048 字节或 80 行,以较小者为准。默认为 File。无法更新。

  • startupProbe (Probe)

    startupProbe 表示 Pod 已成功初始化。如果设置了此字段,则此探针成功完成之前不会执行其他探针。 如果这个探针失败,Pod 会重新启动,就像存活态探针失败一样。 这可用于在 Pod 生命周期开始时提供不同的探针参数,此时加载数据或预热缓存可能需要比稳态操作期间更长的时间。 这无法更新。更多信息: https://kubernetes.io/zh-cn/docs/concepts/workloads/pods/pod-lifecycle#container-probes

  • restartPolicy (string)

    restartPolicy 定义 Pod 中各个容器的重新启动行为。 该字段仅适用于 Init 容器,唯一允许的值是 "Always"。 对于非 Init 容器或未指定此字段的情况,重新启动行为由 Pod 的重启策略和容器类型来定义。 将 restartPolicy 设置为 "Always" 会产生以下效果:该 Init 容器将在退出后持续重新启动,直到所有常规容器终止。 一旦所有常规容器已完成,所有具有 restartPolicy 为 "Always" 的 Init 容器将被关闭。 这种生命期与正常的 Init 容器不同,通常被称为 "sidecar" 容器。 虽然此 Init 容器仍然在 Init 容器序列中启动,但它在进入下一个 Init 容器之前并不等待容器完成。 相反,在此 Init 容器被启动后或在任意 startupProbe 已成功完成后下一个 Init 容器将立即启动。

安全上下文

  • securityContext (SecurityContext)

    SecurityContext 定义了容器应该运行的安全选项。如果设置,SecurityContext 的字段将覆盖 PodSecurityContext 的等效字段。更多信息: https://kubernetes.io/zh-cn/docs/tasks/configure-pod-container/security-context/

    SecurityContext 保存将应用于容器的安全配置。某些字段在 SecurityContext 和 PodSecurityContext 中都存在。 当两者都设置时,SecurityContext 中的值优先。

    • securityContext.runAsUser (int64)

      运行容器进程入口点的 UID。如果未指定,则默认为镜像元数据中指定的用户。 也可以在 PodSecurityContext 中设置。 如果同时在 SecurityContext 和 PodSecurityContext 中设置,则在 SecurityContext 中指定的值优先。 注意,spec.os.name 为 "windows" 时不能设置该字段。

    • securityContext.runAsNonRoot (boolean)

      指示容器必须以非 root 用户身份运行。 如果为 true,kubelet 将在运行时验证镜像,以确保它不会以 UID 0(root)身份运行,如果是,则无法启动容器。 如果未设置或为 false,则不会执行此类验证。也可以在 PodSecurityContext 中设置。 如果同时在 SecurityContext 和 PodSecurityContext 中设置,则在 SecurityContext 中指定的值优先。

    • securityContext.runAsGroup (int64)

      运行容器进程入口点的 GID。如果未设置,则使用运行时默认值。也可以在 PodSecurityContext 中设置。 如果同时在 SecurityContext 和 PodSecurityContext 中设置,则在 SecurityContext 中指定的值优先。 注意,spec.os.name 为 "windows" 时不能设置该字段。

    • securityContext.readOnlyRootFilesystem (boolean)

      此容器是否具有只读根文件系统。默认为 false。注意,spec.os.name 为 "windows" 时不能设置该字段。

    • securityContext.procMount (string)

      procMount 表示用于容器的 proc 挂载类型。默认值为 DefaultProcMount, 它针对只读路径和掩码路径使用容器运行时的默认值。此字段需要启用 ProcMountType 特性门控。 注意,spec.os.name 为 "windows" 时不能设置此字段。

    • securityContext.privileged (boolean)

      以特权模式运行容器。特权容器中的进程本质上等同于主机上的 root。默认为 false。 注意,spec.os.name 为 "windows" 时不能设置此字段。

    • securityContext.allowPrivilegeEscalation (boolean)

      allowPrivilegeEscalation 控制进程是否可以获得比其父进程更多的权限。此布尔值直接控制是否在容器进程上设置 no_new_privs 标志。allowPrivilegeEscalation 在容器处于以下状态时始终为 true:

      1. 以特权身份运行
      2. 具有 CAP_SYS_ADMIN

      请注意,当 spec.os.name 为 "windows" 时,无法设置此字段。

    • securityContext.capabilities (Capabilities)

      运行容器时添加或放弃的权能(Capabilities)。默认为容器运行时所授予的权能集合。 注意,spec.os.name 为 "windows" 时不能设置此字段。

      在运行中的容器中添加和放弃 POSIX 权能。

      • securityContext.capabilities.add ([]string)

        新增权能。

      • securityContext.capabilities.drop ([]string)

        放弃权能。

    • securityContext.seccompProfile (SeccompProfile)

      此容器使用的 seccomp 选项。如果在 Pod 和容器级别都提供了 seccomp 选项,则容器级别的选项会覆盖 Pod 级别的选项设置。 注意,spec.os.name 为 "windows" 时不能设置此字段。

      SeccompProfile 定义 Pod 或容器的 seccomp 配置文件设置。只能设置一个配置文件源。

      • securityContext.seccompProfile.type (string),必需

        type 指示应用哪种 seccomp 配置文件。有效的选项有:

        • Localhost - 应使用在节点上的文件中定义的配置文件。
        • RuntimeDefault - 应使用容器运行时的默认配置文件。
        • Unconfined - 不应用任何配置文件。
      • securityContext.seccompProfile.localhostProfile (string)

        localhostProfile 指示应使用的在节点上的文件,文件中定义了配置文件。 该配置文件必须在节点上先行配置才能使用。 必须是相对于 kubelet 所配置的 seccomp 配置文件位置下的下级路径。 仅当 type 为 "Localhost" 时才必须设置。不得为任何其他类别设置此字段。

    • securityContext.seLinuxOptions (SELinuxOptions)

      要应用到容器上的 SELinux 上下文。如果未设置此字段,容器运行时将为每个容器分配一个随机的 SELinux 上下文。 也可以在 PodSecurityContext 中设置。如果同时在 SecurityContext 和 PodSecurityContext 中设置, 则在 SecurityContext 中指定的值优先。注意,spec.os.name 为 "windows" 时不能设置此字段。

      SELinuxOptions 是要应用到容器上的标签。

      • securityContext.seLinuxOptions.level (string)

        level 是应用于容器的 SELinux 级别标签。

      • securityContext.seLinuxOptions.role (string)

        role 是应用于容器的 SELinux 角色标签。

      • securityContext.seLinuxOptions.type (string)

        type 是适用于容器的 SELinux 类型标签。

      • securityContext.seLinuxOptions.user (string)

        user 是应用于容器的 SELinux 用户标签。

    • securityContext.windowsOptions (WindowsSecurityContextOptions)

      要应用于所有容器上的特定于 Windows 的设置。如果未指定,将使用 PodSecurityContext 中的选项。 如果同时在 SecurityContext 和 PodSecurityContext 中设置,则在 SecurityContext 中指定的值优先。 注意,spec.os.name 为 "linux" 时不能设置此字段。

      WindowsSecurityContextOptions 包含特定于 Windows 的选项和凭据。

      • securityContext.windowsOptions.gmsaCredentialSpec (string)

        gmsaCredentialSpec 是 GMSA 准入 Webhook 内嵌由 gmsaCredentialSpecName 字段所指定的 GMSA 凭证规约的内容的地方。

      • securityContext.windowsOptions.hostProcess (boolean)

        hostProcess 确定容器是否应作为 "主机进程" 容器运行。 一个 Pod 的所有容器必须具有相同的有效 hostProcess 值(不允许混合设置了 hostProcess 容器和未设置 hostProcess 的容器)。 此外,如果 hostProcess 为 true,则 hostNetwork 也必须设置为 true。

      • securityContext.windowsOptions.runAsUserName (string)

        Windows 中运行容器进程入口点的用户名。如果未指定,则默认为镜像元数据中指定的用户。 也可以在 PodSecurityContext 中设置。 如果同时在 SecurityContext 和 PodSecurityContext 中设置,则在 SecurityContext 中指定的值优先。

调试

  • stdin (boolean)

    此容器是否应在容器运行时为 stdin 分配缓冲区。如果未设置,从容器中的 stdin 读取将始终导致 EOF。 默认为 false。

  • stdinOnce (boolean)

    容器运行时是否应在某个 attach 打开 stdin 通道后关闭它。当 stdin 为 true 时,stdin 流将在多个 attach 会话中保持打开状态。 如果 stdinOnce 设置为 true,则 stdin 在容器启动时打开,在第一个客户端连接到 stdin 之前为空, 然后保持打开并接受数据,直到客户端断开连接,此时 stdin 关闭并保持关闭直到容器重新启动。 如果此标志为 false,则从 stdin 读取的容器进程将永远不会收到 EOF。默认为 false。

  • tty (boolean) 这个容器是否应该为自己分配一个 TTY,同时需要设置 stdin 为真。默认为 false。

EphemeralContainer

EphemeralContainer 是一个临时容器,你可以将其添加到现有 Pod 以用于用户发起的活动,例如调试。 临时容器没有资源或调度保证,它们在退出或 Pod 被移除或重新启动时不会重新启动。 如果临时容器导致 Pod 超出其资源分配,kubelet 可能会驱逐 Pod。

要添加临时容器,请使用现有 Pod 的 ephemeralcontainers 子资源。临时容器不能被删除或重新启动。


  • name (string),必需

    以 DNS_LABEL 形式设置的临时容器的名称。此名称在所有容器、Init 容器和临时容器中必须是唯一的。

  • targetContainerName (string)

    如果设置,则为 Pod 规约中此临时容器所针对的容器的名称。临时容器将在该容器的名字空间(IPC、PID 等)中运行。 如果未设置,则临时容器使用 Pod 规约中配置的名字空间。

    容器运行时必须实现对此功能的支持。如果运行时不支持名字空间定位,则设置此字段的结果是未定义的。

镜像

入口点

  • workingDir (string)

    容器的工作目录。如果未指定,将使用容器运行时的默认值,默认值可能在容器镜像中配置。无法更新。

环境变量

  • env([]EnvVar)

    补丁策略:基于 name 键合并

    要在容器中设置的环境变量列表。无法更新。

    EnvVar 表示容器中存在的环境变量。

    • env.name (string),必需

      环境变量的名称。必须是 C_IDENTIFIER。

    • env.value (string)

      变量引用 $(VAR_NAME) 使用容器中先前定义的环境变量和任何服务环境变量进行扩展。 如果无法解析变量,则输入字符串中的引用将保持不变。 $$ 被简化为 $,这允许转义 $(VAR_NAME) 语法:即 "$$(VAR_NAME)" 将产生字符串字面值 "$(VAR_NAME)"。 无论变量是否存在,转义引用都不会被扩展。默认为 ""。

    • env.valueFrom (EnvVarSource)

      环境变量值的来源。如果取值不为空,则不能使用。

      EnvVarSource 表示 envVar 值的源。

      • env.valueFrom.configMapKeyRef (ConfigMapKeySelector)

        选择 ConfigMap 的主键。

        选择 ConfigMap 的主键。

        • env.valueFrom.configMapKeyRef.optional (boolean)

          指定是否 ConfigMap 或其键必须已经被定义。

      • env.valueFrom.fieldRefObjectFieldSelector

        选择 Pod 的一个字段:支持 metadata.namemetadata.namespacemetadata.labels['<KEY>']metadata.annotations['<KEY>']spec.nodeNamespec.serviceAccountNamestatus.hostIPstatus.podIPstatus.podIPs

      • env.valueFrom.resourceFieldRefResourceFieldSelector

        选择容器的资源:当前仅支持资源限制和请求(limits.cpulimits.memorylimits.ephemeral-storagerequests.cpurequests.memoryrequests.ephemeral-storage)。

      • env.valueFrom.secretKeyRef (SecretKeySelector)

        在 Pod 的名字空间中选择某 Secret 的主键。

        SecretKeySelector 选择某 Secret 的主键。

  • envFrom ([]EnvFromSource)

    在容器中填充环境变量的来源列表。在来源中定义的键名必须是 C_IDENTIFIER。 容器启动时,所有无效键都将作为事件报告。当一个键存在于多个来源中时,与最后一个来源关联的值将优先。 如果有重复主键,env 中定义的值将优先。无法更新。

    EnvFromSource 表示一组 ConfigMap 来源

    • envFrom.configMapRef (ConfigMapEnvSource)

      要从中选择的 ConfigMap。

      ConfigMapEnvSource 选择一个 ConfigMap 来填充环境变量。目标 ConfigMap 的 data 字段的内容将键值对表示为环境变量。

    • envFrom.prefix (string)

      要在 ConfigMap 中的每个键前面附加的可选标识符。必须是C_IDENTIFIER。

    • envFrom.secretRef (SecretEnvSource)

      可供选择的 Secret。

      SecretEnvSource 选择一个 Secret 来填充环境变量。目标 Secret 的 data 字段的内容将键值对表示为环境变量。

  • volumeMounts ([]VolumeMount)

    补丁策略:基于 mountPath 键合并

    要挂载到容器文件系统中的 Pod 卷。临时容器不允许子路径挂载。无法更新。

    VolumeMount 描述在容器中卷的挂载。

    • volumeMounts.mountPath (string),必需

      容器内应安装卷的路径。不得包含 ':'。

    • volumeMounts.name (string),必需

      此字段必须与卷的名称匹配。

    • volumeMounts.mountPropagation (string)

      mountPropagation 确定装载如何从主机传播到容器,及反向传播选项。 如果未设置,则使用 None。此字段在 1.10 中为 Beta 字段。

    • volumeMounts.readOnly (boolean)

      如果为 true,则挂载卷为只读,否则为读写(false 或未指定)。默认值为 false。

    • volumeMounts.subPath (string)

      卷中的路径名,应该从该路径挂在容器的卷。默认为 "" (卷的根)。

    • volumeMounts.subPathExpr (string)

      应安装容器卷的卷内的扩展路径。行为类似于 subPath,但环境变量引用 $(VAR_NAME) 使用容器的环境进行扩展。默认为 ""(卷的根)。subPathExprSubPath 是互斥的。

  • volumeDevices ([]VolumeDevice)

    补丁策略:基于 devicePath 键合并

    volumeDevices 是容器要使用的块设备列表。

    volumeDevice 描述容器内原始块设备的映射。

    • volumeDevices.devicePath (string),必需

      devicePath 是设备将被映射到的容器内的路径。

    • volumeDevices.name (string),必需

      name 必须与 Pod 中的 persistentVolumeClaim 的名称匹配。

  • resizePolicy ([]ContainerResizePolicy)

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

    容器的资源调整策略。

    ContainerResizePolicy 表示容器的资源大小调整策略

    • resizePolicy.resourceName (string), 必需

      该资源调整策略适用的资源名称。支持的值:cpu、memory。

    • resizePolicy.restartPolicy (string), 必需

      重启策略,会在调整指定资源大小时使用该策略。如果未指定,则默认为 NotRequired。

生命周期

  • terminationMessagePath (string)

    可选字段。挂载到容器文件系统的路径,用于写入容器终止消息的文件。 写入的消息旨在成为简短的最终状态,例如断言失败消息。如果超出 4096 字节,将被节点截断。 所有容器的总消息长度将限制为 12 KB。默认为 /dev/termination-log。无法更新。

  • terminationMessagePolicy (string)

    指示应如何填充终止消息。字段值为 File 表示将使用 terminateMessagePath 的内容来填充成功和失败的容器状态消息。 如果终止消息文件为空并且容器因错误退出,字段值 FallbackToLogsOnError 表示将使用容器日志输出的最后一块。日志输出限制为 2048 字节或 80 行,以较小者为准。 默认为 File。无法更新。

  • restartPolicy (string)

    这是针对容器的重启策略,用于管理 Pod 内每个容器的重启行为。 此字段仅适用于 Init 容器,在临时容器上无法设置此字段。

调试

  • stdin (boolean)

    是否应在容器运行时内为此容器 stdin 分配缓冲区。 如果未设置,从容器中的 stdin 读数据将始终导致 EOF。默认为 false。

  • stdinOnce (boolean)

    容器运行时是否应在某个 attach 操作打开 stdin 通道后关闭它。 当 stdin 为 true 时,stdin 流将在多个 attach 会话中保持打开状态。 如果 stdinOnce 设置为 true,则 stdin 在容器启动时打开,在第一个客户端连接到 stdin 之前为空, 然后保持打开并接受数据,直到客户端断开连接,此时 stdin 关闭并保持关闭直到容器重新启动。 如果此标志为 false,则从 stdin 读取的容器进程将永远不会收到 EOF。默认为 false。

  • tty (boolean)

    这个容器是否应该为自己分配一个 TTY,也需要 stdin 为 true。默认为 false。

安全上下文

  • securityContext (SecurityContext)

    可选字段。securityContext 定义了运行临时容器的安全选项。 如果设置了此字段,SecurityContext 的字段将覆盖 PodSecurityContext 的等效字段。

    SecurityContext 保存将应用于容器的安全配置。 一些字段在 SecurityContext 和 PodSecurityContext 中都存在。 当两者都设置时,SecurityContext 中的值优先。

    • securityContext.runAsUser (int64)

      运行容器进程入口点的 UID。如果未指定,则默认为镜像元数据中指定的用户。 也可以在 PodSecurityContext 中设置。如果同时在 SecurityContext 和 PodSecurityContext 中设置,则在 SecurityContext 中指定的值优先。 注意,spec.os.name 为 "windows" 时不能设置该字段。

    • securityContext.runAsNonRoot (boolean)

      指示容器必须以非 root 用户身份运行。如果为 true,Kubelet 将在运行时验证镜像, 以确保它不会以 UID 0(root)身份运行,如果是,则无法启动容器。 如果未设置或为 false,则不会执行此类验证。也可以在 PodSecurityContext 中设置。 如果同时在 SecurityContext 和 PodSecurityContext 中设置,则在 SecurityContext 中指定的值优先。

    • securityContext.runAsGroup (int64)

      运行容器进程入口点的 GID。如果未设置,则使用运行时默认值。也可以在 PodSecurityContext 中设置。 如果同时在 SecurityContext 和 PodSecurityContext 中设置,则在 SecurityContext 中指定的值优先。注意,spec.os.name 为 "windows" 时不能设置该字段。

    • securityContext.readOnlyRootFilesystem (boolean)

      此容器是否具有只读根文件系统。 默认为 false。注意,spec.os.name 为 "windows" 时不能设置该字段。

    • securityContext.procMount (string)

      procMount 表示用于容器的 proc 挂载类型。默认值为 DefaultProcMount, 它将容器运行时默认值用于只读路径和掩码路径。这需要启用 ProcMountType 特性门控。 注意,spec.os.name 为 "windows" 时不能设置该字段。

    • securityContext.privileged (boolean)

      以特权模式运行容器。特权容器中的进程本质上等同于主机上的 root。默认为 false。 注意,spec.os.name 为 "windows" 时不能设置该字段。

    • securityContext.allowPrivilegeEscalation (boolean)

      allowPrivilegeEscalation 控制进程是否可以获得比其父进程更多的权限。 此布尔值直接控制是否在容器进程上设置 no_new_privs 标志。allowPrivilegeEscalation 在容器处于以下状态时始终为 true:

      1. 以特权身份运行
      2. 具有 CAP_SYS_ADMIN 权能

      请注意,当 spec.os.name 为 "windows" 时,无法设置此字段。

    • securityContext.capabilities (Capabilities)

      运行容器时添加/放弃的权能。默认为容器运行时授予的默认权能集。 注意,spec.os.name 为 "windows" 时不能设置此字段。

      在运行中的容器中添加和放弃 POSIX 权能。

      • securityContext.capabilities.add ([]string)

        新增的权能。

      • securityContext.capabilities.drop ([]string)

        放弃的权能。

    • securityContext.seccompProfile (SeccompProfile)

      此容器使用的 seccomp 选项。如果在 Pod 和容器级别都提供了 seccomp 选项, 则容器选项会覆盖 Pod 选项。注意,spec.os.name 为 "windows" 时不能设置该字段。

      SeccompProfile 定义 Pod 或容器的 seccomp 配置文件设置。只能设置一个配置文件源。

      • securityContext.seccompProfile.type (string),必需

        type 指示将应用哪种 seccomp 配置文件。有效的选项是:

        • Localhost - 应使用在节点上的文件中定义的配置文件。
        • RuntimeDefault - 应使用容器运行时默认配置文件。
        • Unconfined - 不应应用任何配置文件。
      • securityContext.seccompProfile.localhostProfile (string)

        localhostProfile 指示应使用在节点上的文件中定义的配置文件。 该配置文件必须在节点上预先配置才能工作。 必须是相对于 kubelet 配置的 seccomp 配置文件位置下的子路径。 仅当 type 为 "Localhost" 时才必须设置。不得为任何其他类别设置此字段。

    • securityContext.seLinuxOptions (SELinuxOptions)

      要应用于容器的 SELinux 上下文。如果未指定,容器运行时将为每个容器分配一个随机 SELinux 上下文。也可以在 PodSecurityContext 中设置。 如果同时在 SecurityContext 和 PodSecurityContext 中设置,则在 SecurityContext 中指定的值优先。注意,spec.os.name 为 "windows" 时不能设置此字段。

      SELinuxOptions 是要应用于容器的标签

      • securityContext.seLinuxOptions.level (string)

        level 是应用于容器的 SELinux 级别标签。

      • securityContext.seLinuxOptions.role (string)

        role 是应用于容器的 SELinux 角色标签。

      • securityContext.seLinuxOptions.type (string)

        type 是适用于容器的 SELinux 类型标签。

      • securityContext.seLinuxOptions.user (string)

        user 是应用于容器的 SELinux 用户标签。

    • securityContext.windowsOptions (WindowsSecurityContextOptions)

      要应用到所有容器上的特定于 Windows 的设置。如果未指定,将使用 PodSecurityContext 中的选项。 如果同时在 SecurityContext 和 PodSecurityContext 中设置,则在 SecurityContext 中指定的值优先。注意,spec.os.name 为 "linux" 时不能设置此字段。

      WindowsSecurityContextOptions 包含特定于 Windows 的选项和凭据。

      • securityContext.windowsOptions.gmsaCredentialSpec (string)

        gmsaCredentialSpec 是 GMSA 准入 Webhook 内嵌由 gmsaCredentialSpecName 字段所指定的 GMSA 凭证规约内容的地方。

      • securityContext.windowsOptions.gmsaCredentialSpecName (string)

        gmsaCredentialSpecName 是要使用的 GMSA 凭证规约的名称。

      • securityContext.windowsOptions.hostProcess (boolean)

        hostProcess 确定容器是否应作为 "主机进程" 容器运行。 一个 Pod 的所有容器必须具有相同的有效 hostProcess 值 (不允许混合设置了 hostProcess 的容器和未设置 hostProcess 的容器)。 此外,如果 hostProcess 为 true,则 hostNetwork 也必须设置为 true。

      • securityContext.windowsOptions.runAsUserName (string)

        Windows 中运行容器进程入口点的用户名。如果未指定,则默认为镜像元数据中指定的用户。 也可以在 PodSecurityContext 中设置。如果同时在 SecurityContext 和 PodSecurityContext 中设置,则在 SecurityContext 中指定的值优先。

不允许

  • ports([]ContainerPort)

    补丁策略:基于 containerPort 键合并

    映射:键 containerPort, protocol 组合的唯一值将在合并期间保留

    临时容器不允许使用端口。

    ContainerPort 表示单个容器中的网络端口。

    • ports.containerPort (int32),必需

      要在容器的 IP 地址上公开的端口号。这必须是有效的端口号 0 < x < 65536。

    • ports.hostIP (string)

      要将外部端口绑定到的主机 IP。

    • ports.hostPort (int32)

      要在主机上公开的端口号。如果设置了,则作为必须是一个有效的端口号,0 < x < 65536。 如果指定了 hostNetwork,此值必须与 containerPort 匹配。大多数容器不需要这个配置。

    • ports.name(string)

      如果指定了,则作为端口的名称。必须是 IANA_SVC_NAME 并且在 Pod 中是唯一的。 Pod 中的每个命名端口都必须具有唯一的名称。服务可以引用的端口的名称。

    • ports.protocol (string)

      端口协议。必须是 UDPTCPSCTP 之一。默认为 TCP

  • resources (ResourceRequirements)

    临时容器不允许使用资源。临时容器使用已分配给 Pod 的空闲资源。

    ResourceRequirements 描述计算资源的需求。

    • resources.claims ([]ResourceClaim)

      映射:键 name 的唯一值将在合并过程中保留

      claims 列出了此容器使用的资源名称,资源名称在 spec.resourceClaims 中定义。

      这是一个 Alpha 特性字段,需要启用 DynamicResourceAllocation 功能门控开启此特性。

      此字段不可变更,只能在容器级别设置。

      ResourceClaim 引用 PodSpec.ResourceClaims 中的一项。

      • resources.claims.name (string),必需

        name 必须与使用该字段 Pod 的 pod.spec.resourceClaims 中的一个条目的名称相匹配。它使该资源在容器内可用。

  • lifecycle (Lifecycle)

    临时容器不允许使用生命周期。

    生命周期描述了管理系统为响应容器生命周期事件应采取的行动。 对于 postStart 和 preStop 生命周期处理程序,容器的管理会阻塞,直到操作完成, 除非容器进程失败,在这种情况下处理程序被中止。

    • lifecycle.preStopLifecycleHandler

      preStop 在容器因 API 请求或管理事件(例如:存活态探针/启动探针失败、抢占、资源争用等) 而终止之前立即调用。如果容器崩溃或退出,则不会调用处理程序。 Pod 的终止宽限期倒计时在 preStop 钩子执行之前开始。 无论处理程序的结果如何,容器最终都会在 Pod 的终止宽限期内终止(除非被终结器延迟)。 容器的其他管理会阻塞,直到钩子完成或达到终止宽限期。更多信息: https://kubernetes.io/zh-cn/docs/concepts/containers/container-lifecycle-hooks/#container-hooks

  • livenessProbeProbe

    临时容器不允许使用探针。

  • readyProbeProbe

    临时容器不允许使用探针。

  • startupProbeProbe

    临时容器不允许使用探针。

LifecycleHandler

LifecycleHandler 定义了应在生命周期挂钩中执行的特定操作。 必须指定一个且只能指定一个字段,tcpSocket 除外。


  • exec (execAction)

    Exec 指定要执行的操作。

    ExecAction 描述了 "在容器中运行" 操作。

    • exec.command ([]string)

      command 是要在容器内执行的命令行,命令的工作目录是容器文件系统中的根目录('/')。 该命令只是被通过 exec 执行,而不会单独启动一个 Shell 来运行,因此传统的 Shell 指令('|' 等)将不起作用。要使用某 Shell,你需要显式调用该 Shell。 退出状态 0 被视为活动/健康,非零表示不健康。

  • httpGet (HTTPGetAction)

    HTTPGet 指定要执行的 HTTP 请求。

    HTTPGetAction 描述基于 HTTP Get 请求的操作。

    • httpGet.port (IntOrString),必需

      要在容器上访问的端口的名称或编号。数字必须在 1 到 65535 的范围内。名称必须是 IANA_SVC_NAME。

      IntOrString 是一种可以包含 int32 或字符串值的类型。在 JSON 或 YAML 封组和取消编组时, 它会生成或使用内部类型。例如,这允许你拥有一个可以接受名称或数字的 JSON 字段。

    • httpGet.host (string)

      要连接的主机名,默认为 Pod IP。你可能想在 httpHeaders 中设置 "Host"。

    • httpGet.httpHeaders ([]HTTPHeader)

      要在请求中设置的自定义标头。HTTP 允许重复的标头。

      HTTPHeader 描述了在 HTTP 探针中使用的自定义标头

      • httpGet.httpHeaders.name (string),必需

        HTTP 头部字段名称。 在输出时,它将被规范化处理,因此大小写变体的名称会被视为相同的头。

      • httpGet.httpHeaders.value (string),必需

        HTTP 头部字段取值。

    • httpGet.path (string)

      HTTP 服务器上的访问路径。

    • httpGet.scheme (string)

      用于连接到主机的方案。默认为 HTTP

  • tcpSocket (TCPSocketAction)

    已弃用。不再支持 tcpSocket 作为 LifecycleHandler,但为向后兼容保留之。 当指定 tcp 处理程序时,此字段不会被验证,而生命周期回调将在运行时失败。

    TCPSocketAction 描述基于打开套接字的动作。

    • tcpSocket.port (IntOrString),必需

      容器上要访问的端口的编号或名称。端口号必须在 1 到 65535 的范围内。 名称必须是 IANA_SVC_NAME。

      IntOrString 是一种可以保存 int32 或字符串值的类型。在 JSON 或 YAML 编组和解组中使用时, 会生成或使用内部类型。例如,这允许你拥有一个可以接受名称或数字的 JSON 字段。

    • tcpSocket.host (string)

      可选字段。要连接的主机名,默认为 Pod IP。

NodeAffinity

节点亲和性是一组节点亲和性调度规则。


  • preferredDuringSchedulingIgnoredDuringExecution ([]PreferredSchedulingTerm)

    调度程序会更倾向于将 Pod 调度到满足该字段指定的亲和性表达式的节点, 但它可能会选择违反一个或多个表达式的节点。最优选的节点是权重总和最大的节点, 即对于满足所有调度要求(资源请求、requiredDuringScheduling 亲和表达式等)的每个节点, 通过迭代该字段的元素来计算总和如果节点匹配相应的 matchExpressions,则将 "权重" 添加到总和中; 具有最高总和的节点是最优选的。

    空的首选调度条件匹配所有具有隐式权重 0 的对象(即它是一个 no-op 操作)。 null 值的首选调度条件不匹配任何对象(即也是一个 no-op 操作)。

    • preferredDuringSchedulingIgnoredDuringExecution.preference (NodeSelectorTerm),必需

      与相应权重相关联的节点选择条件。

      null 值或空值的节点选择条件不会匹配任何对象。这些条件的请求按逻辑与操作组合。 TopologySelectorTerm 类型实现了 NodeSelectorTerm 的一个子集。

      • preferredDuringSchedulingIgnoredDuringExecution.preference.matchExpressions ([]NodeSelectorRequirement

        按节点标签列出的节点选择条件列表。

      • preferredDuringSchedulingIgnoredDuringExecution.preference.matchFields ([]NodeSelectorRequirement

        按节点字段列出的节点选择要求列表。

    • preferredDuringSchedulingIgnoredDuringExecution.weight (int32),必需

      与匹配相应的 nodeSelectorTerm 相关的权重,范围为 1-100。

  • requiredDuringSchedulingIgnoredDuringExecution (NodeSelector)

    如果在调度时不满足该字段指定的亲和性要求,则不会将 Pod 调度到该节点上。 如果在 Pod 执行期间的某个时间点不再满足此字段指定的亲和性要求(例如:由于更新), 系统可能会或可能不会尝试最终将 Pod 从其节点中逐出。

    一个节点选择器代表一个或多个标签查询结果在一组节点上的联合;换言之, 它表示由节点选择器项表示的选择器的逻辑或组合。

    • requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms ([]NodeSelectorTerm),必需

      必需的字段。节点选择条件列表。这些条件按逻辑或操作组合。

      null 值或空值的节点选择器条件不匹配任何对象。这里的条件是按逻辑与操作组合的。 TopologySelectorTerm 类型实现了 NodeSelectorTerm 的一个子集。

      • requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms.matchExpressions ([]NodeSelectorRequirement

        按节点标签列出的节点选择器需求列表。

      • requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms.matchFields ([]NodeSelectorRequirement

        按节点字段列出的节点选择器要求列表。

PodAffinity

Pod 亲和性是一组 Pod 间亲和性调度规则。


  • preferredDuringSchedulingIgnoredDuringExecution ([]WeightedPodAffinityTerm)

    调度器会更倾向于将 Pod 调度到满足该字段指定的亲和性表达式的节点, 但它可能会选择违反一个或多个表达式的节点。最优选择是权重总和最大的节点, 即对于满足所有调度要求(资源请求、requiredDuringScheduling 亲和表达式等)的每个节点, 通过迭代该字段的元素来计算总和,如果节点具有与相应 podAffinityTerm 匹配的 Pod,则将“权重”添加到总和中; 具有最高总和的节点是最优选的。

    所有匹配的 WeightedPodAffinityTerm 字段的权重都是按节点累计的,以找到最优选的节点。

    • preferredDuringSchedulingIgnoredDuringExecution.podAffinityTerm (PodAffinityTerm),必需

      必需的字段。一个 Pod 亲和性条件,对应一个与相应的权重值。

      定义一组 Pod(即那些与给定名字空间相关的标签选择算符匹配的 Pod 集合), 当前 Pod 应该与所选 Pod 集合位于同一位置(亲和性)或位于不同位置(反亲和性), 其中“在同一位置”意味着运行在一个节点上,其键 topologyKey 的标签值与运行所选 Pod 集合中的某 Pod 的任何节点上的标签值匹配。

      • preferredDuringSchedulingIgnoredDuringExecution.podAffinityTerm.topologyKey (string),必需

        此 Pod 应与指定名字空间中与标签选择算符匹配的 Pod 集合位于同一位置(亲和性) 或位于不同位置(反亲和性),这里的“在同一位置”意味着运行在一个节点上,其键名为 topologyKey 的标签值与运行所选 Pod 集合中的某 Pod 的任何节点上的标签值匹配。 不允许使用空的 topologyKey

      • preferredDuringSchedulingIgnoredDuringExecution.podAffinityTerm.labelSelectorLabelSelector

        对一组资源的标签查询,在这里资源为 Pod。

      • preferredDuringSchedulingIgnoredDuringExecution.podAffinityTerm.namespaceSelectorLabelSelector

        对条件所适用的名字空间集合的标签查询。 此条件会被应用到此字段所选择的名字空间和 namespaces 字段中列出的名字空间的组合之上。 选择算符为 null 和 namespaces 列表为 null 值或空表示“此 Pod 的名字空间”。 空的选择算符 ({}) 可用来匹配所有名字空间。

      • preferredDuringSchedulingIgnoredDuringExecution.podAffinityTerm.namespaces ([]string)

        namespaces 指定此条件所适用的名字空间,是一个静态列表。 此条件会被应用到 namespaces 字段中列出的名字空间和由 namespaceSelector 选中的名字空间上。 namespaces 列表为 null 或空,以及 namespaceSelector 值为 null 均表示“此 Pod 的名字空间”。

    • preferredDuringSchedulingIgnoredDuringExecution.weight (int32),必需

      weight 是匹配相应 podAffinityTerm 条件的权重,范围为 1-100。

  • requiredDuringSchedulingIgnoredDuringExecution ([]PodAffinityTerm)

    如果在调度时不满足该字段指定的亲和性要求,则该 Pod 不会被调度到该节点上。 如果在 Pod 执行期间的某个时间点不再满足此字段指定的亲和性要求(例如:由于 Pod 标签更新), 系统可能会也可能不会尝试最终将 Pod 从其节点中逐出。 当此列表中有多个元素时,每个 podAffinityTerm 对应的节点列表是取其交集的,即必须满足所有条件。

    定义一组 Pod(即那些与给定名字空间相关的标签选择算符匹配的 Pod 集合),当前 Pod 应该与该 Pod 集合位于同一位置(亲和性)或不位于同一位置(反亲和性)。 这里的“位于同一位置”含义是运行在一个节点上。基于 topologyKey 字段所给的标签键名, 检查所选 Pod 集合中各个 Pod 所在的节点上的标签值,标签值相同则认作“位于同一位置”。

    • requiredDuringSchedulingIgnoredDuringExecution.topologyKey (string),必需

      此 Pod 应与指定名字空间中与标签选择算符匹配的 Pod 集合位于同一位置(亲和性) 或不位于同一位置(反亲和性), 这里的“位于同一位置”含义是运行在一个节点上。基于 topologyKey 字段所给的标签键名, 检查所选 Pod 集合中各个 Pod 所在的节点上的标签值,标签值相同则认作“位于同一位置”。 不允许使用空的 topologyKey

    • requiredDuringSchedulingIgnoredDuringExecution.labelSelectorLabelSelector

      对一组资源的标签查询,在这里资源为 Pod。

    • requiredDuringSchedulingIgnoredDuringExecution.namespaceSelectorLabelSelector

      对条件所适用的名字空间集合的标签查询。 当前条件将应用于此字段选择的名字空间和 namespaces 字段中列出的名字空间。 选择算符为 null 和 namespaces 列表为 null 或空值表示“此 Pod 的名字空间”。 空选择算符 ({}) 能够匹配所有名字空间。

    • requiredDuringSchedulingIgnoredDuringExecution.namespaces ([]string)

      namespaces 指定当前条件所适用的名字空间名称的静态列表。 当前条件适用于此字段中列出的名字空间和由 namespaceSelector 选中的名字空间。 namespaces 列表为 null 或空,以及 namespaceSelector 为 null 表示“此 Pod 的名字空间”。

PodAntiAffinity

Pod 反亲和性是一组 Pod 间反亲和性调度规则。


  • preferredDuringSchedulingIgnoredDuringExecution ([]WeightedPodAffinityTerm)

    调度器更倾向于将 Pod 调度到满足该字段指定的反亲和性表达式的节点, 但它可能会选择违反一个或多个表达式的节点。 最优选的节点是权重总和最大的节点,即对于满足所有调度要求(资源请求、requiredDuringScheduling 反亲和性表达式等)的每个节点,通过遍历元素来计算总和如果节点具有与相应 podAffinityTerm 匹配的 Pod,则此字段并在总和中添加"权重";具有最高加和的节点是最优选的。

    所有匹配的 WeightedPodAffinityTerm 字段的权重都是按节点添加的,以找到最优选的节点。

    • preferredDuringSchedulingIgnoredDuringExecution.podAffinityTerm (PodAffinityTerm),必需

      必需的字段。一个 Pod 亲和性条件,与相应的权重相关联。

      定义一组 Pod(即那些与给定名字空间相关的标签选择算符匹配的 Pod 集合), 当前 Pod 应该与所选 Pod 集合位于同一位置(亲和性)或不位于同一位置(反亲和性), 其中 "在同一位置" 意味着运行在一个节点上,其键 topologyKey 的标签值与运行所选 Pod 集合中的某 Pod 的任何节点上的标签值匹配。

      • preferredDuringSchedulingIgnoredDuringExecution.podAffinityTerm.topologyKey (string),必需

        此 Pod 应与指定名字空间中与标签选择算符匹配的 Pod 集合位于同一位置(亲和性) 或不位于同一位置(反亲和性),这里的 "在同一位置" 意味着运行在一个节点上,其键名为 topologyKey 的标签值与运行所选 Pod 集合中的某 Pod 的任何节点上的标签值匹配。 不允许使用空的 topologyKey

      • preferredDuringSchedulingIgnoredDuringExecution.podAffinityTerm.labelSelectorLabelSelector

        对一组资源的标签查询,在这里资源为 Pod。

      • preferredDuringSchedulingIgnoredDuringExecution.podAffinityTerm.namespaceSelectorLabelSelector

        对条件所适用的名字空间集合的标签查询。 此条件会被应用到此字段所选择的名字空间和 namespaces 字段中列出的名字空间的组合之上。 选择算符为 null 和 namespaces 列表为 null 值或空表示 "此 Pod 的名字空间"。 空的选择算符 ({}) 可用来匹配所有名字空间。

      • preferredDuringSchedulingIgnoredDuringExecution.podAffinityTerm.namespaces ([]string)

        namespaces 指定此条件所适用的名字空间,是一个静态列表。 此条件会被应用到 namespaces 字段中列出的名字空间和由 namespaceSelector 选中的名字空间上。 namespaces 列表为 null 或空,以及 namespaceSelector 值为 null 均表示 "此 Pod 的名字空间"。

    • preferredDuringSchedulingIgnoredDuringExecution.weight (int32),必需

      weight 是匹配相应 podAffinityTerm 条件的权重,范围为 1-100。

  • requiredDuringSchedulingIgnoredDuringExecution ([]PodAffinityTerm)

    如果在调度时不满足该字段指定的反亲和性要求,则该 Pod 不会被调度到该节点上。 如果在 Pod 执行期间的某个时间点不再满足此字段指定的反亲和性要求(例如:由于 Pod 标签更新), 系统可能会或可能不会尝试最终将 Pod 从其节点中逐出。 当有多个元素时,每个 podAffinityTerm 对应的节点列表是取其交集的,即必须满足所有条件。

    定义一组 Pod(即那些与给定名字空间相关的标签选择算符匹配的 Pod 集合),当前 Pod 应该与该 Pod 集合位于同一位置(亲和性)或不位于同一位置(反亲和性)。 这里的 "位于同一位置" 含义是运行在一个节点上。基于 topologyKey 字段所给的标签键名, 检查所选 Pod 集合中各个 Pod 所在的节点上的标签值,标签值相同则认作 "位于同一位置"。

    • requiredDuringSchedulingIgnoredDuringExecution.topologyKey (string),必需

      此 Pod 应与指定名字空间中与标签选择算符匹配的 Pod 集合位于同一位置(亲和性) 或不位于同一位置(反亲和性), 这里的 "位于同一位置" 含义是运行在一个节点上。基于 topologyKey 字段所给的标签键名, 检查所选 Pod 集合中各个 Pod 所在的节点上的标签值,标签值相同则认作 "位于同一位置"。 不允许使用空的 topologyKey

    • requiredDuringSchedulingIgnoredDuringExecution.labelSelectorLabelSelector

      对一组资源的标签查询,在这里资源为 Pod。

    • requiredDuringSchedulingIgnoredDuringExecution.namespaceSelectorLabelSelector

      对条件所适用的名字空间集合的标签查询。 当前条件将应用于此字段选择的名字空间和 namespaces 字段中列出的名字空间。 选择算符为 null 和 namespaces 列表为 null 或空值表示 “此 Pod 的名字空间”。 空选择算符 ({}) 能够匹配所有名字空间。

    • requiredDuringSchedulingIgnoredDuringExecution.namespaces ([]string)

      namespaces 指定当前条件所适用的名字空间名称的静态列表。 当前条件适用于此字段中列出的名字空间和由 namespaceSelector 选中的名字空间。 namespaces 列表为 null 或空,以及 namespaceSelector 为 null 表示 “此 Pod 的名字空间”。

探针

探针描述了要对容器执行的健康检查,以确定它是否处于活动状态或准备好接收流量。


  • exec (execAction)

    exec 指定要执行的操作。

    ExecAction 描述了 "在容器中运行" 操作。

    • exec.command ([]string)

      command 是要在容器内执行的命令行,命令的工作目录是容器文件系统中的根目录('/')。 该命令只是通过 exec 执行,而不会启动 Shell,因此传统的 Shell 指令('|' 等)将不起作用。 要使用某 Shell,你需要显式调用该 Shell。 退出状态 0 被视为存活/健康,非零表示不健康。

  • httpGet (HTTPGetAction)

    httpGet 指定要执行的 HTTP 请求。

    HTTPGetAction 描述基于 HTTP Get 请求的操作。

    • httpGet.port (IntOrString),必需

      容器上要访问的端口的名称或端口号。端口号必须在 1 到 65535 内。名称必须是 IANA_SVC_NAME。

      IntOrString 是一种可以保存 int32 或字符串值的类型。在 JSON 或 YAML 编组和解组时, 它会生成或使用内部类型。例如,这允许你拥有一个可以接受名称或数字的 JSON 字段。

    • httpGet.host (string)

      要连接的主机名,默认为 Pod IP。你可能想在 httpHeaders 中设置 "Host"。

    • httpGet.httpHeaders ([]HTTPHeader)

      要在请求中设置的自定义 HTTP 标头。HTTP 允许重复的标头。

      HTTPHeader 描述了在 HTTP 探针中使用的自定义标头。

      • httpGet.httpHeaders.name (string),必需

        HTTP 头部域名称。 在输出时,它将被规范化处理,因此大小写变体的名称会被视为相同的头。

      • httpGet.httpHeaders.value (string),必需

        HTTP 头部域值。

    • httpGet.path (string)

      HTTP 服务器上的访问路径。

    • httpGet.scheme (string)

      用于连接到主机的方案。默认为 HTTP。

  • tcpSocket (TCPSocketAction)

    tcpSocket 指定涉及 TCP 端口的操作。

    TCPSocketAction 描述基于打开套接字的动作。

    • tcpSocket.port (IntOrString),必需

      容器上要访问的端口的端口号或名称。端口号必须在 1 到 65535 内。名称必须是 IANA_SVC_NAME。

      IntOrString 是一种可以保存 int32 或字符串的类型。在 JSON 或 YAML 编组和解组时, 它会生成或使用内部类型。例如,这允许你拥有一个可以接受名称或数字的 JSON 字段。

    • tcpSocket.host (string)

      可选字段。要连接的主机名,默认为 Pod IP。

  • terminationGracePeriodSeconds (int64)

    Pod 需要在探针失败时体面终止所需的时间长度(以秒为单位),为可选字段。 宽限期是 Pod 中运行的进程收到终止信号后,到进程被终止信号强制停止之前的时间长度(以秒为单位)。 你应该将此值设置为比你的进程的预期清理时间更长。 如果此值为 nil,则将使用 Pod 的 terminateGracePeriodSeconds。 否则,此值将覆盖 Pod 规约中设置的值。字段值值必须是非负整数。 零值表示收到终止信号立即停止(没有机会关闭)。 这是一个 Beta 字段,需要启用 ProbeTerminationGracePeriod 特性门控。最小值为 1。 如果未设置,则使用 spec.terminationGracePeriodSeconds

  • periodSeconds (int32)

    探针的执行周期(以秒为单位)。默认为 10 秒。最小值为 1。

  • failureThreshold (int32)

    探针成功后的最小连续失败次数,超出此阈值则认为探针失败。默认为 3。最小值为 1。

  • successThreshold (int32)

    探针失败后最小连续成功次数,超过此阈值才会被视为探针成功。默认为 1。 存活性探针和启动探针必须为 1。最小值为 1。

  • grpc (GRPCAction)

    GRPC 指定涉及 GRPC 端口的操作。

    • grpc.port (int32),必需

      gRPC 服务的端口号。数字必须在 1 到 65535 的范围内。

    • grpc.service (string)

      service 是要放置在 gRPC 运行状况检查请求中的服务的名称 (请参见 https://github.com/grpc/grpc/blob/master/doc/health-checking.md)。

      如果未指定,则默认行为由 gRPC 定义。

PodStatus

PodStatus 表示有关 Pod 状态的信息。状态内容可能会滞后于系统的实际状态, 尤其是在托管 Pod 的节点无法联系控制平面的情况下。


  • nominatedNodeName (string)

    仅当此 Pod 抢占节点上的其他 Pod 时才设置 nominatedNodeName, 但抢占操作的受害者会有体面终止期限,因此此 Pod 无法立即被调度。 此字段不保证 Pod 会在该节点上调度。 如果其他节点更早进入可用状态,调度器可能会决定将 Pod 放置在其他地方。 调度器也可能决定将此节点上的资源分配给优先级更高的、在抢占操作之后创建的 Pod。 因此,当 Pod 被调度时,该字段可能与 Pod 规约中的 nodeName 不同。

  • hostIP (string)

    hostIP 存储分配给 Pod 的主机的 IP 地址。如果 Pod 尚未启动,则为空。 Pod 可以被调度到 kubelet 有问题的节点上,这意味着即使有节点被分配给 Pod,hostIP 也不会被更新。

  • hostIPs ([]HostIP)

    补丁策略:基于 ip 键合并

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

    hostIPs 存储分配给主机的 IP 地址列表。如果此字段被指定,则第一个条目必须与 hostIP 字段匹配。 如果 Pod 尚未启动,则此列表为空。Pod 可以被调度到 kubelet 有问题的节点上, 这意味着即使有节点被分配给此 Pod,HostIPs 也不会被更新。

    HostIP 表示分配给主机的单个 IP 地址。

    • hostIPs.ip (string)

      ip 是分配给主机的 IP 地址。

  • startTime (Time)

    kubelet 确认 Pod 对象的日期和时间,格式遵从 RFC 3339。 此时间点处于 kubelet 为 Pod 拉取容器镜像之前。

    Time 是 time.Time 的包装器,支持正确编组为 YAML 和 JSON。 time 包所提供的许多工厂方法都有包装器。

  • phase (string)

    Pod 的 phase 是对 Pod 在其生命周期中所处位置的简单、高级摘要。 conditions 数组、reason 和 message 字段以及各个容器的 status 数组包含有关 Pod 状态的进一步详细信息。phase 的取值有五种可能性:

    • Pending:Pod 已被 Kubernetes 系统接受,但尚未创建容器镜像。 这包括 Pod 被调度之前的时间以及通过网络下载镜像所花费的时间。
    • Running:Pod 已经被绑定到某个节点,并且所有的容器都已经创建完毕。至少有一个容器仍在运行,或者正在启动或重新启动过程中。
    • Succeeded:Pod 中的所有容器都已成功终止,不会重新启动。
    • Failed:Pod 中的所有容器都已终止,并且至少有一个容器因故障而终止。 容器要么以非零状态退出,要么被系统终止。
    • Unknown:由于某种原因无法获取 Pod 的状态,通常是由于与 Pod 的主机通信时出错。

    更多信息: https://kubernetes.io/zh-cn/docs/concepts/workloads/pods/pod-lifecycle#pod-phase

  • message (string)

    一条人类可读的消息,标示有关 Pod 为何处于这种情况的详细信息。

  • reason (string)

    一条简短的驼峰式命名的消息,指示有关 Pod 为何处于此状态的详细信息。例如 'Evicted'。

  • podIP (string)

    分配给 Pod 的 podIP 地址。至少在集群内可路由。如果尚未分配则为空。

  • podIPs ([]PodIP)

    补丁策略:基于 ip 键合并

    podIPs 保存分配给 Pod 的 IP 地址。如果指定了该字段,则第 0 个条目必须与 podIP 字段值匹配。 Pod 最多可以为 IPv4 和 IPv6 各分配 1 个值。如果尚未分配 IP,则此列表为空。

    podIP 表示分配给 Pod 的单个 IP 地址。

    • podIP.ip (string)

      ip 是分配给 Pod 的 IP 地址。

  • ephemeralContainerStatuses ([]ContainerStatus)

    已在此 Pod 中运行的任何临时容器的状态。

    ContainerStatus 包含此容器当前状态的详细信息。

  • resourceClaimStatuses ([]PodResourceClaimStatus)

    补丁策略:retainKeys,基于键 name 合并

    映射:键 name 的唯一值将在合并过程中保留

    资源申领的状态。

    对于每个引用 ResourceClaimTemplate 的 PodResourceClaim,PodResourceClaimStatus 被存储在 PodStatus 中。它存储为对应 ResourceClaim 生成的名称。

    • resourceClaimStatuses.name (string), required

      Name 在 Pod 中唯一地标识此资源申领。 此名称必须与 pod.spec.resourceClaims 中的条目名称匹配,这意味着字符串必须是 DNS_LABEL。

    • resourceClaimStatuses.resourceClaimName (string)

      resourceClaimName 是为 Pod 在其名字空间中生成的 ResourceClaim 的名称。 如果此项未被设置,则不需要生成 ResourceClaim。在这种情况下,可以忽略 pod.spec.resourceClaims 这个条目。

  • resize (string)

    Pod 容器所需的资源大小调整状态。如果没有待处理的资源调整大小,则它为空。 对容器资源的任何更改都会自动将其设置为"建议"值。

PodList

PodList 是 Pod 的列表。


操作


get 读取指定的 Pod

HTTP 请求

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

参数

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

    Pod 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (Pod): OK

401: Unauthorized

get 读取指定 Pod 的 ephemeralcontainers

HTTP 请求

GET /api/v1/namespaces/{namespace}/pods/{name}/ephemeralcontainers

参数

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

    Pod 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (Pod): OK

401: Unauthorized

get 读取指定 Pod 的日志

HTTP 请求

GET /api/v1/namespaces/{namespace}/pods/{name}/log

参数

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

    Pod 的名称。

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

    namespace

  • container (查询参数): string

    为其流式传输日志的容器。如果 Pod 中有一个容器,则默认为仅容器。

  • follow (查询参数):boolean

    跟踪 Pod 的日志流。默认为 false。

  • insecureSkipTLSVerifyBackend (查询参数):boolean

    insecureSkipTLSVerifyBackend 表示 API 服务器不应确认它所连接的后端的服务证书的有效性。 这将使 API 服务器和后端之间的 HTTPS 连接不安全。 这意味着 API 服务器无法验证它接收到的日志数据是否来自真正的 kubelet。 如果 kubelet 配置为验证 API 服务器的 TLS 凭据,这并不意味着与真实 kubelet 的连接容易受到中间人攻击(例如,攻击者无法拦截来自真实 kubelet 的实际日志数据)。

  • limitBytes (查询参数): integer

    如果设置,则表示在终止日志输出之前从服务器读取的字节数。 设置此参数可能导致无法显示完整的最后一行日志记录,并且可能返回略多于或略小于指定限制。

  • pretty (查询参数): string

    pretty

  • previous (查询参数):boolean

    返回之前终止了的容器的日志。默认为 false。

  • sinceSeconds (查询参数): integer

    显示日志的当前时间之前的相对时间(以秒为单位)。如果此值早于 Pod 启动时间, 则仅返回自 Pod 启动以来的日志。如果此值是将来的值,则不会返回任何日志。 只能指定 sinceSecondssinceTime 之一。

  • tailLines (查询参数): integer

    如果设置,则从日志末尾开始显示的行数。如果未指定,则从容器创建或 sinceSecondssinceTime 时刻显示日志。

  • timestamps (查询参数):boolean

    如果为 true,则在每行日志输出的开头添加 RFC3339 或 RFC3339Nano 时间戳。默认为 false。

响应

200 (string): OK

401: Unauthorized

get 读取指定 Pod 的状态

HTTP 请求

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

参数

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

    Pod 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (Pod): OK

401: Unauthorized

list 列出或观察 Pod 种类的对象

HTTP 请求

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

参数

响应

200 (PodList): OK

401: Unauthorized

list 列出或观察 Pod 种类的对象

HTTP 请求

GET /api/v1/pods

参数

响应

200 (PodList): OK

401: Unauthorized

create 创建一个 Pod

HTTP 请求

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

参数

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

    namespace

  • bodyPod,必需

  • dryRun (查询参数): string

    dryRun

响应

200 (Pod): OK

201 (Pod): Created

202 (Pod): Accepted

401: Unauthorized

update 替换指定的 Pod

HTTP 请求

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

参数

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

    Pod 的名称。

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

    namespace

  • bodyPod,必需

响应

200 (Pod): OK

201 (Pod): Created

401: Unauthorized

update 替换指定 Pod 的 ephemeralcontainers

HTTP 请求

PUT /api/v1/namespaces/{namespace}/pods/{name}/ephemeralcontainers

参数

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

    Pod 的名称

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

    namespace

  • bodyPod,必需

响应

200 (Pod): OK

201 (Pod): Created

401: Unauthorized

update 替换指定 Pod 的状态

HTTP 请求

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

参数

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

    Pod 的名称

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

    namespace

  • bodyPod,必需

响应

200 (Pod): OK

201 (Pod): Created

401: Unauthorized

patch 部分更新指定 Pod

HTTP 请求

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

参数

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

    Pod 的名称

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

    namespace

  • bodyPatch,必需

响应

200 (Pod): OK

201 (Pod): Created

401: Unauthorized

patch 部分更新指定 Pod 的 ephemeralcontainers

HTTP 请求

PATCH /api/v1/namespaces/{namespace}/pods/{name}/ephemeralcontainers

参数

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

    Pod 的名称。

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

    namespace

  • bodyPatch,必需

响应

200 (Pod): OK

201 (Pod): Created

401: Unauthorized

patch 部分更新指定 Pod 的状态

HTTP 请求

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

参数

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

    Pod 的名称。

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

    namespace

  • bodyPatch,必需

响应

200 (Pod): OK

201 (Pod): Created

401: Unauthorized

delete 删除一个 Pod

HTTP 请求

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

参数

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

    Pod 的名称。

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

    namespace

  • bodyDeleteOptions

响应

200 (Pod): OK

202 (Pod): Accepted

401: Unauthorize

deletecollection 删除 Pod 的集合

HTTP 请求

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

参数

  • continue (查询参数): string

    continue

  • dryRun (查询参数): string

    dryRun

响应

200 (Status): OK

401: Unauthorized

1.2 - PodTemplate

PodTemplate 描述一种模板,用来为预定义的 Pod 生成副本。

apiVersion: v1

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

PodTemplate

PodTemplate 描述一种模板,用来为预定义的 Pod 生成副本。


PodTemplateSpec

PodTemplateSpec 描述基于某模板所创建的 Pod 所应具有的数据。


PodTemplateList

PodTemplateList 是 PodTemplate 对象的列表。


  • items ([]PodTemplate),必需

    PodTemplate 对象列表。

操作


get 读取指定的 PodTemplate

HTTP 请求

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

参数

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

    PodTemplate 的名称

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

    namespace

  • pretty查询参数):string

    pretty

响应

200 (PodTemplate): OK

401: Unauthorized

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

HTTP 请求

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

参数

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

    namespace

  • continue查询参数):string

    continue

  • limit查询参数):integer

    limit

  • pretty查询参数):string

    pretty

  • watch查询参数):boolean

    watch

响应

200 (PodTemplateList): OK

401: Unauthorized

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

HTTP 请求

GET /api/v1/podtemplates

参数

  • continue查询参数):string

    continue

  • limit查询参数):integer

    limit

  • pretty查询参数):string

    pretty

  • watch查询参数):boolean

    watch

响应

200 (PodTemplateList): OK

401: Unauthorized

create 创建一个 PodTemplate

HTTP 请求

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

参数

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

    namespace

  • dryRun查询参数):string

    dryRun

  • pretty查询参数):string

    pretty

响应

200 (PodTemplate): OK

201 (PodTemplate): Created

202 (PodTemplate): Accepted

401: Unauthorized

update 替换指定的 PodTemplate

HTTP 请求

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

参数

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

    PodTemplate 的名称

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

    namespace

  • dryRun查询参数):string

    dryRun

  • pretty查询参数):string

    pretty

响应

200 (PodTemplate): OK

201 (PodTemplate): Created

401: Unauthorized

patch 部分更新指定的 PodTemplate

HTTP 请求

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

参数

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

    PodTemplate 的名称

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

    namespace

  • dryRun查询参数):string

    dryRun

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (PodTemplate): OK

201 (PodTemplate): Created

401: Unauthorized

delete 删除一个 PodTemplate

HTTP 请求

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

参数

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

    PodTemplate 的名称

  • dryRun查询参数):string

    dryRun

  • pretty查询参数):string

    pretty

响应

200 (PodTemplate): OK

202 (PodTemplate): Accepted

401: Unauthorized

deletecollection 删除 PodTemplate 的集合

HTTP 请求

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

参数

  • continue查询参数):string

    continue

  • dryRun查询参数):string

    dryRun

  • limit查询参数):integer

    limit

  • pretty查询参数):string

    pretty

响应

200 (Status): OK

401: Unauthorized

1.3 - ReplicationController

ReplicationController 表示一个副本控制器的配置。

apiVersion: v1

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

ReplicationController

ReplicationController 表示一个副本控制器的配置。


  • apiVersion: v1

  • kind: ReplicationController

ReplicationControllerSpec

ReplicationControllerSpec 表示一个副本控制器的规约。


ReplicationControllerStatus

ReplicationControllerStatus 表示一个副本控制器的当前状态。


  • readyReplicas (int32)

    此副本控制器所用的就绪副本的数量。

  • fullyLabeledReplicas (int32)

    标签与副本控制器的 Pod 模板标签匹配的 Pod 数量。

  • conditions ([]ReplicationControllerCondition)

    补丁策略:按照键 type 合并

    表示副本控制器当前状态的最新可用观测值。

    ReplicationControllerCondition 描述某个点的副本控制器的状态。

    • conditions.status (string),必需

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

    • conditions.type (string),必需

      副本控制器状况的类型。

    • conditions.lastTransitionTime (Time)

      状况上次从一个状态转换为另一个状态的时间。

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

    • conditions.message (string)

    这是一条人类可读的消息,指示有关上次转换的详细信息。

    • conditions.reason (string)

      状况上次转换的原因。

  • observedGeneration (int64)

    observedGeneration 反映了最近观测到的副本控制器的生成情况。

ReplicationControllerList

ReplicationControllerList 是副本控制器的集合。


  • apiVersion: v1

  • kind: ReplicationControllerList

操作


get 读取指定的 ReplicationController

HTTP 请求

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

参数

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

    ReplicationController 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (ReplicationController): OK

401: Unauthorized

get 读取指定的 ReplicationController 的状态

HTTP 请求

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

参数

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

    ReplicationController 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (ReplicationController): OK

401: Unauthorized

list 列出或监视 ReplicationController 类别的对象

HTTP 请求

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

参数

响应

200 (ReplicationControllerList): OK

401: Unauthorized

list 列出或监视 ReplicationController 类别的对象

HTTP 请求

GET /api/v1/replicationcontrollers

参数

响应

200 (ReplicationControllerList): OK

401: Unauthorized

create 创建 ReplicationController

HTTP 请求

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

参数

响应

200 (ReplicationController): OK

201 (ReplicationController): Created

202 (ReplicationController): Accepted

401: Unauthorized

update 替换指定的 ReplicationController

HTTP 请求

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

参数

响应

200 (ReplicationController): OK

201 (ReplicationController): Created

401: Unauthorized

update 替换指定的 ReplicationController 的状态

HTTP 请求

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

参数

响应

200 (ReplicationController): OK

201 (ReplicationController): Created

401: Unauthorized

patch 部分更新指定的 ReplicationController

HTTP 请求

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

参数

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

    ReplicationController 的名称

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

    namespace

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (ReplicationController): OK

201 (ReplicationController): Created

401: Unauthorized

patch 部分更新指定的 ReplicationController 的状态

HTTP 请求

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

参数

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

    ReplicationController 的名称

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

    namespace

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (ReplicationController): OK

201 (ReplicationController): Created

401: Unauthorized

delete 删除 ReplicationController

HTTP 请求

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

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 ReplicationController 的集合

HTTP 请求

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

参数

响应

200 (Status): OK

401: Unauthorized

1.4 - ReplicaSet

ReplicaSet 确保在任何给定的时刻都在运行指定数量的 Pod 副本。

apiVersion: apps/v1

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

ReplicaSet

ReplicaSet 确保在任何给定的时刻都在运行指定数量的 Pod 副本。


  • apiVersion: apps/v1

  • kind: ReplicaSet

ReplicaSetSpec

ReplicaSetSpec 是 ReplicaSet 的规约。


ReplicaSetStatus

ReplicaSetStatus 表示 ReplicaSet 的当前状态。


  • readyReplicas (int32)

    readyReplicas 是此 ReplicaSet 在就绪状况下处理的目标 Pod 数量。

  • fullyLabeledReplicas (int32)

    标签与 ReplicaSet 的 Pod 模板标签匹配的 Pod 数量。

  • conditions ([]ReplicaSetCondition)

    补丁策略:按照键 type 合并

    表示副本集当前状态的最新可用观测值。

    ReplicaSetCondition 描述某个点的副本集状态。

    • conditions.status (string),必需

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

    • conditions.type (string),必需

      副本集状况的类型。

    • conditions.lastTransitionTime (Time)

      状况上次从一个状态转换为另一个状态的时间。

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

    • conditions.message (string)

      这是一条人类可读的消息,指示有关上次转换的详细信息。

    • conditions.reason (string)

      状况上次转换的原因。

  • observedGeneration (int64)

    observedGeneration 反映了最近观测到的 ReplicaSet 生成情况。

ReplicaSetList

ReplicaSetList 是多个 ReplicaSet 的集合。


  • apiVersion: apps/v1

  • kind: ReplicaSetList

操作


get 读取指定的 ReplicaSet

HTTP 请求

GET /apis/apps/v1/namespaces/{namespace}/replicasets/{name}

参数

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

    ReplicaSet 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (ReplicaSet): OK

401: Unauthorized

get 读取指定的 ReplicaSet 的状态

HTTP 请求

GET /apis/apps/v1/namespaces/{namespace}/replicasets/{name}/status

参数

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

    ReplicaSet 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (ReplicaSet): OK

401: Unauthorized

list 列出或监视 ReplicaSet 类别的对象

HTTP 请求

GET /apis/apps/v1/namespaces/{namespace}/replicasets

参数

响应

200 (ReplicaSetList): OK

401: Unauthorized

list 列出或监视 ReplicaSet 类别的对象

HTTP 请求

GET /apis/apps/v1/replicasets

参数

响应

200 (ReplicaSetList): OK

401: Unauthorized

create 创建 ReplicaSet

HTTP 请求

POST /apis/apps/v1/namespaces/{namespace}/replicasets

参数

响应

200 (ReplicaSet): OK

201 (ReplicaSet): Created

202 (ReplicaSet): Accepted

401: Unauthorized

update 替换指定的 ReplicaSet

HTTP 请求

PUT /apis/apps/v1/namespaces/{namespace}/replicasets/{name}

参数

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

    ReplicaSet 的名称

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

    namespace

  • body: ReplicaSet,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (ReplicaSet): OK

201 (ReplicaSet): Created

401: Unauthorized

update 替换指定的 ReplicaSet 的状态

HTTP 请求

PUT /apis/apps/v1/namespaces/{namespace}/replicasets/{name}/status

参数

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

    ReplicaSet 的名称

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

    namespace

  • body: ReplicaSet,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (ReplicaSet): OK

201 (ReplicaSet): Created

401: Unauthorized

patch 部分更新指定的 ReplicaSet

HTTP 请求

PATCH /apis/apps/v1/namespaces/{namespace}/replicasets/{name}

参数

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

    ReplicaSet 的名称

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

    namespace

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (ReplicaSet): OK

201 (ReplicaSet): Created

401: Unauthorized

patch 部分更新指定的 ReplicaSet 的状态

HTTP 请求

PATCH /apis/apps/v1/namespaces/{namespace}/replicasets/{name}/status

参数

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

    ReplicaSet 的名称

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

    namespace

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (ReplicaSet): OK

201 (ReplicaSet): Created

401: Unauthorized

delete 删除 ReplicaSet

HTTP 请求

DELETE /apis/apps/v1/namespaces/{namespace}/replicasets/{name}

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 ReplicaSet 的集合

HTTP 请求

DELETE /apis/apps/v1/namespaces/{namespace}/replicasets

参数

响应

200 (Status): OK

401: Unauthorized

1.5 - Deployment

Deployment 使得 Pod 和 ReplicaSet 能够进行声明式更新。

apiVersion: apps/v1

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

Deployment

Deployment 使得 Pod 和 ReplicaSet 能够进行声明式更新。


  • apiVersion: apps/v1

  • kind: Deployment

DeploymentSpec

DeploymentSpec 定义 Deployment 预期行为的规约。


  • selector (LabelSelector),必需

    供 Pod 所用的标签选择算符。通过此字段选择现有 ReplicaSet 的 Pod 集合, 被选中的 ReplicaSet 将受到这个 Deployment 的影响。此字段必须与 Pod 模板的标签匹配。

  • template (PodTemplateSpec),必需

    template 描述将要创建的 Pod。template.spec.restartPolicy 唯一被允许的值是 Always

  • replicas (int32)

    预期 Pod 的数量。这是一个指针,用于辨别显式零和未指定的值。默认为 1。

  • minReadySeconds (int32)

    新建的 Pod 在没有任何容器崩溃的情况下就绪并被系统视为可用的最短秒数。 默认为 0(Pod 就绪后即被视为可用)。

  • strategy (DeploymentStrategy)

    补丁策略:retainKeys

    将现有 Pod 替换为新 Pod 时所用的部署策略。

    DeploymentStrategy 描述如何将现有 Pod 替换为新 Pod。

    • strategy.type (string)

      部署的类型。取值可以是 “Recreate” 或 “RollingUpdate”。默认为 RollingUpdate。

    • strategy.rollingUpdate (RollingUpdateDeployment)

      滚动更新这些配置参数。仅当 type = RollingUpdate 时才出现。

      控制滚动更新预期行为的规约。

      • strategy.rollingUpdate.maxSurge (IntOrString)

        超出预期的 Pod 数量之后可以调度的最大 Pod 数量。该值可以是一个绝对数(例如: 5)或一个预期 Pod 的百分比(例如:10%)。如果 MaxUnavailable 为 0,则此字段不能为 0。 通过向上取整计算得出一个百分比绝对数。默认为 25%。例如:当此值设为 30% 时, 如果滚动更新启动,则可以立即对 ReplicaSet 扩容,从而使得新旧 Pod 总数不超过预期 Pod 数量的 130%。 一旦旧 Pod 被杀死,则可以再次对新的 ReplicaSet 扩容, 确保更新期间任何时间运行的 Pod 总数最多为预期 Pod 数量的 130%。

        IntOrString 是可以保存 int32 或字符串的一个类型。 当用于 JSON 或 YAML 编组和取消编组时,它会产生或消费内部类型。 例如,这允许你拥有一个可以接受名称或数值的 JSON 字段。

      • strategy.rollingUpdate.maxUnavailable (IntOrString)

        更新期间可能不可用的最大 Pod 数量。该值可以是一个绝对数(例如: 5)或一个预期 Pod 的百分比(例如:10%)。通过向下取整计算得出一个百分比绝对数。 如果 MaxSurge 为 0,则此字段不能为 0。默认为 25%。 例如:当此字段设为 30%,则在滚动更新启动时 ReplicaSet 可以立即缩容为预期 Pod 数量的 70%。 一旦新的 Pod 就绪,ReplicaSet 可以再次缩容,接下来对新的 ReplicaSet 扩容, 确保更新期间任何时间可用的 Pod 总数至少是预期 Pod 数量的 70%。

        IntOrString 是可以保存 int32 或字符串的一个类型。 当用于 JSON 或 YAML 编组和取消编组时,它会产生或消费内部类型。 例如,这允许你拥有一个可以接受名称或数值的 JSON 字段。

  • revisionHistoryLimit (int32)

    保留允许回滚的旧 ReplicaSet 的数量。这是一个指针,用于辨别显式零和未指定的值。默认为 10。

  • progressDeadlineSeconds (int32)

    Deployment 在被视为失败之前取得进展的最大秒数。Deployment 控制器将继续处理失败的部署, 原因为 ProgressDeadlineExceeded 的状况将被显示在 Deployment 状态中。 请注意,在 Deployment 暂停期间将不会估算进度。默认为 600s。

  • paused (boolean)

    指示部署被暂停。

DeploymentStatus

DeploymentStatus 是最近观测到的 Deployment 状态。


  • replicas (int32)

    此部署所针对的(其标签与选择算符匹配)未终止 Pod 的总数。

  • availableReplicas (int32)

    此部署针对的可用(至少 minReadySeconds 才能就绪)的 Pod 总数。

  • readyReplicas (int32)

    readyReplicas 是此 Deployment 在就绪状况下处理的目标 Pod 数量。

  • unavailableReplicas (int32)

    此部署针对的不可用 Pod 总数。这是 Deployment 具有 100% 可用容量时仍然必需的 Pod 总数。 它们可能是正在运行但还不可用的 Pod,也可能是尚未创建的 Pod。

  • updatedReplicas (int32)

    此 Deployment 所针对的未终止 Pod 的总数,这些 Pod 采用了预期的模板规约。

  • collisionCount (int32)

    供 Deployment 所用的哈希冲突计数。 Deployment 控制器在需要为最新的 ReplicaSet 创建名称时将此字段用作冲突预防机制。

  • conditions ([]DeploymentCondition)

    补丁策略:按照键 type 合并

    表示 Deployment 当前状态的最新可用观测值。

    DeploymentCondition 描述某个点的部署状态。

    • conditions.status (string),必需

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

    • conditions.type (string),必需

      Deployment 状况的类型。

    • conditions.lastTransitionTime (Time)

      状况上次从一个状态转换为另一个状态的时间。

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

    • conditions.lastUpdateTime (Time)

      上次更新此状况的时间。

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

    • conditions.message (string)

      这是一条人类可读的消息,指示有关上次转换的详细信息。

    • conditions.reason (string)

      状况上次转换的原因。

  • observedGeneration (int64)

    Deployment 控制器观测到的代数(Generation)。

DeploymentList

DeploymentList 是 Deployment 的列表。


  • apiVersion: apps/v1

  • kind: DeploymentList

  • metadata (ListMeta)

    标准的列表元数据。

  • items ([]Deployment),必需

    items 是 Deployment 的列表。

操作


get 读取指定的 Deployment

HTTP 请求

GET /apis/apps/v1/namespaces/{namespace}/deployments/{name}

参数

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

    Deployment 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (Deployment): OK

401: Unauthorized

get 读取指定的 Deployment 的状态

HTTP 请求

GET /apis/apps/v1/namespaces/{namespace}/deployments/{name}/status

参数

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

    Deployment 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (Deployment): OK

401: Unauthorized

list 列出或监视 Deployment 类别的对象

HTTP 请求

GET /apis/apps/v1/namespaces/{namespace}/deployments

参数

响应

200 (DeploymentList): OK

401: Unauthorized

list 列出或监视 Deployment 类别的对象

HTTP 请求

GET /apis/apps/v1/deployments

参数

响应

200 (DeploymentList): OK

401: Unauthorized

create 创建 Deployment

HTTP 请求

POST /apis/apps/v1/namespaces/{namespace}/deployments

参数

响应

200 (Deployment): OK

201 (Deployment): Created

202 (Deployment): Accepted

401: Unauthorized

update 替换指定的 Deployment

HTTP 请求

PUT /apis/apps/v1/namespaces/{namespace}/deployments/{name}

参数

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

    Deployment 的名称

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

    namespace

  • body: Deployment,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (Deployment): OK

201 (Deployment): Created

401: Unauthorized

update 替换指定的 Deployment 的状态

HTTP 请求

PUT /apis/apps/v1/namespaces/{namespace}/deployments/{name}/status

参数

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

    Deployment 的名称

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

    namespace

  • body: Deployment,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (Deployment): OK

201 (Deployment): Created

401: Unauthorized

patch 部分更新指定的 Deployment

HTTP 请求

PATCH /apis/apps/v1/namespaces/{namespace}/deployments/{name}

参数

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

    Deployment 的名称

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

    namespace

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (Deployment): OK

201 (Deployment): Created

401: Unauthorized

patch 部分更新指定的 Deployment 的状态

HTTP 请求

PATCH /apis/apps/v1/namespaces/{namespace}/deployments/{name}/status

参数

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

    Deployment 的名称

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

    namespace

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (Deployment): OK

201 (Deployment): Created

401: Unauthorized

delete 删除 Deployment

HTTP 请求

DELETE /apis/apps/v1/namespaces/{namespace}/deployments/{name}

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 Deployment 的集合

HTTP 请求

DELETE /apis/apps/v1/namespaces/{namespace}/deployments

参数

响应

200 (Status): OK

401: Unauthorized

1.6 - StatefulSet

StatefulSet 表示一组具有一致身份的 Pod

apiVersion: apps/v1

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

StatefulSet

StatefulSet 表示一组具有一致身份的 Pod。身份定义为:

  • 网络:一个稳定的 DNS 和主机名。
  • 存储:根据要求提供尽可能多的 VolumeClaim。

StatefulSet 保证给定的网络身份将始终映射到相同的存储身份。


StatefulSetSpec

StatefulSetSpec 是 StatefulSet 的规约。


  • serviceName (string), 必需

    serviceName 是管理此 StatefulSet 服务的名称。 该服务必须在 StatefulSet 之前即已存在,并负责该集合的网络标识。 Pod 会获得符合以下模式的 DNS/主机名: pod-specific-string.serviceName.default.svc.cluster.local。 其中 “pod-specific-string” 由 StatefulSet 控制器管理。

  • template (PodTemplateSpec), 必需

    template 是用来描述 Pod 的对象,检测到副本不足时将创建所描述的 Pod。 经由 StatefulSet 创建的每个 Pod 都将满足这个模板,但与 StatefulSet 的其余 Pod 相比,每个 Pod 具有唯一的标识。 每个 Pod 将以 <statefulsetname>-<podindex> 格式命名。 例如,名为 "web" 且索引号为 "3" 的 StatefulSet 中的 Pod 将被命名为 "web-3"。 template.spec.restartPolicy 唯一被允许的值是 Always

  • replicas (int32)

    replicas 是给定模板的所需的副本数。之所以称作副本,是因为它们是相同模板的实例, 不过各个副本也具有一致的身份。如果未指定,则默认为 1。

  • updateStrategy (StatefulSetUpdateStrategy)

    updateStrategy 是一个 StatefulSetUpdateStrategy,表示当对 template 进行修订时,用何种策略更新 StatefulSet 中的 Pod 集合。

    StatefulSetUpdateStrategy 表示 StatefulSet 控制器将用于执行更新的策略。其中包括为指定策略执行更新所需的额外参数。

    • updateStrategy.type (string)

    type 表示 StatefulSetUpdateStrategy 的类型,默认为 RollingUpdate。

    • updateStrategy.rollingUpdate (RollingUpdateStatefulSetStrategy)

      当 type 为 RollingUpdate 时,使用 rollingUpdate 来传递参数。

      RollingUpdateStatefulSetStrategy 用于为 rollingUpdate 类型的更新传递参数。

      • updateStrategy.rollingUpdate.maxUnavailable (IntOrString)

        更新期间不可用的 Pod 个数上限。取值可以是绝对数量(例如:5)或所需 Pod 的百分比(例如:10%)。 绝对数是通过四舍五入的百分比计算得出的。不能为 0,默认为 1。 此字段为 Alpha 级别,仅被启用 MaxUnavailableStatefulSet 特性的服务器支持。 此字段适用于 0 到 replicas-1 范围内的所有 Pod。这意味着如果在 0 到 replicas-1 范围内有任何不可用的 Pod, 这些 Pod 将被计入 maxUnavailable 中。

        IntOrString 是一种可以包含 int32 或字符串数值的类型。在 JSON 或 YAML 编组和解组时, 会生成或使用内部类型。例如,此类型允许你定义一个可以接受名称或数字的 JSON 字段。

      • updateStrategy.rollingUpdate.partition (int32)

        partition 表示 StatefulSet 应该被分区进行更新时的序数。 在滚动更新期间,序数在 replicas-1 和 partition 之间的所有 Pod 都会被更新。 序数在 partition-1 和 0 之间的所有 Pod 保持不变。 这一属性有助于进行金丝雀部署。默认值为 0。

  • podManagementPolicy (string)

    podManagementPolicy 控制在初始规模扩展期间、替换节点上的 Pod 或缩减集合规模时如何创建 Pod。 默认策略是 “OrderedReady”,各个 Pod 按升序创建的(pod-0,然后是pod-1 等), 控制器将等到每个 Pod 都准备就绪后再继续。缩小集合规模时,Pod 会以相反的顺序移除。 另一种策略是 “Parallel”,意味着并行创建 Pod 以达到预期的规模而无需等待,并且在缩小规模时将立即删除所有 Pod。

  • revisionHistoryLimit (int32)

    revisionHistoryLimit 是在 StatefulSet 的修订历史中维护的修订个数上限。 修订历史中包含并非由当前所应用的 StatefulSetSpec 版本未表示的所有修订版本。默认值为 10。

  • volumeClaimTemplates ([]PersistentVolumeClaim)

    volumeClaimTemplates 是允许 Pod 引用的申领列表。 StatefulSet controller 负责以维持 Pod 身份不变的方式将网络身份映射到申领之上。 此列表中的每个申领至少必须在模板的某个容器中存在匹配的(按 name 匹配)volumeMount。 此列表中的申领优先于模板中具有相同名称的所有卷。

  • minReadySeconds (int32)

    新创建的 Pod 应准备就绪(其任何容器都未崩溃)的最小秒数,以使其被视为可用。 默认为 0(Pod 准备就绪后将被视为可用)。

  • persistentVolumeClaimRetentionPolicy (StatefulSetPersistentVolumeClaimRetentionPolicy)

    persistentVolumeClaimRetentionPolicy 描述从 VolumeClaimTemplates 创建的持久卷申领的生命周期。 默认情况下,所有持久卷申领都根据需要创建并被保留到手动删除。 此策略允许更改申领的生命周期,例如在 StatefulSet 被删除或其中 Pod 集合被缩容时删除持久卷申领。 此属性需要启用 StatefulSetAutoDeletePVC 特性门控。特性处于 Alpha 阶段。可选。

    StatefulSetPersistentVolumeClaimRetentionPolicy 描述了用于从 StatefulSet VolumeClaimTemplate 创建的 PVC 的策略

    • persistentVolumeClaimRetentionPolicy.whenDeleted (string)

      whenDeleted 指定当 StatefulSet 被删除时,基于 StatefulSet VolumeClaimTemplates 所创建的 PVC 会发生什么。 默认策略 Retain 使 PVC 不受 StatefulSet 被删除的影响。Delete 策略会导致这些 PVC 也被删除。

    • persistentVolumeClaimRetentionPolicy.whenScaled (string)

      whenScaled 指定当 StatefulSet 缩容时,基于 StatefulSet volumeClaimTemplates 创建的 PVC 会发生什么。 默认策略 Retain 使 PVC 不受缩容影响。 Delete 策略会导致超出副本个数的所有的多余 Pod 所关联的 PVC 被删除。

  • ordinals (StatefulSetOrdinals)

    ordinals 控制 StatefulSet 中副本索引的编号。 默认序数行为是将索引 "0" 设置给第一个副本,对于每个额外请求的副本,该索引加一。 使用 ordinals 字段需要启用 Beta 级别的 StatefulSetStartOrdinal 特性门控。

    StatefulSetOrdinals 描述此 StatefulSet 中用于副本序数赋值的策略。

    • ordinals.start (int32)

      start 是代表第一个副本索引的数字。它可用于从替代索引(例如:从 1 开始索引)而非默认的从 0 索引来为副本设置编号,
      

      还可用于编排从一个 StatefulSet 到另一个 StatefulSet 的渐进式副本迁移动作。如果设置了此值,副本索引范围为 [.spec.ordinals.start, .spec.ordinals.start + .spec.replicas)。如果不设置,则默认为 0。 副本索引范围为 [0, .spec.replicas)。

StatefulSetStatus

StatefulSetStatus 表示 StatefulSet 的当前状态。


  • replicas (int32), 必需

    replicas 是 StatefulSet 控制器创建的 Pod 个数。

  • readyReplicas (int32)

    readyReplicas 是为此 StatefulSet 创建的、状况为 Ready 的 Pod 个数。

  • currentReplicas (int32)

    currentReplicas 是 StatefulSet 控制器根据 currentReplicas 所指的 StatefulSet 版本创建的 Pod 个数。

  • updatedReplicas (int32)

    updatedReplicas 是 StatefulSet 控制器根据 updateRevision 所指的 StatefulSet 版本创建的 Pod 个数。

  • availableReplicas (int32)

    此 StatefulSet 所对应的可用 Pod 总数(就绪时长至少为 minReadySeconds)。

  • collisionCount (int32)

    collisionCount 是 StatefulSet 的哈希冲突计数。 StatefulSet controller 在需要为最新的 controllerRevision 创建名称时使用此字段作为避免冲突的机制。

  • conditions ([]StatefulSetCondition)

    补丁策略:根据 type 键执行合并操作

    表示 StatefulSet 当前状态的最新可用观察结果。

    StatefulSetCondition 描述了 StatefulSet 在某个点的状态。

    • conditions.status (string), 必需

      状况的状态为 True、False、Unknown 之一。

    • conditions.type (string), 必需

      StatefulSet 状况的类型。

    • conditions.lastTransitionTime (Time)

      最近一次状况从一种状态转换到另一种状态的时间。

      Time 是 time.Time 的包装器,它支持对 YAML 和 JSON 的正确编组。 time 包的许多工厂方法提供了包装器。

    • conditions.message (string)

      一条人类可读的消息,指示有关转换的详细信息。

    • conditions.reason (string)

      状况最后一次转换的原因。

  • currentRevision (string)

    currentRevision,如果不为空,表示用于在序列 [0,currentReplicas) 之间生成 Pod 的 StatefulSet 的版本。

  • updateRevision (string)

    updateRevision,如果不为空,表示用于在序列 [replicas-updatedReplicas,replicas) 之间生成 Pod 的 StatefulSet 的版本。

  • observedGeneration (int64)

    observedGeneration 是 StatefulSet 的最新一代。它对应于 StatefulSet 的代数,由 API 服务器在变更时更新。

StatefulSetList

StatefulSetList 是 StatefulSet 的集合。


  • items ([]StatefulSet), 必需

    items 是 StatefulSet 的列表。

操作


get 读取指定的 StatefulSet

HTTP 请求

GET /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}

参数

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

    StatefulSet 的名称。

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (StatefulSet): OK

401: Unauthorized

get 读取指定 StatefulSet 的状态

HTTP 请求

GET /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/status

参数

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

    StatefulSet 的名称。

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (StatefulSet): OK

401: Unauthorized

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

HTTP 请求

GET /apis/apps/v1/namespaces/{namespace}/statefulsets

参数

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

    namespace

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

  • watch (查询参数): boolean

    watch

响应

200 (StatefulSetList): OK

401: Unauthorized

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

HTTP 请求

GET /apis/apps/v1/statefulsets

参数

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

  • watch (查询参数): boolean

    watch

响应

200 (StatefulSetList): OK

401: Unauthorized

create 创建一个 StatefulSet

HTTP 请求

POST /apis/apps/v1/namespaces/{namespace}/statefulsets

参数

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

    namespace

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

pretty

响应

200 (StatefulSet): OK

201 (StatefulSet): Created

202 (StatefulSet): Accepted

401: Unauthorized

update 替换指定的 StatefulSet

HTTP 请求

PUT /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}

参数

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

    StatefulSet 的名称 。

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

    namespace

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (StatefulSet): OK

201 (StatefulSet): Created

401: Unauthorized

update 替换指定 StatefulSet 的状态

HTTP 请求

PUT /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/status

参数

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

    StatefulSet 的名称。

  • namespace (路径参数): string, required

    namespace

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (StatefulSet): OK

201 (StatefulSet): Created

401: Unauthorized

patch 部分更新指定的 StatefulSet

HTTP 请求

PATCH /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}

参数

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

    StatefulSet 的名称。

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

    namespace

  • dryRun (查询参数): string

    dryRun

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (StatefulSet): OK

201 (StatefulSet): Created

401: Unauthorized

patch 部分更新指定 StatefulSet 的状态

HTTP 请求

PATCH /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/status

参数

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

    StatefulSet 的名称。

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

    namespace

  • dryRun (查询参数): string

    dryRun

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (StatefulSet): OK

201 (StatefulSet): Created

401: Unauthorized

delete 删除一个 StatefulSet

HTTP 请求

DELETE /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}

参数

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

    StatefulSet 的名称。

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 StatefulSet 的集合

HTTP 请求

DELETE /apis/apps/v1/namespaces/{namespace}/statefulsets

参数

  • dryRun (查询参数): string

    dryRun

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

响应

200 (Status): OK

401: Unauthorized

1.7 - ControllerRevision

ControllerRevision 实现了状态数据的不可变快照。

apiVersion: apps/v1

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

ControllerRevision

ControllerRevision 实现了状态数据的不可变快照。 客户端负责序列化和反序列化对象,包含对象内部状态。 成功创建 ControllerRevision 后,将无法对其进行更新。 API 服务器将无法成功验证所有尝试改变 data 字段的请求。 但是,可以删除 ControllerRevisions。 请注意,由于 DaemonSet 和 StatefulSet 控制器都使用它来进行更新和回滚,所以这个对象是 Beta 版。 但是,它可能会在未来版本中更改名称和表示形式,客户不应依赖其稳定性。 它主要供控制器内部使用。


  • apiVersion: apps/v1
  • kind: ControllerRevision
  • revision (int64),必需

    revision 表示 data 表示的状态的修订。

  • data (RawExtension)

    data 是状态的序列化表示。

    RawExtension 用于以外部版本来保存扩展数据。

    要使用它,请生成一个字段,在外部、版本化结构中以 RawExtension 作为其类型,在内部结构中以 Object 作为其类型。 你还需要注册你的各个插件类型。

    // 内部包:

    type MyAPIObject struct {  
      runtime.TypeMeta `json:",inline"`   
      MyPlugin runtime.Object `json:"myPlugin"`  
    } 
    
    type PluginA struct {  
      AOption string `json:"aOption"`  
    }
    

    // 外部包:

    type MyAPIObject struct {  
      runtime.TypeMeta `json:",inline"`  
      MyPlugin runtime.RawExtension `json:"myPlugin"`    
    } 
    
    type PluginA struct {  
      AOption string `json:"aOption"`  
    }
    

    // 在网络上,JSON 看起来像这样:

    {  
      "kind":"MyAPIObject",  
      "apiVersion":"v1",  
      "myPlugin": {  
        "kind":"PluginA",  
        "aOption":"foo",  
      },  
    }
    

    那么会发生什么? 解码首先使用 json 或 yaml 将序列化数据解组到你的外部 MyAPIObject 中。 这会导致原始 JSON 被存储下来,但不会被解包。 下一步是复制(使用 pkg/conversion)到内部结构中。 runtime 包的 DefaultScheme 安装了转换函数,它将解析存储在 RawExtension 中的 JSON, 将其转换为正确的对象类型,并将其存储在 Object 中。 (TODO:如果对象是未知类型,将创建并存储一个 runtime.Unknown对象。)

ControllerRevisionList

ControllerRevisionList 是一个包含 ControllerRevision 对象列表的资源。


  • apiVersion: apps/v1
  • kind: ControllerRevisionList

操作


get 读取特定的 ControllerRevision

HTTP 请求

GET /apis/apps/v1/namespaces/{namespace}/controllerrevisions/{name}

参数

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

    ControllerRevision 的名称

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

    namespace

  • pretty查询参数):string

    pretty

响应

200 (ControllerRevision): OK

401: Unauthorized

list 列出或监视 ControllerRevision 类别的对象

HTTP 请求

GET /apis/apps/v1/namespaces/{namespace}/controllerrevisions

参数

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

    namespace

  • continue查询参数):string

    continue

  • limit (查询参数)): integer

    limit

  • pretty查询参数):string

    pretty

  • watch查询参数): boolean

    watch

响应

200 (ControllerRevisionList): OK

401: Unauthorized

list 列出或监视 ControllerRevision 类别的对象

HTTP 请求

GET /apis/apps/v1/controllerrevisions

参数

  • continue查询参数):string

    continue

  • limit查询参数): integer

    limit

  • pretty查询参数):string

    pretty

  • watch查询参数): boolean

    watch

响应

200 (ControllerRevisionList): OK

401: Unauthorized

create 创建一个 ControllerRevision

HTTP 请求

POST /apis/apps/v1/namespaces/{namespace}/controllerrevisions

参数

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

    namespace

  • dryRun查询参数):string

    dryRun

  • pretty查询参数):string

    pretty

响应

200 (ControllerRevision): OK

201 (ControllerRevision): Created

202 (ControllerRevision): Accepted

401: Unauthorized

update 替换特定的 ControllerRevision

HTTP 参数

PUT /apis/apps/v1/namespaces/{namespace}/controllerrevisions/{name}

参数

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

    ControllerRevision 的名称

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

    namespace

  • dryRun查询参数):string

    dryRun

  • pretty查询参数):string

    pretty

响应

200 (ControllerRevision): OK

201 (ControllerRevision): Created

401: Unauthorized

patch 部分更新特定的 ControllerRevision

HTTP 请求

PATCH /apis/apps/v1/namespaces/{namespace}/controllerrevisions/{name}

参数

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

    ControllerRevision 的名称

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

    namespace

  • dryRun查询参数):string

    dryRun

  • force查询参数): boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (ControllerRevision): OK

201 (ControllerRevision): Created

401: Unauthorized

delete 删除一个 ControllerRevision

HTTP 请求

DELETE /apis/apps/v1/namespaces/{namespace}/controllerrevisions/{name}

参数

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

    ControllerRevision 的名称

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

    namespace

  • dryRun查询参数):string

    dryRun

  • pretty查询参数):string

    pretty

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 ControllerRevision 集合

HTTP 请求

DELETE /apis/apps/v1/namespaces/{namespace}/controllerrevisions

参数

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

    namespace

  • continue查询参数):string

    continue

  • dryRun查询参数):string

    dryRun

  • limit查询参数): integer

    limit

  • pretty查询参数):string

    pretty

响应

200 (Status): OK

401: Unauthorized

1.8 - DaemonSet

DaemonSet 表示守护进程集的配置。

apiVersion: apps/v1

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

DaemonSet

DaemonSet 表示守护进程集的配置。


  • apiVersion: apps/v1

  • kind: DaemonSet

DaemonSetSpec

DaemonSetSpec 是守护进程集的规约。


  • minReadySeconds (int32)

    新建的 DaemonSet Pod 应该在没有任何容器崩溃的情况下处于就绪状态的最小秒数,这样它才会被认为是可用的。 默认为 0(Pod 准备就绪后将被视为可用)。

  • updateStrategy (DaemonSetUpdateStrategy)

    用新 Pod 替换现有 DaemonSet Pod 的更新策略。

    DaemonSetUpdateStrategy 是一个结构体,用于控制 DaemonSet 的更新策略。

    • updateStrategy.type (string)

      守护进程集更新的类型。可以是 "RollingUpdate" 或 "OnDelete"。默认为 RollingUpdate。

    • updateStrategy.rollingUpdate (RollingUpdateDaemonSet)

      滚动更新配置参数。仅在 type 值为 "RollingUpdate" 时出现。

      用于控制守护进程集滚动更新的预期行为的规约。

      • updateStrategy.rollingUpdate.maxSurge (IntOrString)

        对于拥有可用 DaemonSet Pod 的节点而言,在更新期间可以拥有更新后的 DaemonSet Pod 的最大节点数。 属性值可以是绝对数量(例如:5)或所需 Pod 的百分比(例如:10%)。 如果 maxUnavailable 为 0,则该值不能为 0。绝对数是通过四舍五入从百分比计算得出的,最小值为 1。 默认值为 0。示例:当设置为 30% 时,最多为节点总数的 30% 节点上应该运行守护进程 Pod (即 status.desiredNumberScheduled) 可以在旧 Pod 标记为已删除之前创建一个新 Pod。更新首先在 30% 的节点上启动新的 Pod。 一旦更新的 Pod 可用(就绪时长至少 minReadySeconds 秒),该节点上的旧 DaemonSet pod 就会被标记为已删除。 如果旧 Pod 因任何原因变得不可用(Ready 转换为 false、被驱逐或节点被腾空), 则会立即在该节点上创建更新的 Pod,而不考虑激增限制。 允许激增意味着如果就绪检查失败,任何给定节点上的守护进程集消耗的资源可能会翻倍, 因此资源密集型守护进程集应该考虑到它们可能会在中断期间导致驱逐。

        IntOrString 是一种可以容纳 int32 或字符串的类型。在 JSON 或 YAML 编组和解组中使用时,它会生成或使用内部类型。 例如,这允许你拥有一个可以接受名称或数字的 JSON 字段。

      • updateStrategy.rollingUpdate.maxUnavailable (IntOrString)

        更新期间不可用的 DaemonSet Pod 的最大数量。值可以是绝对数(例如:5)或更新开始时 DaemonSet Pod 总数的百分比(例如:10%)。 绝对数是通过四舍五入的百分比计算得出的。如果 maxSurge 为 0,则此值不能为 0 默认值为 1。 例如:当设置为 30% 时,最多节点总数 30% 的、应该运行守护进程的节点总数(即 status.desiredNumberScheduled) 可以在任何给定时间停止更新。更新首先停止最多 30% 的 DaemonSet Pod, 然后在它们的位置启动新的 DaemonSet Pod。 一旦新的 Pod 可用,它就会继续处理其他 DaemonSet Pod,从而确保在更新期间至少 70% 的原始 DaemonSet Pod 数量始终可用。

        IntOrString 是一种可以保存 int32 或字符串的类型。在 JSON 或 YAML 编组和解组中使用时,它会生成或使用内部类型。例如,这允许你拥有一个可以接受名称或数字的 JSON 字段。

  • revisionHistoryLimit (int32)

    用来允许回滚而保留的旧历史记录的数量。此字段是个指针,用来区分明确的零值和未指定的指针。默认值是 10。

DaemonSetStatus

DaemonSetStatus 表示守护进程集的当前状态。


  • numberReady (int32),必需

    numberReady 是应该运行守护进程 Pod 并且有一个或多个 DaemonSet Pod 以就绪条件运行的节点数。

  • numberAvailable (int32)

    应该运行守护进程 Pod 并有一个或多个守护进程 Pod 正在运行和可用(就绪时长超过 spec.minReadySeconds)的节点数量。

  • numberUnavailable (int32)

    应该运行守护进程 Pod 并且没有任何守护进程 Pod 正在运行且可用(至少已就绪 spec.minReadySeconds 秒)的节点数。

  • updatedNumberScheduled (int32)

    正在运行更新后的守护进程 Pod 的节点总数。

  • collisionCount (int32)

    DaemonSet 的哈希冲突计数。DaemonSet 控制器在需要为最新的 ControllerRevision 创建名称时使用此字段作为避免冲突的机制。

  • conditions ([]DaemonSetCondition)

    补丁策略:根据 type 键合并

    表示 DaemonSet 当前状态的最新可用观测信息。

    DaemonSet Condition 描述了 DaemonSet 在某一时刻的状态。

    • conditions.status (string),必需

      状况的状态,True、False、Unknown 之一。

    • conditions.type (string),必需

      DaemonSet 状况的类型。

    • conditions.lastTransitionTime (Time)

      状况上次从一种状态转换到另一种状态的时间。

      Time 是对 time.Time 的封装,支持正确编码为 YAML 和 JSON。time 包为许多工厂方法提供了封装器。

    • conditions.message (string)

      一条人类可读的消息,指示有关转换的详细信息。

    • conditions.reason (string)

      状况最后一次转换的原因。

  • observedGeneration (int64)

    守护进程集控制器观察到的最新一代。

DaemonSetList

DaemonSetList 是守护进程集的集合。


  • apiVersion: apps/v1

  • kind: DaemonSetList

Operations


get 读取指定的 DaemonSet

HTTP 请求

GET /apis/apps/v1/namespaces/{namespace}/daemonsets/{name}

参数

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

    DaemonSet 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (DaemonSet): OK

401: 未授权

get 读取指定的 DaemonSet 的状态

HTTP 请求

GET /apis/apps/v1/namespaces/{namespace}/daemonsets/{name}/status

参数

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

    DaemonSet 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (DaemonSet): OK

401: 未授权

list 列表或查看 DaemonSet 类型的对象

HTTP 请求

GET /apis/apps/v1/namespaces/{namespace}/daemonsets

参数

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

    namespace

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

响应

200 (DaemonSetList): OK

401: 未授权

list 列表或查看 DaemonSet 类型的对象

HTTP 请求

GET /apis/apps/v1/daemonsets

参数

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

响应

200 (DaemonSetList): OK

401: 未授权

create 创建一个 DaemonSet

HTTP 请求

POST /apis/apps/v1/namespaces/{namespace}/daemonsets

参数

响应

200 (DaemonSet): OK

201 (DaemonSet): 创建完成

202 (DaemonSet): 已接受

401: 未授权

update 替换指定的 DaemonSet

HTTP 请求

PUT /apis/apps/v1/namespaces/{namespace}/daemonsets/{name}

参数

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

    DaemonSet 的名称

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

    namespace

  • body: DaemonSet,必需

响应

200 (DaemonSet): OK

201 (DaemonSet): 已创建

401: 未授权

update 替换指定 DaemonSet 的状态

HTTP 请求

PUT /apis/apps/v1/namespaces/{namespace}/daemonsets/{name}/status

参数

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

    DaemonSet 的名称

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

    namespace

  • body: DaemonSet, 必需

响应

200 (DaemonSet): OK

201 (DaemonSet): 已创建

401: 未授权

patch 部分更新指定的 DaemonSet

HTTP 请求

PATCH /apis/apps/v1/namespaces/{namespace}/daemonsets/{name}

参数

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

    DaemonSet 的名称

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

    namespace

  • body: Patch, 必需

  • pretty (查询参数): string

    pretty

响应

200 (DaemonSet): OK

201 (DaemonSet): 已创建

401: 未授权

patch 部分更新指定 DaemonSet 的状态

HTTP 请求

PATCH /apis/apps/v1/namespaces/{namespace}/daemonsets/{name}/status

参数

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

    DaemonSet 的名称

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

    namespace

  • body: Patch, 必需

  • pretty (查询参数): string

    pretty

响应

200 (DaemonSet): OK

201 (DaemonSet): 已创建

401: 未授权

delete 删除一个 DaemonSet

HTTP 请求

DELETE /apis/apps/v1/namespaces/{namespace}/daemonsets/{name}

参数

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

    DaemonSet 的名称

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

    namespace

  • body: DeleteOptions

响应

200 (Status): OK

202 (Status): 已接受

401: 未授权

deletecollection 删除 DaemonSet 的集合

HTTP 请求

DELETE /apis/apps/v1/namespaces/{namespace}/daemonsets

参数

  • continue (查询参数): string

    continue

  • dryRun (查询参数): string

    dryRun

响应

200 (Status): OK

401: 未授权

1.9 - Job

Job 表示单个任务的配置。

apiVersion: batch/v1

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

Job

Job 表示单个任务的配置。


  • apiVersion: batch/v1

  • kind: Job

JobSpec

JobSpec 描述了任务执行的情况。


Replicas

Lifecycle

  • completionMode (string)

    completionMode 指定如何跟踪 Pod 完成情况。它可以是 NonIndexed(默认)或者 Indexed

    NonIndexed 表示当有 .spec.completions 个成功完成的 Pod 时,认为 Job 完成。每个 Pod 完成都是彼此同源的。

    Indexed 意味着 Job 的各个 Pod 会获得对应的完成索引值,从 0 到(.spec.completions - 1),可在注解 "batch.kubernetes.io/job-completion-index" 中找到。当每个索引都对应有一个成功完成的 Pod 时, 该任务被认为是完成的。 当值为 Indexed 时,必须指定 .spec.completions 并且 .spec.parallelism 必须小于或等于 10^5。 此外,Pod 名称采用 $(job-name)-$(index)-$(random-string) 的形式,Pod 主机名采用 $(job-name)-$(index) 的形式。

    将来可能添加更多的完成模式。如果 Job 控制器发现它无法识别的模式 (这种情况在升级期间由于版本偏差可能发生),则控制器会跳过 Job 的更新。

  • backoffLimit (int32)

    指定标记此任务失败之前的重试次数。默认值为 6。

  • activeDeadlineSeconds (int64)

    系统尝试终止任务之前任务可以持续活跃的持续时间(秒),时间长度是相对于 startTime 的; 字段值必须为正整数。如果任务被挂起(在创建期间或因更新而挂起), 则当任务再次恢复时,此计时器会被停止并重置。

  • ttlSecondsAfterFinished (int32)

    ttlSecondsAfterFinished 限制已完成执行(完成或失败)的任务的生命周期。如果设置了这个字段, 在 Job 完成 ttlSecondsAfterFinished 秒之后,就可以被自动删除。 当 Job 被删除时,它的生命周期保证(例如终结器)会被考察。 如果未设置此字段,则任务不会被自动删除。如果此字段设置为零,则任务在完成后即可立即删除。

  • suspend (boolean)

    suspend 指定 Job 控制器是否应该创建 Pod。如果创建 Job 时将 suspend 设置为 true,则 Job 控制器不会创建任何 Pod。 如果 Job 在创建后被挂起(即标志从 false 变为 true),则 Job 控制器将删除与该 Job 关联的所有活动 Pod。 用户必须设计他们的工作负载来优雅地处理这个问题。暂停 Job 将重置 Job 的 startTime 字段, 也会重置 ActiveDeadlineSeconds 计时器。默认为 false。

Selector

Beta 级别

  • podFailurePolicy (PodFailurePolicy)

    指定处理失效 Pod 的策略。特别是,它允许指定采取关联操作需要满足的一组操作和状况。 如果为空,则应用默认行为:由该任务的 .status.failed 字段表示的失效 Pod 的计数器将递增, 并针对 backoffLimit 进行检查。此字段不能与 restartPolicy=OnFailure 结合使用。

    此字段是 Beta 级别。当 JobPodFailurePolicy 特性门控被启用时(默认被启用),可以使用此字段。

    PodFailurePolicy 描述失效的 Pod 如何影响 backoffLimit。

    • podFailurePolicy.rules ([]PodFailurePolicyRule),必需

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

      Pod 失效策略规则的列表。这些规则按顺序进行评估。一旦某规则匹配 Pod 失效,则其余规将被忽略。 当没有规则匹配 Pod 失效时,将应用默认的处理方式: Pod 失效的计数器递增并针对 backoffLimit 进行检查。最多允许 20 个。

      PodFailurePolicyRule 描述当满足要求时如何处理一个 Pod 失效。 在每个规则中可以使用 onExitCodes 和 onPodConditions 之一,但不能同时使用二者。

      • podFailurePolicy.rules.action (string),必需

        指定当要求满足时对 Pod 失效采取的操作。可能的值是:

        • FailJob:表示 Pod 的任务被标记为 Failed 且所有正在运行的 Pod 都被终止。
        • FailIndex:表示 Pod 对应的索引被标记为 Failed 且 Pod 不会被重新启动。 此值是 Alpha 级别的。当 JobBackoffLimitPerIndex 特性门控被启用时(默认被禁用),可以使用此值。
        • Ignore:表示 .backoffLimit 的计数器没有递增,并创建了一个替代 Pod。

        • Count:表示以默认方式处理该 Pod,计数器朝着 .backoffLimit 的方向递增。

        后续会考虑增加其他值。客户端应通过跳过此规则对未知的操作做出反应。

      • podFailurePolicy.rules.onPodConditions ([]PodFailurePolicyOnPodConditionsPattern),必需

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

        表示对 Pod 状况的要求。该要求表示为 Pod 状况模式的一个列表。 如果至少一个模式与实际的 Pod 状况匹配,则满足此要求。最多允许 20 个。

        PodFailurePolicyOnPodConditionsPattern 描述与实际 Pod 状况类型匹配的模式。

        • podFailurePolicy.rules.onPodConditions.status (string),必需

          指定必需的 Pod 状况状态。要匹配一个 Pod 状况,指定的状态必须等于该 Pod 状况状态。默认为 True。

        • podFailurePolicy.rules.onPodConditions.type (string),必需

          指定必需的 Pod 状况类型。要匹配一个 Pod 状况,指定的类型必须等于该 Pod 状况类型。

      • podFailurePolicy.rules.onExitCodes (PodFailurePolicyOnExitCodesRequirement)

        表示容器退出码有关的要求。

        PodFailurePolicyOnExitCodesRequirement 描述根据容器退出码处理失效 Pod 的要求。 特别是,它为每个应用容器和 Init 容器状态查找在 Pod 状态中分别用 .status.containerStatuses 和 .status.initContainerStatuses 字段表示的 .state.terminated.exitCode。 成功完成的容器(退出码 0)被排除在此要求检查之外。

        • podFailurePolicy.rules.onExitCodes.operator (string),必需

          表示容器退出码和指定值之间的关系。成功完成的容器(退出码 0)被排除在此要求检查之外。可能的值为:

          • In:如果至少一个容器退出码(如果有多个容器不受 'containerName' 字段限制,则可能是多个退出码) 在一组指定值中,则满足要求。

          • NotIn:如果至少一个容器退出码(如果有多个容器不受 'containerName' 字段限制,则可能是多个退出码) 不在一组指定值中,则满足要求。

          后续会考虑增加其他值。客户端应通过假设不满足要求来对未知操作符做出反应。

        • podFailurePolicy.rules.onExitCodes.values ([]int32),必需

          集合:合并期间保留唯一值

          指定值集。每个返回的容器退出码(在多个容器的情况下可能是多个)将根据该操作符有关的这个值集进行检查。 值的列表必须有序且不得包含重复项。值 '0' 不能用于 In 操作符。至少需要 1 个。最多允许 255 个。

        • podFailurePolicy.rules.onExitCodes.containerName (string)

          将退出码的检查限制为具有指定名称的容器。当为 null 时,该规则适用于所有容器。 当被指定时,它应与 Pod 模板中的容器名称或 initContainer 名称之一匹配。

Alpha 级别

  • backoffLimitPerIndex(int32)

    指定在将特定索引的 Pod 标记为失败之前在对该 Pod 重试次数的限制。 启用后,各索引的失败次数将保存在 Pod 的 batch.kubernetes.io/job-index-failure-count 注解中。 仅当 Job 的 completionMode=Indexed 且 Pod 的重启策略为 Never 时才能设置此字段。 此字段是不可变更的。此字段是 Alpha 级别的。 当 JobBackoffLimitPerIndex 特性门控被启用时(默认被禁用),可以使用此字段。

  • maxFailedIndexes(int32)

    指定在 backoffLimitPerIndex 被设置时、标记 Job 为失败之前所允许的最大失败索引数。 一旦失败的索引数超过此数值,整个 Job 将被标记为 Failed 并终止执行。 如果不设置此字段(对应为 null),则作业继续执行其所有索引,且 Job 会被标记 Complete 状况。 此字段只能在设置 backoffLimitPerIndex 时指定。此字段值可以是 null 或完成次数之内的值。 当完成次数大于 10^5 时,此字段是必需的且必须小于等于 10^4。 此字段是 Alpha 级别的。当 JobBackoffLimitPerIndex 特性门控被启用时(默认禁用),可以使用此字段。

  • podReplacementPolicy(string)

    podReplacementPolicy 指定何时创建替代的 Pod。可能的值包括:

    • TerminatingOrFailed:表示当 Pod 处于终止中(具有 metadata.deletionTimestamp)或失败时,重新创建 Pod。
    • Failed:表示在创建替代的 Pod 之前,等待先前创建的 Pod 完全终止(处于 Failed 或 Succeeded 阶段)。

    当使用 podFailurePolicy 时,Failed 是唯一允许值。 当不使用 podFailurePolicy 时,允许使用 TerminatingOrFailed 和 Failed。 这是一个 Alpha 级别的字段。启用 JobPodReplacementPolicy 特性门控才能使用此字段。

JobStatus

JobStatus 表示 Job 的当前状态。


  • startTime (Time)

    表示任务控制器开始处理任务的时间。在挂起状态下创建 Job 时,直到第一次恢复时才会设置此字段。 每次从暂停中恢复任务时都会重置此字段。它表示为 RFC3339 格式的 UTC 时间。

    Time 是 time.Time 的包装器,支持正确编码为 YAML 和 JSON。time 包提供的许多工厂方法都提供了包装器。

  • completionTime (Time)

    表示任务完成的时间。不能保证对多个独立操作按发生的先后顺序设置。此字段表示为 RFC3339 格式的 UTC 时间。 仅当任务成功完成时才设置完成时间。

    Time 是 time.Time 的包装器,支持正确编码为 YAML 和 JSON。time 包提供的许多工厂方法都提供了包装器。

  • active (int32)

    待处理和正在运行的 Pod 的数量。

  • failed (int32)

    进入 Failed 阶段的 Pod 数量。

  • succeeded (int32)

    进入 Succeeded 阶段的 Pod 数量。

  • completedIndexes (string)

    completedIndexes 以文本格式保存 .spec.completionMode 设置为 "Indexed" 的 Pod 已完成的索引。 索引用十进制整数表示,用逗号分隔。数字是按递增的顺序排列的。三个或更多的连续数字被压缩, 用系列的第一个和最后一个元素表示,用连字符分开。例如,如果完成的索引是 1、3、4、5 和 7,则表示为 "1、3-5、7"。

  • conditions ([]JobCondition)

    补丁策略:根据 type 键合并

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

    对象当前状态的最新可用观察结果。当任务失败时,其中一个状况的类型为 “Failed”,状态为 true。 当任务被暂停时,其中一个状况的类型为 “Suspended”,状态为true;当任务被恢复时,该状况的状态将变为 false。 任务完成时,其中一个状况的类型为 "Complete",状态为 true。更多信息: https://kubernetes.io/zh-cn/docs/concepts/workloads/controllers/jobs-run-to-completion/

    JobCondition 描述任务的当前状况。

    • conditions.status (string), 必需

      状况的状态:True、False、Unknown 之一。

    • conditions.type (string), 必需

      任务状况的类型:Completed 或 Failed。

    • conditions.lastProbeTime (Time)

      最后一次探测的时间。

      Time 是对 time.Time 的封装,支持正确编码为 YAML 和 JSON。我们为 time 包提供的许多工厂方法提供了封装器。

    • conditions.lastTransitionTime (Time)

      上一次从一种状况转换到另一种状况的时间。

      Time 是 time.Time 的包装器,支持正确编码为 YAML 和 JSON。time 包提供的许多工厂方法都提供了包装器。

    • conditions.message (string)

      表示上次转换信息的人类可读消息。

    • conditions.reason (string)

      状况最后一次转换的(简要)原因

  • uncountedTerminatedPods (UncountedTerminatedPods)

    UncountedTerminatedPods 保存已终止但尚未被任务控制器纳入状态计数器中的 Pod 的 UID 的集合。

    任务控制器所创建 Pod 带有终结器。当 Pod 终止(成功或失败)时,控制器将执行三个步骤以在任务状态中对其进行说明:

    1. 将 Pod UID 添加到此字段的列表中。
    2. 去掉 Pod 中的终结器。
    3. 从数组中删除 Pod UID,同时为相应的计数器加一。

    使用此字段可能无法跟踪旧任务,在这种情况下,该字段保持为空。

    UncountedTerminatedPods 持有已经终止的 Pod 的 UID,但还没有被计入工作状态计数器中。

    • uncountedTerminatedPods.failed ([]string)

      集合:合并期间保留唯一值

      failed 字段包含已失败 Pod 的 UID。

    • uncountedTerminatedPods.succeeded ([]string)

      集合:合并期间保留唯一值

      succeeded 包含已成功的 Pod 的 UID。

Beta 级别

  • ready (int32)

    状况为 Ready 的 Pod 数量。

    此字段为 Beta 级别。当特性门控 JobReadyPods 启用(默认启用)时,任务控制器会填充该字段。

Alpha 级别

  • failedIndexes (string)

    当 backoffLimitPerIndex=true 时,failedIndexes 保存失败的索引。 索引以文本格式表示,类似于 completedIndexes 字段,即这些索引是使用逗号分隔的十进制整数。 这些数字按升序列出。三个或更多连续的数字会被压缩,整个序列表示为第一个数字、连字符和最后一个数字。 例如,如果失败的索引是 1、3、4、5 和 7,则表示为 "1,3-5,7"。 该字段是 Alpha 级别的。当 JobBackoffLimitPerIndex 特性门控被启用时(默认被禁用),可以使用此字段。

  • terminating(int32)

    正在终止的 Pod 数量(处于 Pending 或 Running 阶段且具有 deletionTimestamp)。

    此字段是 Alpha 级别的。当特性门控 JobPodReplacementPolicy 被启用时(默认被禁用), Job 控制器会填充该字段。

JobList

JobList 是 Job 的集合。


  • apiVersion: batch/v1

  • kind: JobList

操作


get 读取指定的 Job

HTTP 请求

GET /apis/batch/v1/namespaces/{namespace}/jobs/{name}

参数

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

    Job 的名称。

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (Job): OK

401: Unauthorized

get 读取指定任务的状态

HTTP 请求

GET /apis/batch/v1/namespaces/{namespace}/jobs/{name}/status

参数

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

    Job 的名称。

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (Job): OK

401: Unauthorized

list 列举或监测 Job 类别的对象

HTTP 请求

GET /apis/batch/v1/namespaces/{namespace}/jobs

参数

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

    namespace

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

响应

200 (JobList): OK

401: Unauthorized

list 列举或监测 Job 类别的对象

HTTP 请求

GET /apis/batch/v1/jobs

参数

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

响应

200 (JobList): OK

401: Unauthorized

create 创建一个 Job

HTTP 请求

POST /apis/batch/v1/namespaces/{namespace}/jobs

参数

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

    namespace

  • body: Job, 必需

响应

200 (Job): OK

201 (Job): Created

202 (Job): Accepted

401: Unauthorized

update 替换指定的 Job

HTTP 请求

PUT /apis/batch/v1/namespaces/{namespace}/jobs/{name}

参数

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

    Job 的名称。

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

    namespace

  • body: Job, 必需

响应

200 (Job): OK

201 (Job): Created

401: Unauthorized

update 替换指定 Job 的状态

HTTP 请求

PUT /apis/batch/v1/namespaces/{namespace}/jobs/{name}/status

参数

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

    Job 的名称。

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

    namespace

  • body: Job, 必需

响应

200 (Job): OK

201 (Job): Created

401: Unauthorized

patch 部分更新指定的 Job

HTTP 请求

PATCH /apis/batch/v1/namespaces/{namespace}/jobs/{name}

参数

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

    Job 的名称。

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

    namespace

  • body: Patch, 必需

  • pretty (查询参数): string

    pretty

响应

200 (Job): OK

201 (Job): Created

401: Unauthorized

patch 部分更新指定 Job 的状态

HTTP 请求

PATCH /apis/batch/v1/namespaces/{namespace}/jobs/{name}/status

参数

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

    Job 的名称。

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

    namespace

  • body: Patch, 必需

  • pretty (查询参数): string

    pretty

响应

200 (Job): OK

201 (Job): Created

401: Unauthorized

delete 删除一个 Job

HTTP 请求

DELETE /apis/batch/v1/namespaces/{namespace}/jobs/{name}

参数

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

    Job 的名称。

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

    namespace

  • body: DeleteOptions

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 Job 的集合

HTTP 请求

DELETE /apis/batch/v1/namespaces/{namespace}/jobs

参数

  • continue (查询参数): string

    continue

  • dryRun (查询参数): string

    dryRun

响应

200 (Status): OK

401: Unauthorized

1.10 - CronJob

CronJob 代表单个定时作业 (Cron Job) 的配置。

apiVersion: batch/v1

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

CronJob

CronJob 代表单个定时作业(Cron Job) 的配置。


CronJobSpec

CronJobSpec 描述了作业的执行方式和实际将运行的时间。


  • timeZone (string)

    给定时间表的时区名称,请参阅 https://en.wikipedia.org/wiki/List_of_tz_database_time_zones。 如果未指定,这将默认为 kube-controller-manager 进程的时区。 有效时区名称和时区偏移量的设置由 API 服务器在 CronJob 验证期间从系统范围的时区数据库进行加载, 在执行期间由控制器管理器从系统范围的时区数据库进行加载。 如果找不到系统范围的时区数据库,则转而使用该数据库的捆绑版本。 如果时区名称在 CronJob 的生命周期内或由于主机配置更改而变得无效,该控制器将停止创建新的 Job, 并将创建一个原因为 UnknownTimeZone 的系统事件。更多信息,请请参阅 https://kubernetes.io/zh-cn/docs/concepts/workloads/controllers/cron-jobs/#time-zones

  • concurrencyPolicy (string)

    指定如何处理作业的并发执行。 有效值为:

    • "Allow" (默认):允许 CronJobs 并发运行;
    • "Forbid":禁止并发运行,如果上一次运行尚未完成则跳过下一次运行;
    • "Replace":取消当前正在运行的作业并将其替换为新作业。
  • startingDeadlineSeconds (int64)

    可选字段。当作业因为某种原因错过预定时间时,设定作业的启动截止时间(秒)。错过排期的作业将被视为失败的作业。

  • suspend (boolean)

    这个标志告诉控制器暂停后续的执行,它不适用于已经开始的执行。默认为 false。

  • successfulJobsHistoryLimit (int32)

    要保留的成功完成作业数。值必须是非负整数。默认值为 3。

  • failedJobsHistoryLimit (int32)

    要保留的以失败状态结束的作业个数。值必须是非负整数。默认值为 1。

CronJobStatus

CronJobStatus 表示某个定时作业的当前状态。


  • active ([]ObjectReference)

    Atomic: 将在合并过程中被替换

    指向当前正在运行的作业的指针列表。

  • lastScheduleTime (Time)

    上次成功调度作业的时间信息。

    Time 是对 time.Time 的封装,它支持对 YAML 和 JSON 的正确编排。为 time 包提供的许多工厂方法模式提供了包装器。

  • lastSuccessfulTime (Time)

    上次成功完成作业的时间信息。

    Time 是对 time.Time 的封装,它支持对 YAML 和 JSON 的正确编排。为 time 包提供的许多工厂方法模式提供了包装器。

CronJobList

CronJobList 是定时作业的集合。


  • apiVersion: batch/v1

  • kind: CronJobList

  • items ([]CronJob), required

    items 是 CronJob 的列表。

操作


get 查看指定的 CronJob

HTTP 请求

GET /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}

参数

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

    CronJob 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (CronJob): OK

401: Unauthorized

get 查看指定 CronJob 的状态

HTTP 请求

GET /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}/status

参数

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

    CronJob 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (CronJob): OK

401: Unauthorized

list 查看或监视 CronJob 类别的对象

HTTP 请求

GET /apis/batch/v1/namespaces/{namespace}/cronjobs

参数

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

    namespace

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

  • watch (查询参数): boolean

    watch

响应

200 (CronJobList): OK

401: Unauthorized

list 查看或监视 CronJob 类型的对象

HTTP 请求

GET /apis/batch/v1/cronjobs

参数

  • limit (in query): integer

    limit

  • pretty (in query): string

    pretty

  • watch (in query): boolean

    watch

响应

200 (CronJobList): OK

401: Unauthorized

create 创建一个 CronJob

HTTP 请求

POST /apis/batch/v1/namespaces/{namespace}/cronjobs

参数

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

    namespace

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (CronJob): OK

201 (CronJob): Created

202 (CronJob): Accepted

401: Unauthorized

update 替换指定的 CronJob

HTTP 请求

PUT /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}

参数

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

    CronJob 的名称

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

    namespace

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (CronJob): OK

201 (CronJob): Created

401: Unauthorized

update 替换指定 CronJob 的状态

HTTP 请求

PUT /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}/status

参数

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

    CronJob 的名称

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

    namespace

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (CronJob): OK

201 (CronJob): Created

401: Unauthorized

patch 部分更新指定的 CronJob

HTTP 请求

PATCH /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}

参数

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

    CronJob 的名称

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

    namespace

  • dryRun (查询参数): string

    dryRun

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (CronJob): OK

201 (CronJob): Created

401: Unauthorized

patch 部分更新指定 CronJob 的状态

HTTP 请求

PATCH /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}/status

参数

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

    CronJob 的名称

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

    namespace

  • dryRun (参数参数): string

    dryRun

  • force (参数参数): boolean

    force

  • pretty (参数参数): string

    pretty

响应

200 (CronJob): OK

201 (CronJob): Created

401: Unauthorized

delete 删除一个 CronJob

HTTP 请求

DELETE /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}

参数

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

    CronJob 的名称

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

    namespace

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除一组 CronJob

HTTP 请求

DELETE /apis/batch/v1/namespaces/{namespace}/cronjobs

参数

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

    namespace

  • dryRun (查询参数): string

    dryRun

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

响应

200 (Status): OK

401: Unauthorized

1.11 - HorizontalPodAutoscaler

水平 Pod 自动缩放器的配置。

apiVersion: autoscaling/v1

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

HorizontalPodAutoscaler

水平 Pod 自动缩放器的配置。


  • apiVersion: autoscaling/v1

  • kind: HorizontalPodAutoscaler

HorizontalPodAutoscalerSpec

水平 Pod 自动缩放器的规约。


  • maxReplicas (int32),必填

    maxReplicas 是自动扩缩器可以设置的 Pod 数量上限; 不能小于 minReplicas。

  • minReplicas (int32)

    minReplicas 是自动缩放器可以缩减的副本数的下限。 它默认为 1 个 Pod。 如果启用了 alpha 特性门禁 HPAScaleToZero 并且配置了至少一个 Object 或 External 度量标准, 则 minReplicas 允许为 0。 只要至少有一个度量值可用,缩放就处于活动状态。

  • targetCPUUtilizationPercentage (int32)

    targetCPUUtilizationPercentage 是所有 Pod 的目标平均 CPU 利用率(以请求 CPU 的百分比表示); 如果未指定,将使用默认的自动缩放策略。

HorizontalPodAutoscalerStatus

水平 Pod 自动缩放器的当前状态


  • currentReplicas (int32),必填

    currentReplicas 是此自动缩放器管理的 Pod 的当前副本数。

  • desiredReplicas (int32),必填

    desiredReplicas 是此自动缩放器管理的 Pod 副本的所需数量。

  • currentCPUUtilizationPercentage (int32)

    currentCPUUtilizationPercentage 是当前所有 Pod 的平均 CPU 利用率, 以请求 CPU 的百分比表示, 例如:70 表示平均 Pod 现在正在使用其请求 CPU 的 70%。

  • lastScaleTime (Time)

    lastScaleTime 是上次 HorizontalPodAutoscaler 缩放 Pod 的数量; 自动缩放器用它来控制 Pod 数量的更改频率。

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

  • observedGeneration (int64)

    observedGeneration 是此自动缩放器观察到的最新一代。

HorizontalPodAutoscalerList

水平 Pod 自动缩放器对象列表。


  • apiVersion: autoscaling/v1

  • kind: HorizontalPodAutoscalerList

  • metadata (ListMeta)

    标准的列表元数据。

操作


get 读取特定的 HorizontalPodAutoscaler

HTTP 请求

GET /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers/{name}

参数

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

    HorizontalPodAutoscaler 的名称。

  • namespace路径参数): string,必填

    namespace

  • pretty查询参数): string

    pretty

响应

200 (HorizontalPodAutoscaler): OK

401: Unauthorized

get 读取特定 HorizontalPodAutoscaler 的状态

HTTP 请求

GET /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers/{name}/status

参数

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

    HorizontalPodAutoscaler 的名称。

  • namespace路径参数): string,必填

    namespace

  • pretty查询参数): string

    pretty

响应

200 (HorizontalPodAutoscaler): OK

401: Unauthorized

list 列出或监视 HorizontalPodAutoscaler 类别的对象

HTTP 参数

GET /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers

参数

  • namespace路径参数): string,必填

    namespace

  • continue查询参数): string

    continue

  • limit查询参数): integer

    limit

  • pretty查询参数): string

    pretty

  • watch查询参数): boolean

    watch

响应

200 (HorizontalPodAutoscalerList): OK

401: Unauthorized

list 列出或监视 HorizontalPodAutoscaler 类别的对象

HTTP 请求

GET /apis/autoscaling/v1/horizontalpodautoscalers

参数

  • continue (查询参数*): string

    continue

  • limit查询参数): integer

    limit

  • pretty查询参数): string

    pretty

  • watch查询参数): boolean

    watch

响应

200 (HorizontalPodAutoscalerList): OK

401: Unauthorized

create 创建一个 HorizontalPodAutoscaler

HTTP 请求

POST /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers

参数

  • namespace路径参数): string,必填

    namespace

  • dryRun查询参数): string

    dryRun

  • pretty查询参数): string

    pretty

响应

200 (HorizontalPodAutoscaler): OK

201 (HorizontalPodAutoscaler): Created

202 (HorizontalPodAutoscaler): Accepted

401: Unauthorized

update 替换特定的 HorizontalPodAutoscaler

HTTP 请求

PUT /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers/{name}

参数

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

    HorizontalPodAutoscaler 的名称

  • namespace路径参数): string,必填

    namespace

  • dryRun查询参数): string

    dryRun

  • pretty查询参数): string

    pretty

响应

200 (HorizontalPodAutoscaler): OK

201 (HorizontalPodAutoscaler): Created

401: Unauthorized

update 替换特定 HorizontalPodAutoscaler 的状态

HTTP 请求

PUT /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers/{name}/status

参数

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

    HorizontalPodAutoscaler 的名称

  • namespace路径参数): string,必填

    namespace

  • dryRun查询参数): string

    dryRun

  • pretty查询参数): string

    pretty

响应

200 (HorizontalPodAutoscaler): OK

201 (HorizontalPodAutoscaler): Created

401: Unauthorized

patch 部分更新特定的 HorizontalPodAutoscaler

HTTP 请求

PATCH /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers/{name}

参数

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

    HorizontalPodAutoscaler 的名称

  • namespace路径参数): string,必填

    namespace

  • dryRun查询参数): string

    dryRun

  • force查询参数): boolean

    force

  • pretty查询参数): string

    pretty

响应

200 (HorizontalPodAutoscaler): OK

201 (HorizontalPodAutoscaler): Created

401: Unauthorized

patch 部分更新特定 HorizontalPodAutoscaler 的状态

HTTP 请求

PATCH /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers/{name}/status

参数

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

    HorizontalPodAutoscaler 的名称

  • namespace路径参数): string,必填

    namespace

  • dryRun查询参数): string

    dryRun

  • force查询参数): boolean

    force

  • pretty查询参数): string

    pretty

响应

200 (HorizontalPodAutoscaler): OK

201 (HorizontalPodAutoscaler): Created

401: Unauthorized

delete 删除一个 HorizontalPodAutoscaler

HTTP 请求

DELETE /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers/{name}

参数

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

    HorizontalPodAutoscaler 的名称

  • namespace路径参数): string,必填

    namespace

  • dryRun查询参数): string

    dryRun

  • pretty查询参数): string

    pretty

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 HorizontalPodAutoscaler 的集合

HTTP 请求

DELETE /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers

参数

  • namespace路径参数): string,必填

    namespace

  • continue查询参数): string

    continue

  • dryRun查询参数): string

    dryRun

  • limit查询参数): integer

    limit

  • pretty查询参数): string

    pretty

响应

200 (Status): OK

401: Unauthorized

1.12 - HorizontalPodAutoscaler

HorizontalPodAutoscaler 是水平 Pod 自动扩缩器的配置,它根据指定的指标自动管理实现 scale 子资源的任何资源的副本数。

apiVersion: autoscaling/v2

import "k8s.io/api/autoscaling/v2"

HorizontalPodAutoscaler

HorizontalPodAutoscaler 是水平 Pod 自动扩缩器的配置, 它根据指定的指标自动管理实现 scale 子资源的任何资源的副本数。


HorizontalPodAutoscalerSpec

HorizontalPodAutoscalerSpec 描述了 HorizontalPodAutoscaler 预期的功能。


  • maxReplicas (int32),必需

    maxReplicas 是自动扩缩器可以扩容的副本数的上限。不能小于 minReplicas。

  • scaleTargetRef (CrossVersionObjectReference),必需

    scaleTargetRef 指向要扩缩的目标资源,用于收集 Pod 的相关指标信息以及实际更改的副本数。

    CrossVersionObjectReference 包含足够的信息来让你识别出所引用的资源。

    • scaleTargetRef.name (string),必需

      name 是被引用对象的名称;更多信息:https://kubernetes.io/zh-cn/docs/concepts/overview/working-with-objects/names/#names

    • scaleTargetRef.apiVersion (string)

      apiVersion 是被引用对象的 API 版本。

  • minReplicas (int32)

    minReplicas 是自动扩缩器可以缩减的副本数的下限。它默认为 1 个 Pod。 如果启用了 Alpha 特性门控 HPAScaleToZero 并且配置了至少一个 Object 或 External 度量指标, 则 minReplicas 允许为 0。只要至少有一个度量值可用,扩缩就处于活动状态。

  • behavior (HorizontalPodAutoscalerBehavior)

    behavior 配置目标在扩容(Up)和缩容(Down)两个方向的扩缩行为(分别用 scaleUp 和 scaleDown 字段)。 如果未设置,则会使用默认的 HPAScalingRules 进行扩缩容。

    HorizontalPodAutoscalerBehavior 配置目标在扩容(Up)和缩容(Down)两个方向的扩缩行为 (分别用 scaleUp 和 scaleDown 字段)。

    • behavior.scaleDown (HPAScalingRules)

      scaleDown 是缩容策略。如果未设置,则默认值允许缩减到 minReplicas 数量的 Pod, 具有 300 秒的稳定窗口(使用最近 300 秒的最高推荐值)。

      HPAScalingRules 为一个方向配置扩缩行为。在根据 HPA 的指标计算 desiredReplicas 后应用这些规则。 可以通过指定扩缩策略来限制扩缩速度。可以通过指定稳定窗口来防止抖动, 因此不会立即设置副本数,而是选择稳定窗口中最安全的值。

      • behavior.scaleDown.policies ([]HPAScalingPolicy)

        原子性:将在合并时被替换

        policies 是可在扩缩容过程中使用的潜在扩缩策略的列表。必须至少指定一个策略,否则 HPAScalingRules 将被视为无效而丢弃。

        HPAScalingPolicy 是一个单一的策略,它必须在指定的过去时间间隔内保持为 true。

        • behavior.scaleDown.policies.type (string),必需

          type 用于指定扩缩策略。

        • behavior.scaleDown.policies.value (int32),必需

          value 包含策略允许的更改量。它必须大于零。

        • behavior.scaleDown.policies.periodSeconds (int32),必需

          periodSeconds 表示策略应该保持为 true 的时间窗口长度。 periodSeconds 必须大于零且小于或等于 1800(30 分钟)。

      • behavior.scaleDown.selectPolicy (string)

        selectPolicy 用于指定应该使用哪个策略。如果未设置,则使用默认值 Max。

      • behavior.scaleDown.stabilizationWindowSeconds (int32)

        stabilizationWindowSeconds 是在扩缩容时应考虑的之前建议的秒数。stabilizationWindowSeconds 必须大于或等于零且小于或等于 3600(一小时)。如果未设置,则使用默认值:

        • 扩容:0(不设置稳定窗口)。
        • 缩容:300(即稳定窗口为 300 秒)。
    • behavior.scaleUp (HPAScalingRules)

      scaleUp 是用于扩容的扩缩策略。如果未设置,则默认值为以下值中的较高者:

      • 每 60 秒增加不超过 4 个 Pod
      • 每 60 秒 Pod 数量翻倍

      不使用稳定窗口。

      HPAScalingRules 为一个方向配置扩缩行为。在根据 HPA 的指标计算 desiredReplicas 后应用这些规则。 可以通过指定扩缩策略来限制扩缩速度。可以通过指定稳定窗口来防止抖动, 因此不会立即设置副本数,而是选择稳定窗口中最安全的值。

      • behavior.scaleUp.policies ([]HPAScalingPolicy)

        原子性:将在合并时被替换

        policies 是可在扩缩容过程中使用的潜在扩缩策略的列表。必须至少指定一个策略,否则 HPAScalingRules 将被视为无效而丢弃。

        HPAScalingPolicy 是一个单一的策略,它必须在指定的过去时间间隔内保持为 true。

        • behavior.scaleUp.policies.type (string),必需

          type 用于指定扩缩策略。

          - **behavior.scaleUp.policies.value** (int32),必需
        

        value 包含策略允许的更改量。它必须大于零。

        • behavior.scaleUp.policies.periodSeconds (int32),必需

          periodSeconds 表示策略应该保持为 true 的时间窗口长度。 periodSeconds 必须大于零且小于或等于 1800(30 分钟)。

      • behavior.scaleUp.selectPolicy (string)

        selectPolicy 用于指定应该使用哪个策略。如果未设置,则使用默认值 Max。

      • behavior.scaleUp.stabilizationWindowSeconds (int32)

        stabilizationWindowSeconds 是在扩缩容时应考虑的之前建议的秒数。stabilizationWindowSeconds 必须大于或等于零且小于或等于 3600(一小时)。如果未设置,则使用默认值:

        • 扩容:0(不设置稳定窗口)。
        • 缩容:300(即稳定窗口为 300 秒)。
  • metrics ([]MetricSpec)

    原子性:将在合并时被替换

    metrics 包含用于计算预期副本数的规约(将使用所有指标的最大副本数)。 预期副本数是通过将目标值与当前值之间的比率乘以当前 Pod 数来计算的。 因此,使用的指标必须随着 Pod 数量的增加而减少,反之亦然。 有关每种类别的指标必须如何响应的更多信息,请参阅各个指标源类别。 如果未设置,默认指标将设置为 80% 的平均 CPU 利用率。

    MetricSpec 指定如何基于单个指标进行扩缩容(一次只能设置 type 和一个其他匹配字段)

    • metrics.type (string),必需

      type 是指标源的类别。它取值是 “ContainerResource”、“External”、“Object”、“Pods” 或 “Resource” 之一, 每个类别映射到对象中的一个对应的字段。注意:“ContainerResource” 类别在特性门控 HPAContainerMetrics 启用时可用。

    • metrics.containerResource (ContainerResourceMetricSource)

      containerResource 是指 Kubernetes 已知的资源指标(例如在请求和限制中指定的那些), 描述当前扩缩目标中每个 Pod 中的单个容器(例如 CPU 或内存)。 此类指标内置于 Kubernetes 中,在使用 “pods” 源的、按 Pod 计算的普通指标之外,还具有一些特殊的扩缩选项。 这是一个 Alpha 特性,可以通过 HPAContainerMetrics 特性标志启用。

      ContainerResourceMetricSource 指示如何根据请求和限制中指定的 Kubernetes 已知的资源指标进行扩缩容, 此结构描述当前扩缩目标中的每个 Pod(例如 CPU 或内存)。在与目标值比较之前,这些值先计算平均值。 此类指标内置于 Kubernetes 中,并且在使用 “Pods” 源的、按 Pod 统计的普通指标之外支持一些特殊的扩缩选项。 只应设置一种 “target” 类别。

      • metrics.containerResource.container (string),必需

        container 是扩缩目标的 Pod 中容器的名称。

      - **metrics.containerResource.name** (string),必需
      

      name 是相关资源的名称。

      • metrics.containerResource.target (MetricTarget),必需

        target 指定给定指标的目标值。

        MetricTarget 定义特定指标的目标值、平均值或平均利用率

        • metrics.containerResource.target.type (string),必需

          type 表示指标类别是 UtilizationValueAverageValue

        • metrics.containerResource.target.averageUtilization (int32)

          averageUtilization 是跨所有相关 Pod 的资源指标均值的目标值, 表示为 Pod 资源请求值的百分比。目前仅对 “Resource” 指标源类别有效。

        • metrics.containerResource.target.averageValue (Quantity)

          是跨所有相关 Pod 的指标均值的目标值(以数量形式给出)。

        • metrics.containerResource.target.value (Quantity)

          value 是指标的目标值(以数量形式给出)。

    • metrics.external (ExternalMetricSource)

      external 指的是不与任何 Kubernetes 对象关联的全局指标。 这一字段允许基于来自集群外部运行的组件(例如云消息服务中的队列长度,或来自运行在集群外部的负载均衡器的 QPS)的信息进行自动扩缩容。

      ExternalMetricSource 指示如何基于 Kubernetes 对象无关的指标 (例如云消息传递服务中的队列长度,或来自集群外部运行的负载均衡器的 QPS)执行扩缩操作。

      • metrics.external.metric (MetricIdentifier),必需

        metric 通过名称和选择算符识别目标指标。

        MetricIdentifier 定义指标的名称和可选的选择算符

        • metrics.external.metric.name (string),必需

          name 是给定指标的名称。

        • metrics.external.metric.selector (LabelSelector)

          selector 是给定指标的标准 Kubernetes 标签选择算符的字符串编码形式。 设置后,它作为附加参数传递给指标服务器,以获取更具体的指标范围。 未设置时,仅 metricName 参数将用于收集指标。

      • metrics.external.target (MetricTarget),必需

        target 指定给定指标的目标值。

        MetricTarget 定义特定指标的目标值、平均值或平均利用率

        • metrics.external.target.type (string),必需

          type 表示指标类别是 UtilizationValueAverageValue

        • metrics.external.target.averageUtilization (int32)

          averageUtilization 是跨所有相关 Pod 得到的资源指标均值的目标值, 表示为 Pod 资源请求值的百分比。目前仅对 “Resource” 指标源类别有效。

        • metrics.external.target.averageValue (Quantity)

          averageValue 是跨所有相关 Pod 得到的指标均值的目标值(以数量形式给出)。

        • metrics.external.target.value (Quantity)

          value 是指标的目标值(以数量形式给出)。

    • metrics.object (ObjectMetricSource)

      object 是指描述单个 Kubernetes 对象的指标(例如,Ingress 对象上的 hits-per-second)。

      ObjectMetricSource 表示如何根据描述 Kubernetes 对象的指标进行扩缩容(例如,Ingress 对象的 hits-per-second

      • metrics.object.metric (MetricIdentifier),必需

        metric 通过名称和选择算符识别目标指标。

        MetricIdentifier 定义指标的名称和可选的选择算符

        • metrics.object.metric.name (string),必需

          name 是给定指标的名称。

        • metrics.object.metric.selector (LabelSelector)

          selector 是给定指标的标准 Kubernetes 标签选择算符的字符串编码形式。 设置后,它作为附加参数传递给指标服务器,以获取更具体的指标范围。 未设置时,仅 metricName 参数将用于收集指标。

      • metrics.object.target (MetricTarget),必需

        target 表示给定指标的目标值。

        MetricTarget 定义特定指标的目标值、平均值或平均利用率

        • metrics.object.target.type (string),必需

          type 表示指标类别是 UtilizationValueAverageValue

        • metrics.object.target.averageUtilization (int32)

          averageUtilization 是跨所有相关 Pod 得出的资源指标均值的目标值, 表示为 Pod 资源请求值的百分比。目前仅对 “Resource” 指标源类别有效。

        • metrics.object.target.averageValue (Quantity)

          averageValue 是跨所有 Pod 得出的指标均值的目标值(以数量形式给出)。

        • metrics.object.target.value (Quantity)

          value 是指标的目标值(以数量形式给出)。

    • metrics.pods (PodsMetricSource)

      pods 是指描述当前扩缩目标中每个 Pod 的指标(例如,transactions-processed-per-second)。 在与目标值进行比较之前,这些指标值将被平均。

      PodsMetricSource 表示如何根据描述当前扩缩目标中每个 Pod 的指标进行扩缩容(例如,transactions-processed-per-second)。 在与目标值进行比较之前,这些指标值将被平均。

      • metrics.pods.metric (MetricIdentifier),必需

        metric 通过名称和选择算符识别目标指标。

        MetricIdentifier 定义指标的名称和可选的选择算符

        • metrics.pods.metric.name (string),必需

          name 是给定指标的名称。

        • metrics.pods.metric.selector (LabelSelector)

          selector 是给定指标的标准 Kubernetes 标签选择算符的字符串编码形式。 设置后,它作为附加参数传递给指标服务器,以获取更具体的指标范围。 未设置时,仅 metricName 参数将用于收集指标。

      • metrics.pods.target (MetricTarget),必需

        target 表示给定指标的目标值。

        MetricTarget 定义特定指标的目标值、平均值或平均利用率

        • metrics.pods.target.type (string),必需

          type 表示指标类别是 UtilizationValueAverageValue

        • metrics.pods.target.averageUtilization (int32)

          averageUtilization 是跨所有相关 Pod 得出的资源指标均值的目标值, 表示为 Pod 资源请求值的百分比。目前仅对 “Resource” 指标源类别有效。

        • metrics.pods.target.averageValue (Quantity)

          averageValue 是跨所有 Pod 得出的指标均值的目标值(以数量形式给出)。

        • metrics.pods.target.value (Quantity)

          value 是指标的目标值(以数量形式给出)。

    • metrics.resource (ResourceMetricSource)

      resource 是指 Kubernetes 已知的资源指标(例如在请求和限制中指定的那些), 此结构描述当前扩缩目标中的每个 Pod(例如 CPU 或内存)。此类指标内置于 Kubernetes 中, 并且在使用 “Pods” 源的、按 Pod 统计的普通指标之外支持一些特殊的扩缩选项。

      ResourceMetricSource 指示如何根据请求和限制中指定的 Kubernetes 已知的资源指标进行扩缩容, 此结构描述当前扩缩目标中的每个 Pod(例如 CPU 或内存)。在与目标值比较之前,这些指标值将被平均。 此类指标内置于 Kubernetes 中,并且在使用 “Pods” 源的、按 Pod 统计的普通指标之外支持一些特殊的扩缩选项。 只应设置一种 “target” 类别。

      • metrics.resource.name (string),必需

        name 是相关资源的名称。

      • metrics.resource.target (MetricTarget),必需

        target 指定给定指标的目标值。

        MetricTarget 定义特定指标的目标值、平均值或平均利用率

        • metrics.resource.target.type (string),必需

          type 表示指标类别是 UtilizationValueAverageValue

        • metrics.resource.target.averageUtilization (int32)

          averageUtilization 是跨所有相关 Pod 得出的资源指标均值的目标值, 表示为 Pod 资源请求值的百分比。目前仅对 “Resource” 指标源类别有效。

        • metrics.resource.target.averageValue (Quantity)

          averageValue 是跨所有 Pod 得出的指标均值的目标值(以数量形式给出)。

        • metrics.resource.target.value (Quantity)

          value 是指标的目标值(以数量形式给出)。

HorizontalPodAutoscalerStatus

HorizontalPodAutoscalerStatus 描述了水平 Pod 自动扩缩器的当前状态。


  • desiredReplicas (int32),必需

    desiredReplicas 是此自动扩缩器管理的 Pod 的所期望的副本数,由自动扩缩器最后计算。

  • conditions ([]HorizontalPodAutoscalerCondition)

    补丁策略:基于键 type 合并

    Map:合并时将保留 type 键的唯一值

    conditions 是此自动扩缩器扩缩其目标所需的一组条件,并指示是否满足这些条件。

    HorizontalPodAutoscalerCondition 描述 HorizontalPodAutoscaler 在某一时间点的状态。

    • conditions.status (string),必需

      status 是状况的状态(True、False、Unknown)。

    • conditions.type (string),必需

      type 描述当前状况。

    • conditions.lastTransitionTime (Time)

      lastTransitionTime 是状况最近一次从一种状态转换到另一种状态的时间。

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

    • conditions.message (string)

      message 是一个包含有关转换的可读的详细信息。

    • conditions.reason (string)

      reason 是状况最后一次转换的原因。

  • currentMetrics ([]MetricStatus)

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

    currentMetrics 是此自动扩缩器使用的指标的最后读取状态。

    MetricStatus 描述了单个指标的最后读取状态。

    • currentMetrics.type (string),必需

      type 是指标源的类别。它取值是 “ContainerResource”、“External”、“Object”、“Pods” 或 “Resource” 之一, 每个类别映射到对象中的一个对应的字段。注意:“ContainerResource” 类别在特性门控 HPAContainerMetrics 启用时可用。

    • currentMetrics.containerResource (ContainerResourceMetricStatus)

      containerResource 是指 Kubernetes 已知的一种资源指标(例如在请求和限制中指定的那些), 描述当前扩缩目标中每个 Pod 中的单个容器(例如 CPU 或内存)。 此类指标内置于 Kubernetes 中,并且在使用 "Pods" 源的、按 Pod 统计的普通指标之外支持一些特殊的扩缩选项。

      ContainerResourceMetricStatus 指示如何根据请求和限制中指定的 Kubernetes 已知的资源指标进行扩缩容, 此结构描述当前扩缩目标中的每个 Pod(例如 CPU 或内存)。此类指标内置于 Kubernetes 中, 并且在使用 “Pods” 源的、按 Pod 统计的普通指标之外支持一些特殊的扩缩选项。

      • currentMetrics.containerResource.container (string),必需

        container 是扩缩目标的 Pod 中的容器名称。

      • currentMetrics.containerResource.current (MetricValueStatus),必需

        current 包含给定指标的当前值。

        MetricValueStatus 保存指标的当前值

        • currentMetrics.containerResource.current.averageUtilization (int32)

          averageUtilization 是跨所有相关 Pod 得出的资源指标均值的当前值,表示为 Pod 资源请求值的百分比。

        • currentMetrics.containerResource.current.averageValue (Quantity)

          averageValue 是跨所有相关 Pod 的指标均值的当前值(以数量形式给出)。

        • currentMetrics.containerResource.current.value (Quantity)

          value 是指标的当前值(以数量形式给出)。

      • currentMetrics.containerResource.name (string),必需

        name 是相关资源的名称。

    • currentMetrics.external (ExternalMetricStatus)

      external 指的是不与任何 Kubernetes 对象关联的全局指标。这一字段允许基于来自集群外部运行的组件 (例如云消息服务中的队列长度,或来自集群外部运行的负载均衡器的 QPS)的信息进行自动扩缩。

      ExternalMetricStatus 表示与任何 Kubernetes 对象无关的全局指标的当前值。

      • currentMetrics.external.current (MetricValueStatus),必需

        current 包含给定指标的当前值。

        MetricValueStatus 保存指标的当前值

        • currentMetrics.external.current.averageUtilization (int32)

          averageUtilization 是跨所有相关 Pod 得出的资源指标均值的当前值,表示为 Pod 资源请求值的百分比。

        • currentMetrics.external.current.averageValue (Quantity)

          averageValue 是跨所有相关 Pod 的指标均值的当前值(以数量形式给出)。

        • currentMetrics.external.current.value (Quantity)

          value 是指标的当前值(以数量形式给出)。

      • currentMetrics.external.metric (MetricIdentifier),必需

        metric 通过名称和选择算符识别目标指标。

        MetricIdentifier 定义指标的名称和可选的选择算符

        • currentMetrics.external.metric.name (string),必需

          name 是给定指标的名称。

        • currentMetrics.external.metric.selector (LabelSelector)

          selector 是给定指标的标准 Kubernetes 标签选择算符的字符串编码形式。 设置后,它作为附加参数传递给指标服务器,以获取更具体的指标范围。 未设置时,仅 metricName 参数将用于收集指标。

    • currentMetrics.object (ObjectMetricStatus)

      object 是指描述单个 Kubernetes 对象的指标(例如,Ingress 对象的 hits-per-second)。

      ObjectMetricStatus 表示描述 Kubernetes 对象的指标的当前值(例如,Ingress 对象的 hits-per-second)。

      • currentMetrics.object.current (MetricValueStatus),必需

        current 包含给定指标的当前值。

        MetricValueStatus 保存指标的当前值

        • currentMetrics.object.current.averageUtilization (int32)

          averageUtilization 是跨所有相关 Pod 得出的资源指标均值的当前值,表示为 Pod 资源请求值的百分比。

        • currentMetrics.object.current.averageValue (Quantity)

          averageValue 是跨所有相关 Pod 的指标均值的当前值(以数量形式给出)。

        • currentMetrics.object.current.value (Quantity)

          value 是指标的当前值(以数量形式给出)。

      • currentMetrics.object.metric (MetricIdentifier),必需

        metric 通过名称和选择算符识别目标指标。

        MetricIdentifier 定义指标的名称和可选的选择算符

        • currentMetrics.object.metric.name (string),必需

          name 是给定指标的名称。

        • currentMetrics.object.metric.selector (LabelSelector)

          selector 是给定指标的标准 Kubernetes 标签选择算符的字符串编码形式。 设置后,它作为附加参数传递给指标服务器,以获取更具体的指标范围。 未设置时,仅 metricName 参数将用于收集指标。

    • currentMetrics.pods (PodsMetricStatus)

      pods 是指描述当前扩缩目标中每个 Pod 的指标(例如,transactions-processed-per-second)。 在与目标值进行比较之前,这些指标值将被平均。

      PodsMetricStatus 表示描述当前扩缩目标中每个 Pod 的指标的当前值(例如,transactions-processed-per-second)。

      • currentMetrics.pods.current (MetricValueStatus),必需

        current 包含给定指标的当前值。

        MetricValueStatus 保存指标的当前值

        • currentMetrics.pods.current.averageUtilization (int32)

          averageUtilization 是跨所有相关 Pod 得出的资源指标均值的当前值,表示为 Pod 资源请求值的百分比。

        • currentMetrics.pods.current.averageValue (Quantity)

          averageValue 是跨所有相关 Pod 的指标均值的当前值(以数量形式给出)。

        • currentMetrics.pods.current.value (Quantity)

          value 是指标的当前值(以数量形式给出)。

      • currentMetrics.pods.metric (MetricIdentifier),必需

        metric 通过名称和选择算符识别目标指标。

        MetricIdentifier 定义指标的名称和可选的选择算符

        • currentMetrics.pods.metric.name (string),必需

          name 是给定指标的名称。

        • currentMetrics.pods.metric.selector (LabelSelector)

          selector 是给定指标的标准 Kubernetes 标签选择算符的字符串编码形式。 设置后,它作为附加参数传递给指标服务器,以获取更具体的指标范围。 未设置时,仅 metricName 参数将用于收集指标。

    • currentMetrics.resource (ResourceMetricStatus)

      resource 是指 Kubernetes 已知的资源指标(例如在请求和限制中指定的那些), 此结构描述当前扩缩目标中的每个 Pod(例如 CPU 或内存)。此类指标内置于 Kubernetes 中, 并且在使用 “Pods” 源的、按 Pod 统计的普通指标之外支持一些特殊的扩缩选项。

      ResourceMetricSource 指示如何根据请求和限制中指定的 Kubernetes 已知的资源指标进行扩缩容, 此结构描述当前扩缩目标中的每个 Pod(例如 CPU 或内存)。在与目标值比较之前,这些指标值将被平均。 此类指标内置于 Kubernetes 中,并且在使用 “Pods” 源的、按 Pod 统计的普通指标之外支持一些特殊的扩缩选项。

      • currentMetrics.resource.current (MetricValueStatus),必需

        current 包含给定指标的当前值。

        MetricValueStatus 保存指标的当前值

        • currentMetrics.resource.current.averageUtilization (int32)

          averageUtilization 是跨所有相关 Pod 得出的资源指标均值的当前值, 表示为 Pod 资源请求值的百分比。

        • currentMetrics.resource.current.averageValue (Quantity)

          averageValue 是跨所有相关 Pod 的指标均值的当前值(以数量形式给出)。

        • currentMetrics.resource.current.value (Quantity)

          value 是指标的当前值(以数量形式给出)。

      • currentMetrics.resource.name (string),必需

        name 是相关资源的名称。

  • currentReplicas (int32)

    currentReplicas 是此自动扩缩器管理的 Pod 的当前副本数,如自动扩缩器最后一次看到的那样。

  • lastScaleTime (Time)

    lastScaleTime 是 HorizontalPodAutoscaler 上次扩缩 Pod 数量的时间,自动扩缩器使用它来控制更改 Pod 数量的频率。

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

  • observedGeneration (int64)

    observedGeneration 是此自动扩缩器观察到的最新一代。

HorizontalPodAutoscalerList

HorizontalPodAutoscalerList 是水平 Pod 自动扩缩器对象列表。


  • apiVersion: autoscaling/v2

  • kind: HorizontalPodAutoscalerList

  • metadata (ListMeta)

    metadata 是标准的列表元数据。

Operations


get 读取指定的 HorizontalPodAutoscaler

HTTP 请求

GET /apis/autoscaling/v2/namespaces/{namespace}/horizontalpodautoscalers/{name}

参数

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

    HorizontalPodAutoscaler 的名称。

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

    namespace

  • pretty查询参数): string

    pretty

响应

200 (HorizontalPodAutoscaler): OK

401: Unauthorized

get 读取指定 HorizontalPodAutoscaler 的状态

HTTP 请求

GET /apis/autoscaling/v2/namespaces/{namespace}/horizontalpodautoscalers/{name}/status

参数

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

    HorizontalPodAutoscaler 的名称。

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

    namespace

  • pretty查询参数): string

    pretty

响应

200 (HorizontalPodAutoscaler): OK

401: Unauthorized

list 列出或观察 HorizontalPodAutoscaler 类别的对象

HTTP 请求

GET /apis/autoscaling/v2/namespaces/{namespace}/horizontalpodautoscalers

参数

响应

200 (HorizontalPodAutoscalerList): OK

401: Unauthorized

list 列出或观察 HorizontalPodAutoscaler 类别的对象

HTTP 请求

GET /apis/autoscaling/v2/horizontalpodautoscalers

参数

响应

200 (HorizontalPodAutoscalerList): OK

401: Unauthorized

create 创建一个 HorizontalPodAutoscaler

HTTP 请求

POST /apis/autoscaling/v2/namespaces/{namespace}/horizontalpodautoscalers

参数

响应

200 (HorizontalPodAutoscaler): OK

201 (HorizontalPodAutoscaler): Created

202 (HorizontalPodAutoscaler): Accepted

401: Unauthorized

update 替换指定的 HorizontalPodAutoscaler

HTTP 请求

PUT /apis/autoscaling/v2/namespaces/{namespace}/horizontalpodautoscalers/{name}

参数

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

    HorizontalPodAutoscaler 的名称。

响应

200 (HorizontalPodAutoscaler): OK

201 (HorizontalPodAutoscaler): Created

401: Unauthorized

update 替换指定 HorizontalPodAutoscaler 的状态

HTTP 请求

PUT /apis/autoscaling/v2/namespaces/{namespace}/horizontalpodautoscalers/{name}/status

参数

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

    HorizontalPodAutoscaler 的名称。

响应

200 (HorizontalPodAutoscaler): OK

201 (HorizontalPodAutoscaler): Created

401: Unauthorized

patch 部分更新指定的 HorizontalPodAutoscaler

HTTP 请求

PATCH /apis/autoscaling/v2/namespaces/{namespace}/horizontalpodautoscalers/{name}

参数

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

    HorizontalPodAutoscaler 的名称。

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

    namespace

  • bodyPatch,必需

  • dryRun查询参数): string

    dryRun

  • fieldManager查询参数): string

    fieldManager

  • fieldValidation查询参数): string

    fieldValidation

  • force查询参数): boolean

    force

  • pretty查询参数): string

    pretty

响应

200 (HorizontalPodAutoscaler): OK

201 (HorizontalPodAutoscaler): Created

401: Unauthorized

patch 部分更新指定 HorizontalPodAutoscaler 的状态

HTTP 请求

PATCH /apis/autoscaling/v2/namespaces/{namespace}/horizontalpodautoscalers/{name}/status

参数

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

    HorizontalPodAutoscaler 的名称。

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

    namespace

  • bodyPatch,必需

  • dryRun查询参数): string

    dryRun

  • fieldManager查询参数): string

    fieldManager

  • fieldValidation查询参数): string

    fieldValidation

  • force查询参数): boolean

    force

  • pretty查询参数): string

    pretty

响应

200 (HorizontalPodAutoscaler): OK

201 (HorizontalPodAutoscaler): Created

401: Unauthorized

delete 删除一个 HorizontalPodAutoscaler

HTTP 请求

DELETE /apis/autoscaling/v2/namespaces/{namespace}/horizontalpodautoscalers/{name}

参数

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

    HorizontalPodAutoscaler 的名称。

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 HorizontalPodAutoscaler 的集合

HTTP 请求

DELETE /apis/autoscaling/v2/namespaces/{namespace}/horizontalpodautoscalers

参数

响应

200 (Status): OK

401: Unauthorized

1.13 - PriorityClass

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

apiVersion: scheduling.k8s.io/v1

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

PriorityClass

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


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

    value 表示此优先级的整数值。这是 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

1.14 - PodSchedulingContext v1alpha2

PodSchedulingContext 对象包含使用 "WaitForFirstConsumer" 分配模式的 ResourceClaims 来调度 Pod 所需的信息。

apiVersion: resource.k8s.io/v1alpha2

import "k8s.io/api/resource/v1alpha2"

PodSchedulingContext

PodSchedulingContext 对象包含调度某些 Pod 所需要的额外信息,这些 Pod 使用了 “WaitForFirstConsumer” 分配模式的 ResourceClaim。

本功能特性是 Alpha 级别的特性,需要启用 DynamicResourceAllocation 特性门控。


  • apiVersion: resource.k8s.io/v1alpha2

  • kind: PodSchedulingContext

  • metadata (ObjectMeta)

    标准的对象元数据。

PodSchedulingContextSpec

PodSchedulingContextSpec 描述了 Pod 所需要的资源在哪里。


  • potentialNodes ([]string)

    集合:合并期间保留唯一值

    potentialNodes 列出可以运行 Pod 的节点。

    该字段的大小限制为 128。对于许多集群来说,这已经足够大了。 较大的集群可能需要更多的尝试去找到一个适合所有待定资源的节点。 这个限制值可能会在以后提高,但不会降低。

  • selectedNode (string)

    selectedNode 是一个节点,由 Pod 引用的 ResourceClaim 将在此节点上尝试, 且尝试的分配模式是 “WaitForFirstConsumer”。

PodSchedulingContextStatus

PodSchedulingContextStatus 描述 Pod 的资源可以从哪里分配。


  • resourceClaims ([]ResourceClaimSchedulingStatus)

    映射:键 name 的唯一值将在合并过程中保留

    resourceClaims 描述了每个 pod.spec.resourceClaim 条目的资源可用性, 其中对应的 ResourceClaim 使用 “WaitForFirstConsumer” 分配模式。

    ResourceClaimSchedulingStatus 包含关于一个采用 “WaitForFirstConsumer” 分配模式的特定 ResourceClaim 的信息。

    • resourceClaims.name (string)

      name 与 pod.spec.resourceClaims[*].name 字段匹配。

    • resourceClaims.unsuitableNodes ([]string)

      集合:合并期间保留唯一值

      unsuitableNodes 列出 ResourceClaim 无法被分配的节点。

      该字段的大小限制为 128,与 PodSchedulingSpec.PotentialNodes 相同。 这可能会在以后增加,但不会减少。

PodSchedulingContextList

PodSchedulingContextList 是 Pod 调度对象的集合。


  • apiVersion: resource.k8s.io/v1alpha2

  • kind: PodSchedulingContextList

  • metadata (ListMeta)

    标准的列表元数据。

操作


get 读取指定的 PodSchedulingContext

HTTP 请求

GET /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/podschedulingcontexts/{name}

参数

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

    PodSchedulingContext 的名称。

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

    namespace

  • pretty查询参数):string

    pretty

响应

200 (PodSchedulingContext): OK

401: Unauthorized

get 读取指定 PodSchedulingContext 的状态

HTTP 请求

GET /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/podschedulingcontexts/{name}/status

参数

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

    PodSchedulingContext 的名称。

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

    namespace

  • pretty查询参数):string

    pretty

响应

200 (PodSchedulingContext): OK

401: Unauthorized

list 列出或监视 PodSchedulingContext 类别的对象

HTTP 请求

GET /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/podschedulingcontexts

参数

响应

200 (PodSchedulingContextList): OK

401: Unauthorized

list 列出或监视 PodSchedulingContext 类别的对象

HTTP 请求

GET /apis/resource.k8s.io/v1alpha2/podschedulingcontexts

参数

响应

200 (PodSchedulingContextList): OK

401: Unauthorized

create 创建 PodSchedulingContext

HTTP 请求

POST /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/podschedulingcontexts

参数

响应

200 (PodSchedulingContext): OK

201 (PodSchedulingContext): Created

202 (PodSchedulingContext): Accepted

401: Unauthorized

update 替换指定的 PodSchedulingContext

HTTP 请求

PUT /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/podschedulingcontexts/{name}

参数

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

    PodSchedulingContext 的名称。

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

    namespace

  • body: PodSchedulingContext,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • pretty查询参数):string

    pretty

响应

200 (PodSchedulingContext): OK

201 (PodSchedulingContext): Created

401: Unauthorized

update 替换指定 PodSchedulingContext 的状态

HTTP 请求

PUT /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/podschedulingcontexts/{name}/status

参数

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

    PodSchedulingContext 的名称。

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

    namespace

  • body: PodSchedulingContext,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • pretty查询参数):string

    pretty

响应

200 (PodSchedulingContext): OK

201 (PodSchedulingContext): Created

401: Unauthorized

patch 部分更新指定的 PodSchedulingContext

HTTP 请求

PATCH /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/podschedulingcontexts/{name}

参数

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

    PodSchedulingContext 的名称。

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

    namespace

  • body: Patch,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (PodSchedulingContext): OK

201 (PodSchedulingContext): Created

401: Unauthorized

patch 部分更新指定 PodSchedulingContext 的状态

HTTP 请求

PATCH /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/podschedulingcontexts/{name}/status

参数

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

    PodSchedulingContext 的名称。

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

    namespace

  • body: Patch,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (PodSchedulingContext): OK

201 (PodSchedulingContext): Created

401: Unauthorized

delete 删除 PodSchedulingContext

HTTP 请求

DELETE /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/podschedulingcontexts/{name}

参数

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

    PodSchedulingContext 的名称。

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

    namespace

  • body: DeleteOptions

  • dryRun查询参数):string

    dryRun

  • gracePeriodSeconds查询参数):integer

    gracePeriodSeconds

  • pretty查询参数):string

    pretty

  • propagationPolicy查询参数):string

    propagationPolicy

响应

200 (PodSchedulingContext): OK

202 (PodSchedulingContext): Accepted

401: Unauthorized

deletecollection 删除 PodSchedulingContext 的集合

HTTP 请求

DELETE /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/podschedulingcontexts

参数

响应

200 (Status): OK

401: Unauthorized

1.15 - ResourceClaim v1alpha2

ResourceClaim 描述资源使用者需要哪些资源。

apiVersion: resource.k8s.io/v1alpha2

import "k8s.io/api/resource/v1alpha2"

ResourceClaim

ResourceClaim 描述资源使用者需要哪些资源。它的状态跟踪资源是否已被分配以及产生的属性是什么。

这是一个 Alpha 级别的资源类型,需要启用 DynamicResourceAllocation 特性门控。


  • apiVersion: resource.k8s.io/v1alpha2

  • kind: ResourceClaim

  • spec (ResourceClaimSpec),必需

    spec 描述了需要被分配的资源所需的属性。它只能在创建 ResourceClaim 时设置一次。

  • status (ResourceClaimStatus)

    status 描述资源是否可用以及具有哪些属性。

ResourceClaimSpec

ResourceClaimSpec 定义资源如何被分配。


  • resourceClassName (string),必需

    resourceClassName 通过部署驱动时创建的 ResourceClass 名称来引用驱动和附加参数。

  • allocationMode (string)

    分配可以立即开始或在 Pod 想要使用资源时开始。"WaitForFirstConsumer" 是默认值。

  • parametersRef (ResourceClaimParametersReference)

    parametersRef 引用一个单独的对象,包含驱动为申领分配资源时将使用的任意参数。

    此对象必须与 ResourceClaim 在同一个名字空间中。

    ResourceClaimParametersReference 包含足够信息,便于你定位 ResourceClaim 的参数。 该对象必须与 ResourceClaim 在相同的名字空间中。

    • parametersRef.kind (string),必需

      kind 是所引用资源的类别。这个值与参数对象元数据中的值相同,例如 "ConfigMap"。

    • parametersRef.name (string),必需

      name 是所引用资源的名称。

    • parametersRef.apiGroup (string)

      apiGroup 是所引用资源的组。对于核心 API 而言此值为空。 字段值与创建资源时所用的 apiVersion 中的组匹配。

ResourceClaimStatus

ResourceClaimStatus 跟踪资源是否已被分配以及产生的属性是什么。


  • allocation (AllocationResult)

    一旦某资源或资源集已被成功分配,资源驱动就会设置 allocation 的值。 如果此项未被设置,则表示资源尚未被分配。

    AllocationResult 包含已分配资源的属性。

    • allocation.availableOnNodes (NodeSelector)

      在资源驱动完成资源分配之后,将设置此字段以通知调度器可以将使用了 ResourceClaim 的 Pod 调度到哪里。

      设置此字段是可选的。如果字段值为空,表示资源可以在任何地方访问。

      节点选择算符表示对一组节点执行一个或多个标签查询的结果的并集; 也就是说,它表示由节点选择算符条件表示的选择算符的逻辑或计算结果。

      • allocation.availableOnNodes.nodeSelectorTerms ([]NodeSelectorTerm),必需

        必需。节点选择算符条件的列表。这些条件以逻辑或进行计算。

        一个 null 或空的节点选择算符条件不会与任何对象匹配。条件中的要求会按逻辑与的关系来计算。 TopologySelectorTerm 类别实现了 NodeSelectorTerm 的子集。

        • allocation.availableOnNodes.nodeSelectorTerms.matchExpressions ([]NodeSelectorRequirement)

          基于节点标签所设置的节点选择算符要求的列表。

        • allocation.availableOnNodes.nodeSelectorTerms.matchFields ([]NodeSelectorRequirement)

          基于节点字段所设置的节点选择算符要求的列表。

    • allocation.resourceHandles ([]ResourceHandle)

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

      resourceHandles 包含应在申领的整个生命期中保持的、与某资源分配所关联的状态。 每个 resourceHandle 包含应向特定 kubelet 插件传递的数据, 一旦资源落到某具体节点上,这些数据就会被传递给该插件。 此数据将在成功分配后由驱动返回,并对 Kubernetes 不透明。 必要时驱动文档可能会向用户阐述如何解读这些数据。

      设置此字段是可选的。它最大可以有 32 个条目。如果为 null(或为空), 则假定此分配将由某个确定的 kubelet 插件处理, 不会附加 resourceHandle 数据。所调用的 kubelet 插件的名称将与嵌入此 AllocationResult 的 ResourceClaimStatus 中设置的 driverName 匹配。

      resourceHandle 保存不透明的资源数据,以供特定的 kubelet 插件处理。

      • allocation.resourceHandles.data (string)

        data 包含与此 resourceHandle 关联的不透明数据。 data 由资源驱动中的控制器组件设置,该驱动的名字与嵌入此 resourceHandle 的 ResourceClaimStatus 中设置的 driverName 相同。 data 在分配时进行设置,供 kubelet 插件处理;所指的插件的名称与此 resourceHandle 所设置的 driverName 相同。

        该字段的最大值为 16KiB。此值在未来可能会增加,但不会减少。

      • allocation.resourceHandles.driverName (string)

        driverName 指定资源驱动的名称;一旦 resourceHandle 落到某具体节点, 就应调用该驱动对应的 kubelet 插件来处理此数据。 字段值可能与嵌入此 resourceHandle 的 ResourceClaimStatus 中设置的 driverName 不同。

    • allocation.shareable (boolean)

      shareable 确定资源是否同时支持多个使用者。

  • deallocationRequested (boolean)

    deallocationRequested 表示某 ResourceClaim 将被取消分配。

    出现请求后,驱动必须释放此申领,重置此字段并清除 allocation 字段。

    在 deallocationRequested 被设置时,不能将新的使用者添加到 reservedFor。

  • driverName (string)

    driverName 是在确定了分配之后,从 ResourceClass 复制而来的驱动名称。

  • reservedFor ([]ResourceClaimConsumerReference)

    Map:合并期间根据键 uid 保留不重复的值

    reservedFor 标明目前哪些实体允许使用申领。如果引用未为某个 Pod 预留的 ResourceClaim,则该 Pod 将不会启动。

    最多可以有 32 个这样的预留。这一限制可能会在未来放宽,但不会减少。

    ResourceClaimConsumerReference 包含足够的信息以便定位 ResourceClaim 的使用者。 用户必须是与 ResourceClaim 在同一名字空间中的资源。

    • reservedFor.name (string),必需

      name 是所引用资源的名称。

    • reservedFor.resource (string),必需

      resource 是所引用资源的类别,例如 "pods"。

    • reservedFor.uid (string),必需

      uid 用于唯一标识资源的某实例。

    • reservedFor.apiGroup (string)

      apiGroup 是所引用资源的组。对于核心 API 而言此值为空。 字段值与创建资源时所用的 apiVersion 中的组匹配。

ResourceClaimList

ResourceClaimList 是申领的集合。


  • apiVersion: resource.k8s.io/v1alpha2

  • kind: ResourceClaimList

  • metadata (ListMeta)

    标准的列表元数据。

  • items ([]ResourceClaim),必需

    items 是资源申领的列表。

操作


get 读取指定的 ResourceClaim

HTTP 请求

GET /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/resourceclaims/{name}

参数

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

    ResourceClaim 的名称。

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

    namespace

  • pretty查询参数):string

    pretty

响应

200 (ResourceClaim): OK

401: Unauthorized

get 读取指定 ResourceClaim 的状态

HTTP 请求

GET /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/resourceclaims/{name}/status

参数

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

    ResourceClaim 的名称。

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

    namespace

  • pretty查询参数):string

    pretty

响应

200 (ResourceClaim): OK

401: Unauthorized

list 列出或监视 ResourceClaim 类别的对象

HTTP 请求

GET /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/resourceclaims

参数

响应

200 (ResourceClaimList): OK

401: Unauthorized

list 列出或监视 ResourceClaim 类别的对象

HTTP 请求

GET /apis/resource.k8s.io/v1alpha2/resourceclaims

参数

响应

200 (ResourceClaimList): OK

401: Unauthorized

create 创建 ResourceClaim

HTTP 请求

POST /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/resourceclaims

参数

响应

200 (ResourceClaim): OK

201 (ResourceClaim): Created

202 (ResourceClaim): Accepted

401: Unauthorized

update 替换指定的 ResourceClaim

HTTP 请求

PUT /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/resourceclaims/{name}

参数

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

    ResourceClaim 的名称。

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

    namespace

  • body: ResourceClaim,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • pretty查询参数):string

    pretty

响应

200 (ResourceClaim): OK

201 (ResourceClaim): Created

401: Unauthorized

update 替换指定 ResourceClaim 的状态

HTTP 请求

PUT /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/resourceclaims/{name}/status

参数

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

    ResourceClaim 的名称。

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

    namespace

  • body: ResourceClaim,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • pretty查询参数):string

    pretty

响应

200 (ResourceClaim): OK

201 (ResourceClaim): Created

401: Unauthorized

patch 部分更新指定的 ResourceClaim

HTTP 请求

PATCH /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/resourceclaims/{name}

参数

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

    ResourceClaim 的名称。

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

    namespace

  • body: Patch,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (ResourceClaim): OK

201 (ResourceClaim): Created

401: Unauthorized

patch 部分更新指定 ResourceClaim 的状态

HTTP 请求

PATCH /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/resourceclaims/{name}/status

参数

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

    ResourceClaim 的名称。

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

    namespace

  • body: Patch,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (ResourceClaim): OK

201 (ResourceClaim): Created

401: Unauthorized

delete 删除 ResourceClaim

HTTP 请求

DELETE /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/resourceclaims/{name}

参数

响应

200 (ResourceClaim): OK

202 (ResourceClaim): Accepted

401: Unauthorized

deletecollection 删除 ResourceClaim 的集合

HTTP 请求

DELETE /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/resourceclaims

参数

响应

200 (Status): OK

401: Unauthorized

1.16 - ResourceClaimTemplate v1alpha2

ResourceClaimTemplate 用于生成 ResourceClaim 对象。

apiVersion: resource.k8s.io/v1alpha2

import "k8s.io/api/resource/v1alpha2"

ResourceClaimTemplate

ResourceClaimTemplate 用于生成 ResourceClaim 对象。


  • apiVersion: resource.k8s.io/v1alpha2

  • kind: ResourceClaimTemplate

  • metadata (ObjectMeta)

    标准的对象元数据。

  • spec (ResourceClaimTemplateSpec), 必需

    描述要生成的 ResourceClaim。

    该字段是不可变的。当需要时,控制平面将为 Pod 创建一个 ResourceClaim,然后不再对其进行更新。

ResourceClaimTemplateSpec

ResourceClaimTemplateSpec 包含针对 ResourceClaim 的元数据和字段。


spec* (ResourceClaimSpec), 必需

ResourceClaim 的规约。整个内容将不加修改地复制到从模板创建的 ResourceClaim 中。 与 ResourceClaim 中相同的字段在此处也是有效的。

  • metadata (ObjectMeta)

    ObjectMeta 可以包含创建 PVC 时将要复制到其中的标签和注解。 不允许设置其他字段,并且即便设置了也会在验证期间被拒绝。

ResourceClaimTemplateList

ResourceClaimTemplateList 是申领模板的集合。


  • apiVersion: resource.k8s.io/v1alpha2

  • kind: ResourceClaimTemplateList

  • metadata (ListMeta)

    标准的列表元数据。

操作


get 读取指定的 ResourceClaimTemplate

HTTP 请求

GET /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/resourceclaimtemplates/{name}

参数

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

    name of the ResourceClaimTemplate

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (ResourceClaimTemplate): OK

401: Unauthorized

list 列出或监视 ResourceClaimTemplate 类别的对象

HTTP 请求

GET /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/resourceclaimtemplates

参数

响应

200 (ResourceClaimTemplateList): OK

401: Unauthorized

list 列出或监视 ResourceClaimTemplate 类别的对象

HTTP 请求

GET /apis/resource.k8s.io/v1alpha2/resourceclaimtemplates

参数

响应

200 (ResourceClaimTemplateList): OK

401: Unauthorized

create 创建 ResourceClaimTemplate

HTTP 请求

POST /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/resourceclaimtemplates

参数

响应

200 (ResourceClaimTemplate): OK

201 (ResourceClaimTemplate): Created

202 (ResourceClaimTemplate): Accepted

401: Unauthorized

update 替换指定的 ResourceClaimTemplate

HTTP 请求

PUT /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/resourceclaimtemplates/{name}

参数

响应

200 (ResourceClaimTemplate): OK

201 (ResourceClaimTemplate): Created

401: Unauthorized

patch 部分更新指定的 ResourceClaimTemplate

HTTP 请求

PATCH /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/resourceclaimtemplates/{name}

参数

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

    name of the ResourceClaimTemplate

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

    namespace

  • body: Patch, 必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (ResourceClaimTemplate): OK

201 (ResourceClaimTemplate): Created

401: Unauthorized

delete 删除 ResourceClaimTemplate

HTTP 请求

DELETE /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/resourceclaimtemplates/{name}

参数

响应

200 (ResourceClaimTemplate): OK

202 (ResourceClaimTemplate): Accepted

401: Unauthorized

deletecollection 删除 ResourceClaimTemplate 的集合

HTTP 请求

DELETE /apis/resource.k8s.io/v1alpha2/namespaces/{namespace}/resourceclaimtemplates

参数

响应

200 (Status): OK

401: Unauthorized

1.17 - ResourceClass v1alpha2

ResourceClass 由管理员用于影响资源被分配的方式。

apiVersion: resource.k8s.io/v1alpha2

import "k8s.io/api/resource/v1alpha2"

ResourceClass

ResourceClass 由管理员用于影响资源被分配的方式。

这是一个 Alpha 级别的资源类型,需要启用 DynamicResourceAllocation 特性门控。


  • apiVersion: resource.k8s.io/v1alpha2

  • kind: ResourceClass

  • driverName (string),必需

    driverName 定义动态资源驱动的名称,该驱动用于分配使用此类的 ResourceClaim。

    资源驱动具有唯一的名称,以正向的域名顺序(acme.example.com)给出。

  • parametersRef (ResourceClassParametersReference)

    parametersRef 引用任意一个独立的对象,其中可以包含驱动在分配使用此类的资源时所用的参数。 动态资源驱动可以区分存储在此处的参数和存储在 ResourceClaimSpec 中的参数。

    ResourceClassParametersReference 包含了足够的信息,让你可以定位针对 ResourceClass 的参数。

    • parametersRef.kind (string),必需

      kind 是所引用资源的类别。这个值与参数对象元数据中的值相同。

    • parametersRef.name (string),必需

      name 是所引用资源的名称。

    • parametersRef.apiGroup (string)

      apiGroup 是所引用资源的组。对于核心 API 而言此值为空。这与创建资源时所用的 apiVersion 中的组匹配。

    • parametersRef.namespace (string)

      包含被引用的资源的名字空间。对于集群作用域的资源必须为空,对于名字空间作用域的资源必须不为空。

  • suitableNodes (NodeSelector)

    当 Pod 使用还未分配的 ResourceClaim 时,调度程序在尝试查找适合 Pod 的节点时, 将仅考虑与选择算符匹配的节点。

    设置此字段是可选的,如果设置为 null,则所有节点都是候选者。

    节点选择算符表示针对一组节点执行一个或多个标签查询的结果的并集; 也就是说,它表示由节点选择算符条件表示的选择算符的逻辑或计算结果。

    • suitableNodes.nodeSelectorTerms ([]NodeSelectorTerm),必需

      必需。节点选择算符条件的列表。这些条件会按逻辑或的关系来计算。

      Null 或空的节点选择算符条件不会与任何对象匹配。这些条件会按逻辑与的关系来计算。 TopologySelectorTerm 类别实现了 NodeSelectorTerm 的子集。

      • suitableNodes.nodeSelectorTerms.matchExpressions ([]NodeSelectorRequirement)

        基于节点标签所设置的节点选择算符要求的列表。

      • suitableNodes.nodeSelectorTerms.matchFields ([]NodeSelectorRequirement)

        基于节点字段所设置的节点选择算符要求的列表。

ResourceClassList

ResourceClassList 是资源类的集合。


  • apiVersion: resource.k8s.io/v1alpha2

  • kind: ResourceClassList

  • metadata (ListMeta)

    标准的列表元数据。

  • items ([]ResourceClass),必需

    items 是资源类的列表。

操作


get 读取指定的 ResourceClass

HTTP 请求

GET /apis/resource.k8s.io/v1alpha2/resourceclasses/{name}

参数

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

    ResourceClass 的名称。

  • pretty查询参数):string

    pretty

响应

200 (ResourceClass): OK

401: Unauthorized

list 列出或监视 ResourceClass 类别的对象

HTTP 请求

GET /apis/resource.k8s.io/v1alpha2/resourceclasses

参数

响应

200 (ResourceClassList): OK

401: Unauthorized

create 创建 ResourceClass

HTTP 请求

POST /apis/resource.k8s.io/v1alpha2/resourceclasses

参数

响应

200 (ResourceClass): OK

201 (ResourceClass): Created

202 (ResourceClass): Accepted

401: Unauthorized

update 替换指定的 ResourceClass

HTTP 请求

PUT /apis/resource.k8s.io/v1alpha2/resourceclasses/{name}

参数

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

    ResourceClass 的名称。

  • body: ResourceClass,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • pretty查询参数):string

    pretty

响应

200 (ResourceClass): OK

201 (ResourceClass): Created

401: Unauthorized

patch 部分更新指定的 ResourceClass

HTTP 请求

PATCH /apis/resource.k8s.io/v1alpha2/resourceclasses/{name}

参数

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

    ResourceClass 的名称。

  • body: Patch,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (ResourceClass): OK

201 (ResourceClass): Created

401: Unauthorized

delete 删除 ResourceClass

HTTP 请求

DELETE /apis/resource.k8s.io/v1alpha2/resourceclasses/{name}

参数

响应

200 (ResourceClass): OK

202 (ResourceClass): Accepted

401: Unauthorized

deletecollection 删除 ResourceClass 的集合

HTTP 请求

DELETE /apis/resource.k8s.io/v1alpha2/resourceclasses

参数

响应

200 (Status): OK

401: Unauthorized

2 - Service 资源

2.1 - Service

Service 是软件服务(例如 mysql)的命名抽象,包含代理要侦听的本地端口(例如 3306)和一个选择算符,选择算符用来确定哪些 Pod 将响应通过代理发送的请求。

apiVersion: v1

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

Service

Service 是软件服务(例如 mysql)的命名抽象,包含代理要侦听的本地端口(例如 3306)和一个选择算符, 选择算符用来确定哪些 Pod 将响应通过代理发送的请求。


ServiceSpec

ServiceSpec 描述用户在服务上创建的属性。


  • selector (map[string]string)

    将 Service 流量路由到具有与此 selector 匹配的标签键值对的 Pod。 如果为空或不存在,则假定该服务有一个外部进程管理其端点,Kubernetes 不会修改该端点。 仅适用于 ClusterIP、NodePort 和 LoadBalancer 类型。如果类型为 ExternalName,则忽略。 更多信息: https://kubernetes.io/docs/concepts/services-networking/service/

  • ports ([]ServicePort)

    Patch strategy:基于键 type 合并

    Map:合并时将保留 type 键的唯一值

    此 Service 公开的端口列表。 更多信息: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies

    ServicePort 包含有关 ServicePort 的信息。

    • ports.port (int32),必需

      Service 将公开的端口。

    • ports.targetPort (IntOrString)

      在 Service 所针对的 Pod 上要访问的端口号或名称。 编号必须在 1 到 65535 的范围内。名称必须是 IANA_SVC_NAME。 如果此值是一个字符串,将在目标 Pod 的容器端口中作为命名端口进行查找。 如果未指定字段,则使用 port 字段的值(直接映射)。 对于 clusterIP 为 None 的服务,此字段将被忽略, 应忽略不设或设置为 port 字段的取值。 更多信息: https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service

      IntOrString 是一种可以保存 int32 或字符串的类型。 在 JSON 或 YAML 编组和解组中使用时,它会生成或使用内部类型。 例如,这允许您拥有一个可以接受名称或数字的 JSON 字段。

    • ports.protocol (string)

      此端口的 IP 协议。支持 “TCP”、“UDP” 和 “SCTP”。默认为 TCP。

    • ports.name (string)

      Service 中此端口的名称。这必须是 DNS_LABEL。 ServiceSpec 中的所有端口的名称都必须唯一。 在考虑 Service 的端点时,这一字段值必须与 EndpointPort 中的 name 字段相同。 如果此服务上仅定义一个 ServicePort,则为此字段为可选。

    • ports.nodePort (int32)

      当类型为 NodePort 或 LoadBalancer 时,Service 公开在节点上的端口, 通常由系统分配。如果指定了一个在范围内且未使用的值,则将使用该值,否则操作将失败。 如果在创建的 Service 需要该端口时未指定该字段,则会分配端口。 如果在创建不需要该端口的 Service时指定了该字段,则会创建失败。 当更新 Service 时,如果不再需要此字段(例如,将类型从 NodePort 更改为 ClusterIP),这个字段将被擦除。 更多信息: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport

    • ports.appProtocol (string)

      此端口的应用协议,用作实现的提示,为他们理解的协议提供更丰富的行为。此字段遵循标准
      

      Kubernetes 标签语法,有效值包括:

        * 无前缀协议名称 - 保留用于 IANA 标准服务名称(根据 RFC-6335 和 https://www.iana.org/assignments/service-names)。
      
  • type (string)

    type 确定 Service 的公开方式。默认为 ClusterIP。 有效选项为 ExternalName、ClusterIP、NodePort 和 LoadBalancer。 ClusterIP 为端点分配一个集群内部 IP 地址用于负载均衡。 Endpoints 由 selector 确定,如果未设置 selector,则需要通过手动构造 Endpoints 或 EndpointSlice 的对象来确定。 如果 clusterIP 为 None,则不分配虚拟 IP,并且 Endpoints 作为一组端点而不是虚拟 IP 发布。 NodePort 建立在 ClusterIP 之上,并在每个节点上分配一个端口,该端口路由到与 clusterIP 相同的 Endpoints。 LoadBalancer 基于 NodePort 构建并创建一个外部负载均衡器(如果当前云支持),该负载均衡器路由到与 clusterIP 相同的 Endpoints。 externalName 将此 Service 别名为指定的 externalName。其他几个字段不适用于 ExternalName Service。 更多信息: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types

  • ipFamilies ([]string)

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

    iPFamilies 是分配给此服务的 IP 协议(例如 IPv4、IPv6)的列表。 该字段通常根据集群配置和 ipFamilyPolicy 字段自动设置。 如果手动指定该字段,且请求的协议在集群中可用,且 ipFamilyPolicy 允许,则使用;否则服务创建将失败。 该字段修改是有条件的:它允许添加或删除辅助 IP 协议,但不允许更改服务的主要 IP 协议。 有效值为 “IPv4” 和 “IPv6”。 该字段仅适用于 ClusterIP、NodePort 和 LoadBalancer 类型的服务,并且确实可用于“无头”服务。 更新服务设置类型为 ExternalName 时,该字段将被擦除。

    该字段最多可以包含两个条目(双栈系列,按任意顺序)。 如果指定,这些协议栈必须对应于 clusterIPs 字段的值。 clusterIP 和 ipFamilies 都由 ipFamilyPolicy 字段管理。

  • ipFamilyPolicy (string)

    iPFamilyPolicy 表示此服务请求或要求的双栈特性。 如果没有提供值,则此字段将被设置为 SingleStack。 服务可以是 “SingleStack”(单个 IP 协议)、 “PreferDualStack”(双栈配置集群上的两个 IP 协议或单栈集群上的单个 IP 协议) 或 “RequireDualStack”(双栈上的两个 IP 协议配置的集群,否则失败)。 ipFamilies 和 clusterIPs 字段取决于此字段的值。 更新服务设置类型为 ExternalName 时,此字段将被擦除。

  • clusterIP (string)

    clusterIP 是服务的 IP 地址,通常是随机分配的。 如果地址是手动指定的,在范围内(根据系统配置),且没有被使用,它将被分配给服务,否则创建服务将失败。 clusterIP 一般不会被更改,除非 type 被更改为 ExternalName (ExternalName 需要 clusterIP 为空)或 type 已经是 ExternalName 时,可以更改 clusterIP(在这种情况下,可以选择指定此字段)。 可选值 “None”、空字符串 (“”) 或有效的 IP 地址。 clusterIP 为 “None” 时会生成“无头服务”(无虚拟 IP),这在首选直接 Endpoint 连接且不需要代理时很有用。 仅适用于 ClusterIP、NodePort、和 LoadBalancer 类型的服务。 如果在创建 ExternalName 类型的 Service 时指定了 clusterIP,则创建将失败。 更新 Service type 为 ExternalName 时,clusterIP 会被移除。 更多信息: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies

  • clusterIPs ([]string)

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

    clusterIPs 是分配给该 Service 的 IP 地址列表,通常是随机分配的。 如果地址是手动指定的,在范围内(根据系统配置),且没有被使用,它将被分配给 Service;否则创建 Service 失败。 clusterIP 一般不会被更改,除非 type 被更改为 ExternalName (ExternalName 需要 clusterIPs 为空)或 type 已经是 ExternalName 时,可以更改 clusterIPs(在这种情况下,可以选择指定此字段)。 可选值 “None”、空字符串 (“”) 或有效的 IP 地址。 clusterIPs 为 “None” 时会生成“无头服务”(无虚拟 IP),这在首选直接 Endpoint 连接且不需要代理时很有用。 适用于 ClusterIP、NodePort、和 LoadBalancer 类型的服务。 如果在创建 ExternalName 类型的 Service 时指定了 clusterIPs,则会创建失败。 更新 Service type 为 ExternalName 时,该字段将被移除。如果未指定此字段,则将从 clusterIP 字段初始化。 如果指定 clusterIPs,客户端必须确保 clusterIPs[0] 和 clusterIP 一致。

    clusterIPs 最多可包含两个条目(双栈系列,按任意顺序)。 这些 IP 必须与 ipFamilies 的值相对应。 clusterIP 和 ipFamilies 都由 ipFamilyPolicy 管理。 更多信息: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies

  • externalIPs ([]string)

    externalIPs 是一个 IP 列表,集群中的节点会为此 Service 接收针对这些 IP 地址的流量。 这些 IP 不被 Kubernetes 管理。用户需要确保流量可以到达具有此 IP 的节点。 一个常见的例子是不属于 Kubernetes 系统的外部负载均衡器。

  • sessionAffinity (string)

    支持 “ClientIP” 和 “None”。用于维护会话亲和性。 启用基于客户端 IP 的会话亲和性。必须是 ClientIP 或 None。默认为 None。 更多信息: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies

  • loadBalancerIP (string)

    仅适用于服务类型:LoadBalancer。此功能取决于底层云提供商是否支持负载均衡器。 如果云提供商不支持该功能,该字段将被忽略。 已弃用:该字段信息不足,且其含义因实现而异。此字段是不可移植的,并且可能不支持双栈。。 我们鼓励用户在可用时使用特定于实现的注解。

  • loadBalancerSourceRanges ([]string)

    如果设置了此字段并且被平台支持,将限制通过云厂商的负载均衡器的流量到指定的客户端 IP。 如果云提供商不支持该功能,该字段将被忽略。 更多信息: https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/

  • loadBalancerClass (string)

    loadBalancerClass 是此 Service 所属的负载均衡器实现的类。 如果设置了此字段,则字段值必须是标签风格的标识符,带有可选前缀,例如 ”internal-vip” 或 “example.com/internal-vip”。 无前缀名称是为最终用户保留的。该字段只能在 Service 类型为 “LoadBalancer” 时设置。 如果未设置此字段,则使用默认负载均衡器实现。默认负载均衡器现在通常通过云提供商集成完成,但应适用于任何默认实现。 如果设置了此字段,则假定负载均衡器实现正在监测具有对应负载均衡器类的 Service。 任何默认负载均衡器实现(例如云提供商)都应忽略设置此字段的 Service。 只有在创建或更新的 Service 的 type 为 “LoadBalancer” 时,才可设置此字段。 一经设定,不可更改。当 Service 的 type 更新为 “LoadBalancer” 之外的其他类型时,此字段将被移除。

  • externalName (string)

    externalName 是发现机制将返回的外部引用,作为此服务的别名(例如 DNS CNAME 记录)。 不涉及代理。必须是小写的 RFC-1123 主机名 (https://tools.ietf.org/html/rfc1123), 并且要求 typeExternalName

  • externalTrafficPolicy (string)

    externalTrafficPolicy 描述了节点如何分发它们在 Service 的“外部访问”地址 (NodePort、ExternalIP 和 LoadBalancer IP)接收到的服务流量。 如果设置为 “Local”,代理将以一种假设外部负载均衡器将负责在节点之间服务流量负载均衡, 因此每个节点将仅向服务的节点本地端点传递流量,而不会伪装客户端源 IP。 (将丢弃错误发送到没有端点的节点的流量。) “Cluster” 默认值使用负载均衡路由到所有端点的策略(可能会根据拓扑和其他特性进行修改)。 请注意,从集群内部发送到 External IP 或 LoadBalancer IP 的流量始终具有 “Cluster” 语义, 但是从集群内部发送到 NodePort 的客户端需要在选择节点时考虑流量路由策略。

  • internalTrafficPolicy (string)

    InternalTrafficPolicy 描述节点如何分发它们在 ClusterIP 上接收到的服务流量。 如果设置为 “Local”,代理将假定 Pod 只想与在同一节点上的服务端点通信,如果没有本地端点,它将丢弃流量。 “Cluster” 默认将流量路由到所有端点(可能会根据拓扑和其他特性进行修改)。

  • healthCheckNodePort (int32)

    healthCheckNodePort 指定 Service 的健康检查节点端口。 仅适用于 type 为 LoadBalancer 且 externalTrafficPolicy 设置为 Local 的情况。 如果为此字段设定了一个值,该值在合法范围内且没有被使用,则使用所指定的值。 如果未设置此字段,则自动分配字段值。外部系统(例如负载平衡器)可以使用此端口来确定给定节点是否拥有此服务的端点。 在创建不需要 healthCheckNodePort 的 Service 时指定了此字段,则 Service 创建会失败。 要移除 healthCheckNodePort,需要更改 Service 的 type。 该字段一旦设置就无法更改。

  • publishNotReadyAddresses (boolean)

    publishNotReadyAddresses 表示任何处理此 Service 端点的代理都应忽略任何准备就绪/未准备就绪的指示。 设置此字段的主要场景是为 StatefulSet 的服务提供支持,使之能够为其 Pod 传播 SRV DNS 记录,以实现对等发现。 为 Service 生成 Endpoints 和 EndpointSlice 资源的 Kubernetes 控制器对字段的解读是, 即使 Pod 本身还没有准备好,所有端点都可被视为 “已就绪”。 对于代理而言,如果仅使用 Kubernetes 通过 Endpoints 或 EndpointSlice 资源所生成的端点, 则可以安全地假设这种行为。

  • sessionAffinityConfig (SessionAffinityConfig)

    sessionAffinityConfig 包含会话亲和性的配置。

    SessionAffinityConfig 表示会话亲和性的配置。

    • sessionAffinityConfig.clientIP (ClientIPConfig)

      clientIP 包含基于客户端 IP 的会话亲和性的配置。

      ClientIPConfig 表示基于客户端 IP 的会话亲和性的配置。

      • sessionAffinityConfig.clientIP.timeoutSeconds (int32)

        timeoutSeconds 指定 ClientIP 类型会话的维系时间秒数。 如果 ServiceAffinity == "ClientIP",则该值必须 >0 && <=86400(1 天)。默认值为 10800(3 小时)。

  • allocateLoadBalancerNodePorts (boolean)

    allocateLoadBalancerNodePorts 定义了是否会自动为 LoadBalancer 类型的 Service 分配 NodePort。默认为 true。 如果集群负载均衡器不依赖 NodePort,则可以设置此字段为 false。 如果调用者(通过指定一个值)请求特定的 NodePort,则无论此字段如何,都会接受这些请求。 该字段只能设置在 type 为 LoadBalancer 的 Service 上,如果 type 更改为任何其他类型,该字段将被移除。

ServiceStatus

ServiceStatus 表示 Service 的当前状态。


  • conditions ([]Condition)

    Patch strategy: 在 type 上合并

    Map: 键类型的唯一值将在合并期间保留

    服务的当前状态。

    condition 包含此 API 资源某一方面当前的状态详细信息。

    • conditions.lastTransitionTime(Time),必需

      lastTransitionTime 是状况最近一次状态转化的时间。 变化应该发生在下层状况发生变化的时候。如果不知道下层状况发生变化的时间, 那么使用 API 字段更改的时间是可以接受的。

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

    • conditions.message (string),必需

      message 是人类可读的消息,有关转换的详细信息,可以是空字符串。

    • conditions.reason (string),必需

      reason 包含一个程序标识符,指示 condition 最后一次转换的原因。 特定条件类型的生产者可以定义该字段的预期值和含义,以及这些值是否被视为有保证的 API。 该值应该是 CamelCase 字符串且不能为空。

    • conditions.status (string),必需

      condition 的状态,True、False、Unknown 之一。

    • conditions.type (string),必需

      CamelCase 或 foo.example.com/CamelCase 中的条件类型。

    • conditions.observedGeneration (int64)

      observedGeneration 表示设置 condition 基于的 .metadata.generation 的过期次数。 例如,如果 .metadata.generation 当前为 12,但 .status.conditions[x].observedGeneration 为 9, 则 condition 相对于实例的当前状态已过期。

  • loadBalancer (LoadBalancerStatus)

    loadBalancer 包含负载均衡器的当前状态(如果存在)。

    LoadBalancerStatus 表示负载均衡器的状态。

    • loadBalancer.ingress ([]LoadBalancerIngress)

      ingress 是一个包含负载均衡器 Ingress 点的列表。Service 的流量需要被发送到这些 Ingress 点。

      LoadBalancerIngress 表示负载平衡器入口点的状态: 用于服务的流量是否被发送到入口点。

      • loadBalancer.ingress.hostname (string)

        hostname 是为基于 DNS 的负载均衡器 Ingress 点(通常是 AWS 负载均衡器)设置的。

      • loadBalancer.ingress.ip (string)

        ip 是为基于 IP 的负载均衡器 Ingress 点(通常是 GCE 或 OpenStack 负载均衡器)设置的。

      • loadBalancer.ingress.ipMode (string)

          ipMode 指定负载平衡器 IP 的行为方式,并且只能在设置了 ip 字段时指定。
        

        将其设置为 VIP 表示流量将传送到节点,并将目标设置为负载均衡器的 IP 和端口。 将其设置为 Proxy 表示将流量传送到节点或 Pod,并将目标设置为节点的 IP 和节点端口或 Pod 的 IP 和端口。 服务实现可以使用此信息来调整流量路由。

      • loadBalancer.ingress.ports ([]PortStatus)

        Atomic:将在合并期间被替换

        ports 是 Service 的端口列表。如果设置了此字段,Service 中定义的每个端口都应该在此列表中。

        • loadBalancer.ingress.ports.port (int32),必需

          port 是所记录的服务端口状态的端口号。

        • loadBalancer.ingress.ports.protocol (string),必需

          protocol 是所记录的服务端口状态的协议。支持的值为:TCPUDPSCTP

        • loadBalancer.ingress.ports.error (string)

          error 是记录 Service 端口的问题。 错误的格式应符合以下规则:

          • 内置错误原因应在此文件中指定,应使用 CamelCase 名称。
          • 云提供商特定错误原因的名称必须符合格式 foo.example.com/CamelCase。

ServiceList

ServiceList 包含一个 Service 列表。


  • items([]Service),必需

    Service 列表

操作


get 读取指定的 Service

HTTP 请求

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

参数

  • name (查询参数):string,必需

    Service 名称

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

    namespace

  • pretty查询参数):string

    pretty

响应

200(Service): OK

401: Unauthorized

get 读取指定 Service 的状态

HTTP 请求

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

参数

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

    Service 名称

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

    namespace

  • pretty查询参数):string

    pretty

响应

200(Service): OK

401: Unauthorized

list 列出或监测 Service 类型的对象

HTTP 请求

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

参数

响应

200(ServiceList): OK

401: Unauthorized

list 列出或监测 Service 类型的对象

HTTP 请求

GET /api/v1/services

参数

响应

200(ServiceList): OK

401: Unauthorized

create 创建一个 Service

HTTP 请求

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

参数

响应

200(Service): OK

201(Service): Created

202(Service): Accepted

401: Unauthorized

update 替换指定的 Service

HTTP 请求

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

参数

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

    Service 名称

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

    namespace

  • body: Service,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • pretty查询参数):string

    pretty

响应

200(Service): OK

201(Service): Created

401: Unauthorized

update 替换指定 Service 的状态

HTTP 请求

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

参数

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

    Service 名称

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

    namespace

  • body: Service,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • pretty查询参数):string

    pretty

响应

200(Service): OK

201(Service): Created

401: Unauthorized

patch 部分更新指定的 Service

HTTP 请求

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

参数

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

    Service 名称

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

    namespace

  • body: Patch,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200(Service): OK

201(Service): Created

401: Unauthorized

patch 部分更新指定 Service 的状态

HTTP 请求

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

参数

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

    Service 名称

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

    namespace

  • body: Patch,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200(Service): OK

201(Service): Created

401: Unauthorized

delete 删除 Service

HTTP 请求

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

参数

响应

200(Service): OK

202(Service): Accepted

401: Unauthorized

deletecollection 删除 Service 集合

HTTP 请求

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

参数

响应

200(Status): OK

401: Unauthorized

2.2 - Endpoints

Endpoints 是实现实际服务的端点的集合。

apiVersion: v1

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

Endpoints

Endpoints 是实现实际服务的端点的集合。举例:

 Name: "mysvc",
 Subsets: [
   {
     Addresses: [{"ip": "10.10.1.1"}, {"ip": "10.10.2.2"}],
     Ports: [{"name": "a", "port": 8675}, {"name": "b", "port": 309}]
   },
   {
     Addresses: [{"ip": "10.10.3.3"}],
     Ports: [{"name": "a", "port": 93}, {"name": "b", "port": 76}]
   },
]

  • apiVersion: v1

  • kind: Endpoints

  • metadata (ObjectMeta)

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

  • subsets ([]EndpointSubset)

    所有端点的集合是所有 subsets 的并集。不同地址会根据其 IP 地址被放入不同子集。 对于具有多个端口的单个地址,如果其中一些端口已就绪,而另一些端口未就绪(因为它们来自不同的容器), 将导致地址显示在不同端口的不同子集中。 任何地址都不可以同时出现在 addresses 和 notReadyAddress 中的相同子集内。

    EndpointSubset 是一组具有公共端口集的地址。扩展的端点集是 addresses 和 ports 的笛卡尔乘积。例如假设:

    { Addresses: [{"ip": "10.10.1.1"}, {"ip": "10.10.2.2"}], Ports: [{"name": "a", "port": 8675}, {"name": "b", "port": 309}] }

    则最终的端点集可以看作:

    a: [ 10.10.1.1:8675, 10.10.2.2:8675 ], b: [ 10.10.1.1:309, 10.10.2.2:309 ]*

    • subsets.addresses ([]EndpointAddress)

      提供标记为就绪的相关端口的 IP 地址。 这些端点应该被认为是负载均衡器和客户端可以安全使用的。

      EndpointAddress 是描述单个 IP 地址的元组。

      • subsets.addresses.ip (string), 必需

        端点的 IP。不可以是本地回路(127.0.0.0/8 或 ::1)、 链路本地(169.254.0.0/16 或 fe80::/10)或链路本地多播(224.0.0.0/24 或 ff02::/16))地址。

      • subsets.addresses.hostname (string)

        端点主机名称。

      • subsets.addresses.nodeName (string)

        可选:承载此端点的节点。此字段可用于确定一个节点的本地端点。

      • subsets.addresses.targetRef (ObjectReference)

        对提供端点的对象的引用。

    • subsets.notReadyAddresses ([]EndpointAddress)

      提供相关端口但由于尚未完成启动、最近未通过就绪态检查或最近未通过活跃性检查而被标记为当前未就绪的 IP 地址。 EndpointAddress 是描述单个 IP 地址的元组。

      • subsets.notReadyAddresses.ip (string), 必需

        端点的 IP。不可以是本地环路(127.0.0.0/8 或 ::1)、 链路本地(169.254.0.0/16 或 fe80::/10)或链路本地多播(224.0.0.0/24 或 ff02::/16)地址。

      • subsets.notReadyAddresses.hostname (string)

        端点主机名称。

      • subsets.notReadyAddresses.nodeName (string)

        可选:承载此端点的节点。此字段可用于确定节点的本地端点。

      • subsets.notReadyAddresses.targetRef (ObjectReference)

        对提供端点的对象的引用。

    • subsets.ports ([]EndpointPort)

      相关 IP 地址上可用的端口号。

      EndpointPort 是描述单个端口的元组。

      • subsets.ports.port (int32), 必需

        端点的端口号。

      • subsets.ports.protocol (string)

        此端口的 IP 协议。必须是 UDP、TCP 或 SCTP。默认值为 TCP。

      • subsets.ports.name (string)

        端口的名称。此字段必须与相应 ServicePort 中的 name 字段匹配。必须是 DNS_LABEL。 仅当定义了一个端口时才可选。

      • subsets.ports.appProtocol (string)

        端口的应用程序协议。这被用作实现的提示,为他们理解的协议提供更丰富的行为。 此字段遵循标准的 Kubernetes 标签语法。有效值为:

EndpointsList

EndpointsList 是端点列表。


操作


get 读取指定的 Endpoints

HTTP 请求

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

参数

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

    Endpoints 的名称。

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

    namespace

  • pretty (查询参数):string

    pretty

响应

200 (Endpoints): OK

401: Unauthorized

list 列出或监测 Endpoints 类型的对象

HTTP 请求

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

参数

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

    namespace

  • continue (查询参数):string

    continue

  • limit (查询参数):integer

    limit

  • pretty (查询参数):string

    pretty

  • watch (查询参数):boolean

    watch

响应

200 (EndpointsList): OK

401: Unauthorized

list 列出或监测 Endpoints 类型的对象

HTTP 请求

GET /api/v1/endpoints

参数

  • limit (查询参数):integer

    limit

  • pretty (查询参数):string

    pretty

响应

200 (EndpointsList): OK

401: Unauthorized

create 创建 Endpoints

HTTP 请求

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

参数

响应

200 (Endpoints): OK

201 (Endpoints): Created

202 (Endpoints): Accepted

401: Unauthorized

update 替换指定的 Endpoints

HTTP 请求

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

参数

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

    Endpoints 名称

响应

200 (Endpoints): OK

201 (Endpoints): Created

401: Unauthorized

patch 部分更新指定的 Endpoints

HTTP 请求

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

参数

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

    Endpoints 名称

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

    namespace

  • body: Patch, 必需

  • pretty (查询参数):string

    pretty

响应

200 (Endpoints): OK

201 (Endpoints): Created

401: Unauthorized

delete 删除 Endpoints

HTTP 请求

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

参数

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

    Endpoints 名称

  • dryRun (查询参数):string

    dryRun

  • pretty (查询参数):string

    pretty

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 Endpoints 组

HTTP 请求

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

参数

  • continue (查询参数):string

    continue

  • dryRun (查询参数):string

    dryRun

  • limit (查询参数):integer

    limit

  • pretty (查询参数):string

    pretty

响应

200 (Status): OK

401: Unauthorized

2.3 - EndpointSlice

EndpointSlice 是实现某 Service 的端点的子集.

apiVersion: discovery.k8s.io/v1

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

EndpointSlice

EndpointSlice 是实现某 Service 的端点的子集。一个 Service 可以有多个 EndpointSlice 对象与之对应, 必须将所有的 EndpointSlice 拼接起来才能形成一套完整的端点集合。Service 通过标签来选择 EndpointSlice。


  • apiVersion:discovery.k8s.io/v1

  • kind:EndpointSlice

  • metadata (ObjectMeta)

    标准的对象元数据。

  • addressType (string), 必需

    addressType 指定当前 EndpointSlice 携带的地址类型。一个 EndpointSlice 只能携带同一类型的地址。 EndpointSlice 对象创建完成后不可以再更改 addressType 字段。 目前支持的地址类型为:

    • IPv4:表示 IPv4 地址。
    • IPv6:表示 IPv6 地址。
    • FQDN:表示完全限定域名。
  • endpoints ([]Endpoint), 必需

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

    endpoints 是当前 EndpointSlice 中一组唯一的端点。每个 EndpointSlice 最多可以包含 1000 个端点。

    端点是实现某 Service 的一个逻辑“后端”。

    • endpoints.addresses ([]string), 必需

      集合:不重复的值在合并期间会被保留

      本端点的地址。此字段的内容会根据对应的 EndpointSlice addressType 字段的值进行解释。 消费者必须根据自身能力处理不同类型的地址。此字段必须至少包含 1 个地址,最多不超过 100 个地址。 假定这些地址都是可替换的,而且客户端也可能选择只用第一个元素。参阅: https://issue.k8s.io/106267

    • endpoints.conditions (EndpointConditions)

      conditions 包含和本端点当前状态有关的信息。

      EndpointConditions 是端点的当前状况。

      • endpoints.conditions.ready (boolean)

        ready 说明此端点已经准备好根据相关的系统映射接收流量。nil 值表示状态未知。 在大多数情况下,消费者应将这种未知状态视为就绪(ready)。 考虑到兼容性,对于正在结束状态下的端点,永远不能将 ready 设置为“true”, 除非正常的就绪行为被显式覆盖,例如当关联的服务设置了 publishNotReadyAddresses 标志时。

      • endpoints.conditions.serving (boolean)

        serving 和 ready 非常相似。唯一的不同在于, 即便某端点的状态为 Terminating 也可以设置 serving。 对于处在终止过程中的就绪端点,此状况应被设置为 “true”。 如果设置为 nil,则消费者应该以 ready 值为准。

      • endpoints.conditions.terminating (boolean)

        terminating 说明当前端点正在终止过程中。nil 值表示状态未知。 消费者应将这种未知状态视为端点并不处于终止过程中。

    • endpoints.deprecatedTopology (map[string]string)

      deprecatedTopology 包含 v1beta1 API 的拓扑信息部分。目前已经弃用了此字段, 移除 v1beta1 API 时(不早于 Kubernetes v1.24)会一起移除此字段。 此字段目前仍然可以存储值,但是不能通过 v1 API 写入数据。 向此字段写入数据的任何尝试都会被忽略,并且不会通知用户。 移除此字段后,可以在 zone 和 nodeName 字段中查看拓扑信息。

    • endpoints.hints (EndpointHints)

      hints 是关于应该如何使用某端点的提示信息。

      EndpointHints 提供应该如何使用某端点的提示信息。

      • endpoints.hints.forZones ([]ForZone)

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

        forZones 表示应该由哪个可用区调用此端点从才能激活拓扑感知路由。

        ForZone 指示应该由哪些可用区调度此端点。

        • endpoints.hints.forZones.name (string), 必需

          name 代表可用区的名称。

    • endpoints.hostname (string)

      此端点的主机名称。端点的使用者可以通过此字段区分各个端点(例如,通过 DNS 域名)。 使用同一主机名称的多个端点应被视为可替换(例如,DNS 中的多个 A 记录)。 必须为小写字母,并且需要通过 DNS Label (RFC 1123) 验证。

    • endpoints.nodeName (string)

      nodeName 是托管此端点的 Node 的名称,使用 nodeName 可以决定 Node 本地有哪些端点。

    • endpoints.targetRef (ObjectReference)

      targetRef 是对代表此端点的 Kubernetes 对象的引用。

    • endpoints.zone (string)

      zone 是此端点所在的可用区(Zone)的名称。

  • ports ([]EndpointPort)

    原子性:合并期间会被替代

    ports 列出了当前 EndpointSlice 中各个端点所暴露的网络端口。每个端口的名称不得重复。 当 ports 列表为空时,表示没有已经指定暴露哪些端口。如果端口值被定义为 nil,表示暴露“所有端口”。 每个 EndpointSlice 最多可以包含 100 个端口。

    EndpointPort 是 EndpointSlice 使用的端口。

    • ports.port (int32)

      port 表示端点的端口号。如果未指定,就不限制端口,且必须根据消费者的具体环境进行解释。

    • ports.protocol (string)

      protocol 表示此端口的 IP 协议。必须为 UDP、TCP 或 SCTP。默认为 TCP。

    • ports.name (string)

      name 表示此端口的名称。EndpointSlice 中所有端口的名称都不得重复。 如果 EndpointSlice 是基于 Kubernetes Service 创建的, 那么此端口的名称和 Service.ports[].name 字段的值一致。默认为空字符串。 名称必须是空字符串,或者必须通过 DNS_LABEL 验证:

      • 最多包含 63 个字符。
      • 必须包含英文小写字母或'-'。
      • 必须以字母开头并以字母结尾。
    • ports.appProtocol (string)

      此端口的应用层协议。字段值被用作提示,允许协议实现为其所理解的协议提供更丰富的行为。 此字段遵循标准的 Kubernetes 标签句法。有效的取值是:

EndpointSliceList

EndpointSliceList 是 EndpointSlice 的列表。


  • apiVersion:discovery.k8s.io/v1

  • kind:EndpointSliceList

  • metadata (ListMeta)

    标准的列表元数据

  • items ([]EndpointSlice), 必需

    items 是 EndpointSlice 列表

操作


get 读取指定的 EndpointSlice

HTTP 请求

GET /apis/discovery.k8s.io/v1/namespaces/{namespace}/endpointslices/{name}

参数

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

    EndpointSlice 的名称

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

    namespace

  • pretty (查询参数):string

    pretty

响应

200 (EndpointSlice):OK

401:Unauthorized

list 列举或监测 EndpointSlice 类别的对象

HTTP 请求

GET /apis/discovery.k8s.io/v1/namespaces/{namespace}/endpointslices

参数

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

    namespace

  • continue (查询参数):string

    continue

  • limit (查询参数):integer

    limit

  • pretty (查询参数):string

    pretty

  • watch (查询参数):boolean

    watch

响应

200 (EndpointSliceList): OK

401:Unauthorized

list 列举或监测 EndpointSlice 类别的对象

HTTP 请求

GET /apis/discovery.k8s.io/v1/endpointslices

参数

  • continue (查询参数):string

    continue

  • limit (查询参数):integer limit
  • pretty (查询参数):string pretty
  • watch (查询参数):boolean

    watch

响应

200 (EndpointSliceList):OK

401:Unauthorized

create 创建 EndpointSlice

HTTP 请求

POST /apis/discovery.k8s.io/v1/namespaces/{namespace}/endpointslices

参数

  • dryRun (查询参数):string

    dryRun

  • pretty (查询参数):string

    pretty

响应

200 (EndpointSlice):OK

201 (EndpointSlice):Created

202 (EndpointSlice):Accepted

401:Unauthorized

update 替换指定的 EndpointSlice

HTTP 请求

PUT /apis/discovery.k8s.io/v1/namespaces/{namespace}/endpointslices/{name}

参数

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

    EndpointSlice 的名称

  • dryRun (查询参数):string

    dryRun

  • pretty (查询参数):string

    pretty

响应

200 (EndpointSlice):OK

201 (EndpointSlice):Created

401:Unauthorized

patch 部分更新指定的 EndpointSlice

HTTP 请求

PATCH /apis/discovery.k8s.io/v1/namespaces/{namespace}/endpointslices/{name}

参数

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

    EndpointSlice 的名称

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

    namespace

  • bodyPatch, 必需

  • dryRun (查询参数):string

    dryRun

  • force (查询参数):boolean

    force

  • pretty (查询参数):string

    pretty

响应

200 (EndpointSlice):OK

201 (EndpointSlice):Created

401:Unauthorized

delete 删除 EndpointSlice

HTTP 请求

DELETE /apis/discovery.k8s.io/v1/namespaces/{namespace}/endpointslices/{name}

参数

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

    EndpointSlice 的名称

  • dryRun (查询参数):string

    dryRun

  • pretty (查询参数):string

    pretty

响应

200 (Status):OK

202 (Status):Accepted

401:Unauthorized

deletecollection 删除 EndpointSlice 的集合

HTTP 请求

DELETE /apis/discovery.k8s.io/v1/namespaces/{namespace}/endpointslices

参数

  • continue (查询参数):string

    continue

  • dryRun (查询参数):string

    dryRun

  • limit (查询参数):integer

    limit

  • pretty (查询参数):string

    pretty

响应

200 (Status):OK

401:Unauthorized

2.4 - Ingress

Ingress 是允许入站连接到达后端定义的端点的规则集合。

apiVersion: networking.k8s.io/v1

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

Ingress

Ingress 是允许入站连接到达后端定义的端点的规则集合。 Ingress 可以配置为向服务提供外部可访问的 URL、负载均衡流量、终止 SSL、提供基于名称的虚拟主机等。


IngressSpec

IngressSpec 描述用户希望存在的 Ingress。


  • defaultBackend (IngressBackend)

    defaultBackend 是负责处理与任何规则都不匹配的请求的后端。 如果未指定 rules,则必须指定 defaultBackend。 如果未设置 defaultBackend,则不符合任何 rules 的请求的处理将由 Ingress 控制器决定。

  • ingressClassName (string)

    ingressClassName 是 IngressClass 集群资源的名称。 Ingress 控制器实现使用此字段来了解它们是否应该通过传递连接(控制器 -> IngressClass -> Ingress 资源)为该 Ingress 资源提供服务。尽管 kubernetes.io/ingress.class 注解(简单的常量名称)从未正式定义, 但它被 Ingress 控制器广泛支持,以在 Ingress 控制器和 Ingress 资源之间创建直接绑定。 新创建的 Ingress 资源应该优先选择使用该字段。但是,即使注解已被正式弃用, 出于向后兼容性的原因,Ingress 控制器仍应能够处理该注解(如果存在)。

  • rules ([]IngressRule)

    Atomic: 将在合并期间被替换

    rules 是用于配置 Ingress 的主机规则列表。如果未指定或没有规则匹配,则所有流量都将发送到默认后端。

    IngressRule 表示将指定主机下的路径映射到相关后端服务的规则。 传入请求首先评估主机匹配,然后路由到与匹配的 IngressRuleValue 关联的后端。

    • rules.host (string)

      host 是 RFC 3986 定义的网络主机的完全限定域名。请注意以下与 RFC 3986 中定义的 URI 的 “host” 部分的偏差:

      1. 不允许 IP。当前 IngressRuleValue 只能应用于父 Ingress Spec 中的 IP。

      2. 由于不允许使用端口,因此不理会 “:” 分隔符。 当前 Ingress 的端口隐式为:

        • :80 用于 http
        • :443 用于 https

      这两种情况在未来都可能发生变化。入站请求在通过 IngressRuleValue 处理之前先进行 host 匹配。 如果主机未指定,Ingress 将根据指定的 IngressRuleValue 规则路由所有流量。

      host 可以是 “精确“ 的,设置为一个不含终止句点的网络主机域名(例如 “foo.bar.com” ), 也可以是一个 “通配符”,设置为以单个通配符标签为前缀的域名(例如 “.foo.com”)。 通配符 “” 必须单独显示为第一个 DNS 标签,并且仅与单个标签匹配。 你不能单独使用通配符作为标签(例如,Host=“*”)。请求将按以下方式与主机字段匹配:

      1. 如果 host 是精确匹配的,则如果 http Host 标头等于 host 值,则请求与此规则匹配。
      2. 如果 host 是用通配符给出的,那么如果 HTTP Host 标头与通配符规则的后缀(删除第一个标签)相同, 则请求与此规则匹配。
    • rules.http (HTTPIngressRuleValue)

      HTTPIngressRuleValue 是指向后端的 http 选择算符列表。例如 http://<host>/<path>?<searchpart> -> 后端, 其中 url 的部分对应于 RFC 3986,此资源将用于匹配最后一个 “/” 之后和第一个 “?” 之前的所有内容或 “#”。

      • rules.http.paths ([]HTTPIngressPath),必需

        Atomic: 将在合并期间被替换

        paths 是一个将请求映射到后端的路径集合。

        HTTPIngressPath 将路径与后端关联。与路径匹配的传入 URL 将转发到后端。

        • rules.http.paths.backend (IngressBackend),必需

          backend 定义将流量转发到的引用服务端点。

        • rules.http.paths.pathType (string),必需

          pathType 决定如何解释 path 匹配。pathType 可以是以下值之一:

          • Exact:与 URL 路径完全匹配。

          • Prefix:根据按 “/” 拆分的 URL 路径前缀进行匹配。 匹配是按路径元素逐个元素完成。路径元素引用的是路径中由“/”分隔符拆分的标签列表。 如果每个 p 都是请求路径 p 的元素前缀,则请求与路径 p 匹配。 请注意,如果路径的最后一个元素是请求路径中的最后一个元素的子字符串,则匹配不成功 (例如 /foo/bar 匹配 /foo/bar/baz,但不匹配 /foo/barbaz)。

          • ImplementationSpecific:路径匹配的解释取决于 IngressClass。 实现可以将其视为单独的路径类型,也可以将其视为前缀或确切的路径类型。 实现需要支持所有路径类型。

        • rules.http.paths.path (string)

          path 要与传入请求的路径进行匹配。 目前,它可以包含 RFC 3986 定义的 URL 的常规 “路径” 部分所不允许的字符。 路径必须以 “/” 开头,并且在 pathType 值为 “Exact” 或 “Prefix” 时必须存在。

  • tls ([]IngressTLS)

    Atomic: 将在合并期间被替换

    tls 表示 TLS 配置。目前,Ingress 仅支持一个 TLS 端口 443。 如果此列表的多个成员指定了不同的主机,如果实现 Ingress 的 Ingress 控制器支持 SNI, 则它们将根据通过 SNI TLS 扩展指定的主机名在同一端口上多路复用。

    IngressTLS 描述与 Ingress 相关的传输层安全性。

    • tls.hosts ([]string)

      Atomic: 将在合并期间被替换

      hosts 是 TLS 证书中包含的主机列表。 此列表中的值必须与 tlsSecret 中使用的名称匹配。 默认为实现此 Ingress 的负载均衡控制器的通配符主机设置(如果未指定)。

    • tls.secretName (string)

      secretName 是用于终止端口 443 上 TLS 通信的 Secret 的名称。 字段是可选的,以允许仅基于 SNI 主机名的 TLS 路由。 如果侦听器中的 SNI 主机与入口规则使用的 “Host” 标头字段冲突,则 SNI 主机用于终止,Host 标头的值用于路由。

IngressBackend

IngressBackend 描述给定服务和端口的所有端点。


  • resource (TypedLocalObjectReference)

    resource 是对 Ingress 对象所在命名空间中另一个 Kubernetes 资源的引用。 如果指定了 resource,则不得指定 service.name 和 service.port。 此字段是一个与 service 互斥的设置。

  • service (IngressServiceBackend)

    service 引用一个 Service 作为后端。此字段是一个与 resource 互斥的设置。

    IngressServiceBackend 引用一个 Kubernetes Service 作为后端。

    • service.name (string),必需

    name 是引用的服务。服务必须与 Ingress 对象位于同一命名空间中。

    • service.port (ServiceBackendPort)

    所引用的服务的端口。IngressServiceBackend 需要端口名或端口号。

    ServiceBackendPort 是被引用的服务的端口。

    • service.port.name (string)

      name 是服务上的端口名称。此字段是一个与 number 互斥的设置。

    • service.port.number (int32)

      number 是服务上的数字形式端口号(例如 80)。此字段是一个与 name 互斥的设置。

IngressStatus

IngressStatus 描述 Ingress 的当前状态。


  • loadBalancer (IngressLoadBalancerStatus)

    loadBalancer 包含负载均衡器的当前状态。

    IngressLoadBalancerStatus 表示负载均衡器的状态。

    • loadBalancer.ingress ([]IngressLoadBalancerIngress)

      ingress 是一个包含负载均衡器入口点的列表。

      IngressLoadBalancerIngress 表示负载均衡器入口点的状态。

      • loadBalancer.ingress.hostname (string)

        hostname 是为基于 DNS 的负载平衡器入口点所设置的主机名。

      • loadBalancer.ingress.ip (string)

        ip 是为基于 IP 的负载平衡器入口点设置的 IP。

      • loadBalancer.ingress.ports ([]IngressPortStatus)

        Atomic: 将在合并期间被替换

        ports 提供有关此 LoadBalancer 公开端口的信息。

        IngressPortStatus 表示服务端口的错误情况

        • loadBalancer.ingress.ports.port (int32),必需

          port 是入栈端口的端口号

        • loadBalancer.ingress.ports.protocol (string),必需

          protocol 是入栈端口的协议。支持的值为:“TCP”、“UDP”、“SCTP”。

        • loadBalancer.ingress.ports.error (string)

          error 用来记录服务端口的问题。错误的格式应符合以下规则:

          • 应在此文件中指定内置错误码,并且错误码应使用驼峰法命名。
          • 特定于云驱动的错误码名称必须符合 foo.example.com/CamelCase 格式。

IngressList

IngressList 是 Ingress 的集合。


  • items ([]Ingress),必需

    items 是 Ingress 的列表。

操作


get 读取指定的 Ingress

HTTP 请求

GET /apis/networking.k8s.io/v1/namespaces/{namespace}/ingresses/{name}

参数

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

    Ingress 的名称。

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (Ingress): OK

401: Unauthorized

get 读取指定 Ingress 状态

HTTP 请求

GET /apis/networking.k8s.io/v1/namespaces/{namespace}/ingresses/{name}/status

参数

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

    Ingress 的名称。

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (Ingress): OK

401: Unauthorized

list 列出或监测 Ingress 类型对象

HTTP 请求

GET /apis/networking.k8s.io/v1/namespaces/{namespace}/ingresses

参数

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

    namespace

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

  • watch (查询参数): boolean

    watch

响应

200 (IngressList): OK

401: Unauthorized

list 列出或监测 Ingress 类型对象

HTTP 请求

GET /apis/networking.k8s.io/v1/ingresses

参数

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

  • watch (查询参数): boolean

    watch

响应

200 (IngressList): OK

401: Unauthorized

create 创建一个 Ingress

HTTP 请求

POST /apis/networking.k8s.io/v1/namespaces/{namespace}/ingresses

参数

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (Ingress): OK

201 (Ingress): Created

202 (Ingress): Accepted

401: Unauthorized

update 替换指定的 Ingress

HTTP 请求

PUT /apis/networking.k8s.io/v1/namespaces/{namespace}/ingresses/{name}

参数

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

    Ingress 的名称。

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

    namespace

  • body: Ingress,必需

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (Ingress): OK

201 (Ingress): Created

401: Unauthorized

update 替换指定 Ingress 的状态

HTTP 请求

PUT /apis/networking.k8s.io/v1/namespaces/{namespace}/ingresses/{name}/status

参数

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

    Ingress 的名称。

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

    namespace

  • body: Ingress,必需

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (Ingress): OK

201 (Ingress): Created

401: Unauthorized

patch 部分更新指定的 Ingress

HTTP 请求

PATCH /apis/networking.k8s.io/v1/namespaces/{namespace}/ingresses/{name}

参数

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

    Ingress 的名称。

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

    namespace

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (Ingress): OK

201 (Ingress): Created

401: Unauthorized

patch 部分更新指定 Ingress 的状态

HTTP 请求

PATCH /apis/networking.k8s.io/v1/namespaces/{namespace}/ingresses/{name}/status

参数

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

    Ingress 的名称。

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

    namespace

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (Ingress): OK

201 (Ingress): Created

401: Unauthorized

delete 删除一个 Ingress

HTTP 请求

DELETE /apis/networking.k8s.io/v1/namespaces/{namespace}/ingresses/{name}

参数

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

    Ingress 的名称。

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

    namespace

  • body: DeleteOptions

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 Ingress 的集合

HTTP 请求

DELETE /apis/networking.k8s.io/v1/namespaces/{namespace}/ingresses

参数

  • dryRun (查询参数): string

    dryRun

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

响应

200 (Status): OK

401: Unauthorized

2.5 - IngressClass

IngressClass 代表 Ingress 的类,被 Ingress 的规约引用。

apiVersion: networking.k8s.io/v1

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

IngressClass

IngressClass 代表 Ingress 的类,被 Ingress 的规约引用。 ingressclass.kubernetes.io/is-default-class 注解可以用来标明一个 IngressClass 应该被视为默认的 Ingress 类。 当某个 IngressClass 资源将此注解设置为 true 时, 没有指定类的新 Ingress 资源将被分配到此默认类。


IngressClassSpec

IngressClassSpec 提供有关 Ingress 类的信息。


  • controller (string)

    controller 是指应该处理此类的控制器名称。 这允许由同一控制器控制不同“口味”。例如,对于同一个实现的控制器你可能有不同的参数。 此字段应该指定为长度不超过 250 个字符的域前缀路径,例如 “acme.io/ingress-controller”。 该字段是不可变的。

  • parameters (IngressClassParametersReference)

    parameters 是指向控制器中包含额外配置的自定义资源的链接。 如果控制器不需要额外的属性,这是可选的。

    IngressClassParametersReference 标识一个 API 对象。这可以用来指定一个集群或者命名空间范围的资源

    • parameters.kind (string),必需

      kind 是被引用资源的类型。

    • parameters.name (string),必需

      name 是被引用资源的名称。

    • parameters.apiGroup (string)

      apiGroup 是被引用资源的组。 如果未指定 apiGroup,则被指定的 kind 必须在核心 API 组中。 对于任何其他第三方类型,apiGroup 是必需的。

    • parameters.namespace (string)

      namespace 是被引用资源的命名空间。 当范围被设置为 “namespace” 时,此字段是必需的; 当范围被设置为 “Cluster” 时,此字段必须不设置。

    • parameters.scope (string)

      scope 表示是否引用集群或者命名空间范围的资源。 这可以设置为“集群”(默认)或者“命名空间”。

IngressClassList

IngressClassList 是 IngressClasses 的集合。


  • apiVersion: networking.k8s.io/v1

  • kind: IngressClassList

  • metadata (ListMeta)

    标准的列表元数据。

  • items ([]IngressClass),必需

    items 是 IngressClasses 的列表。

操作


get 读取指定的 IngressClass

HTTP 请求

GET /apis/networking.k8s.io/v1/ingressclasses/{name}

参数

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

    IngressClass 的名称

  • pretty查询参数):string

    pretty

响应

200 (IngressClass): OK

401: Unauthorized

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

HTTP 请求

GET /apis/networking.k8s.io/v1/ingressclasses

参数

  • continue查询参数):string

    continue

  • limit查询参数):integer

    limit

  • pretty查询参数):string

    pretty

  • watch查询参数):boolean

    watch

响应

200 (IngressClassList): OK

401: Unauthorized

create 创建一个 IngressClass

HTTP 请求

POST /apis/networking.k8s.io/v1/ingressclasses

参数

  • dryRun查询参数):string

    dryRun

  • pretty查询参数):string

    pretty

响应

200 (IngressClass): OK

201 (IngressClass): Created

202 (IngressClass): Accepted

401: Unauthorized

update 替换指定的 IngressClass

HTTP 请求

PUT /apis/networking.k8s.io/v1/ingressclasses/{name}

参数

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

    IngressClass 的名称

  • dryRun查询参数):string

    dryRun

  • pretty查询参数):string

    pretty

响应

200 (IngressClass): OK

201 (IngressClass): Created

401: Unauthorized

patch 部分更新指定的 IngressClass

HTTP 请求

PATCH /apis/networking.k8s.io/v1/ingressclasses/{name}

参数

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

    IngressClass 的名称

  • dryRun查询参数):string

    dryRun

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (IngressClass): OK

201 (IngressClass): Created

401: Unauthorized

delete 删除一个 IngressClass

HTTP 请求

DELETE /apis/networking.k8s.io/v1/ingressclasses/{name}

参数

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

    IngressClass 的名称

  • body: DeleteOptions

  • dryRun查询参数):string

    dryRun

  • pretty查询参数):string

    pretty

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 IngressClass 的集合

DELETE /apis/networking.k8s.io/v1/ingressclasses

参数

  • continue查询参数):string

    continue

  • dryRun查询参数):string

    dryRun

  • limit查询参数):integer

    limit

  • pretty查询参数):string

    pretty

响应

200 (Status): OK

401: Unauthorized

3 - 配置和存储资源

3.1 - ConfigMap

ConfigMap 包含供 Pod 使用的配置数据。

apiVersion: v1

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

ConfigMap

ConfigMap 包含供 Pod 使用的配置数据。


  • apiVersion: v1

  • kind: ConfigMap

  • binaryData (map[string][]byte)

    binaryData 包含二进制数据。 每个键必须由字母、数字、“-”、“_” 或 “.” 组成。 binaryData 可以包含不在 UTF-8 范围中的字节序列。 binaryData 中存储的键不得与 data 字段中的键重叠,这在验证过程中是强制要求。 使用此字段需要 apiserver 和 kubelet 的版本高于 1.10。

  • data (map[string]string)

    data 包含配置数据。 每个键必须由字母、数字、“-”、“_” 或 “.” 组成。 如果值包含非 UTF-8 字节序列,则必须使用 binaryData 字段。 data 中存储的键不得与 binaryData 字段中的键重叠,这在验证过程中是强制要求。

  • immutable (boolean)

    如果 immutable 设为 true, 则确保不会更新 ConfigMap 中存储的数据(只能修改对象元数据)。 如果未设为 true,则可以随时修改此字段。 默认为 nil。

ConfigMapList

ConfigMapList 是包含 ConfigMap 对象列表的资源。


  • apiVersion: v1

  • kind: ConfigMapList

操作


get 读取指定的 ConfigMap

HTTP 请求

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

参数

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

    ConfigMap 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (ConfigMap): OK

401: Unauthorized

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

HTTP 请求

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

参数

响应

200 (ConfigMapList): OK

401: Unauthorized

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

HTTP 请求

GET /api/v1/configmaps

参数

响应

200 (ConfigMapList): OK

401: Unauthorized

create 创建 ConfigMap

HTTP 请求

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

参数

响应

200 (ConfigMap): OK

201 (ConfigMap): Created

202 (ConfigMap): Accepted

401: Unauthorized

update 替换指定的 ConfigMap

HTTP 请求

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

参数

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

    ConfigMap 的名称

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

    namespace

  • body: ConfigMap,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (ConfigMap): OK

201 (ConfigMap): Created

401: Unauthorized

patch 部分更新指定的 ConfigMap

HTTP 请求

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

参数

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

    ConfigMap 的名称

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

    namespace

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (ConfigMap): OK

201 (ConfigMap): Created

401: Unauthorized

delete 删除 ConfigMap

HTTP 请求

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

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 ConfigMap 的集合

HTTP 请求

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

参数

响应

200 (Status): OK

401: Unauthorized

3.2 - Secret

Secret 包含某些类别的秘密数据。

apiVersion: v1

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

Secret

Secret 包含某些类别的秘密数据。 data 字段值的总字节必须小于 MaxSecretSize 字节。


  • apiVersion: v1

  • kind: Secret

  • immutable (boolean)

    如果 immutable 设为 true,则确保不会更新 Secret 中存储的数据(只能修改对象元数据)。 如果未设为 true,则可以随时修改此字段。 默认为 nil。

  • stringData (map[string]string)

    stringData 允许指定字符串格式的非二进制秘密数据。 为了方便起见,它作为只写输入字段提供。 写入时将所有键和值合并到 data 字段,且覆盖任何现有的值。 从 API 读取时绝不会输出 stringData 字段。

  • type (string)

    用于满足程序化方式处理秘密数据。 更多信息: https://kubernetes.io/zh-cn/docs/concepts/configuration/secret/#secret-types

SecretList

SecretList 是 Secret 的列表。


  • apiVersion: v1

  • kind: SecretList

操作


get 读取指定的 Secret

HTTP 请求

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

参数

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

    Secret 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (Secret): OK

401: Unauthorized

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

HTTP 请求

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

参数

响应

200 (SecretList): OK

401: Unauthorized

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

HTTP 请求

GET /api/v1/secrets

参数

响应

200 (SecretList): OK

401: Unauthorized

create 创建 Secret

HTTP 请求

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

参数

响应

200 (Secret): OK

201 (Secret): Created

202 (Secret): Accepted

401: Unauthorized

update 替换指定的 Secret

HTTP 请求

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

参数

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

    Secret 的名称

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

    namespace

  • body: Secret,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (Secret): OK

201 (Secret): Created

401: Unauthorized

patch 部分更新指定的 Secret

HTTP 请求

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

参数

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

    Secret 的名称

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

    namespace

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (Secret): OK

201 (Secret): Created

401: Unauthorized

delete 删除 Secret

HTTP 请求

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

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 Secret 的集合

HTTP 请求

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

参数

响应

200 (Status): OK

401: Unauthorized

3.3 - Volume

Volume 表示 Pod 中一个有名字的卷,可以由 Pod 中的任意容器进行访问。

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

Volume

Volume 表示 Pod 中一个有名字的卷,可以由 Pod 中的任意容器进行访问。


暴露的持久卷

投射

  • configMap (ConfigMapVolumeSource)

    configMap 表示应填充此卷的 configMap。

    将 ConfigMap 适配到一个卷中。目标 ConfigMap 的 data 字段的内容将以文件的形式呈现在一个卷中, 使用 data 字段中的键名作为文件名,除非 items 元素中已经填充了由键名到路径的特定映射。 ConfigMap 卷支持所有权管理和 SELinux 重新打标签。

    • configMap.name (string)

    被引用资源的名称。更多信息: https://kubernetes.io/zh-cn/docs/concepts/overview/working-with-objects/names/#names

    • configMap.optional (boolean)

      optional 指定是否所引用的 ConfigMap 或其键必须已经被定义。

    • configMap.defaultMode (int32)

      defaultMode 是可选的:默认情况下,模式位用于为已创建的文件设置权限。 必须是 0000 到 0777 之间的八进制值或 0 到 511 之间的十进制值。 YAML 既接受八进制值也接受十进制值,JSON 针对模式位需要十进制值。此字段默认为 0644。 路径内的目录不受此设置的影响。这可能与影响文件模式的其他选项(如 fsGroup)有冲突,且结果可以是其他模式位也被设置。

    • configMap.items ([]KeyToPath)

      如果未指定 items,则所引用的 ConfigMap 的 data 字段中的每个键值对将作为一个文件被投射到卷中, 这个文件的名称是键名,而文件的内容是键的取值。 如果指定 items,则所列出的键将被投射到指定的路径中,且不会显示未列出的键。 如果指定的键不在 ConfigMap 中,则卷设置将出错,除非对应的键被标记为可选。 路径必须是相对路径,不能包含 “..” 路径,也不能以 “..” 开头。

  • secret (SecretVolumeSource)

    secret 表示用来填充此卷的 Secret。更多信息: https://kubernetes.io/zh-cn/docs/concepts/storage/volumes#secret

    将 Secret 适配到一个卷中。 目标 Secret 的 data 字段的内容将以文件的形式呈现在一个卷中,使用 data 字段中的键名作为文件名。 Secret 卷支持所有权管理和 SELinux 重新打标签。

    • secret.defaultMode (int32)

      defaultMode 是可选的:默认情况下,模式位用于为已创建的文件设置权限。 必须是 0000 到 0777 之间的八进制值或 0 到 511 之间的十进制值。 YAML 既接受八进制值也接受十进制值,JSON 针对模式位需要十进制值。此字段默认为 0644。 路径内的目录不受此设置的影响。 这可能与影响文件模式的其他选项(如 fsGroup)有冲突,且结果可以是其他模式位也被设置。

    • secret.items ([]KeyToPath)

      如果未指定 items,则所引用的 Secret 的 data 字段中的每个键值对将作为一个文件被投射到卷中, 这个文件的名称是键名,而文件的内容是键的取值。 如果指定 items,则所列出的键将被投射到指定的路径中,且不会显示未列出的键。 如果指定的键不在 Secret 中,则卷设置将出错,除非对应的键被标记为可选。 路径必须是相对路径,不能包含 “..” 路径,也不能以 “..” 开头。

  • downwardAPI (DownwardAPIVolumeSource)

    downwardAPI 表示有关 Pod 的 Downward API,用来填充此卷。

    DownwardAPIVolumeSource 表示包含 Downward API 信息的一个卷。Downward API 卷支持所有权管理和 SELinux 重新打标签。

    • downwardAPI.defaultMode (int32)

      可选:默认情况下,模式位用于已创建的文件。 必须是可选的:默认情况下,模式位用于为已创建的文件设置权限。 必须是 0000 到 0777 之间的八进制值或 0 到 511 之间的十进制值。 YAML 既接受八进制值也接受十进制值,JSON 针对模式位需要十进制值。此字段默认为 0644。 路径内的目录不受此设置的影响。这可能与影响文件模式的其他选项(如 fsGroup)有冲突,且结果可以是其他模式位也被设置。

    • downwardAPI.items ([]DownwardAPIVolumeFile)

      items 是 Downward API 卷文件的列表。

  • projected (ProjectedVolumeSource)

    这是供 Secret、ConfigMap 和 Downward API 等所有资源使用的投射项。

    表示一个投射的卷源。

    • projected.defaultMode (int32)

      defaultMode 是默认情况下用于为已创建的文件设置权限的模式位。 必须是 0000 到 0777 之间的八进制值或 0 到 511 之间的十进制值。 YAML 既接受八进制值也接受十进制值,JSON 针对模式位需要十进制值。 路径内的目录不受此设置的影响。 这可能与影响文件模式的其他选项(如 fsGroup)有冲突,且结果可以是其他模式位也被设置。

    • projected.sources ([]VolumeProjection)

      sources 是卷投射的列表。

      这里的投射项目可能与其他受支持的卷类型一起进行投射。

      • projected.sources.configMap (ConfigMapProjection)

        与要投射的 ConfigMap 数据有关的 ConfigMap 信息。

        将 ConfigMap 适配到一个投射的卷中。 目标 ConfigMap 的 Data 字段的内容将以文件的形式呈现在一个被投射的卷中, 使用 data 字段中的键名作为文件名,除非 items 元素中已经填充了由键名到路径的特定映射。 请注意,这等同于没有默认模式的 ConfigMap 卷源。

        • projected.sources.configMap.items ([]KeyToPath)

          如果未指定 items,则所引用的 ConfigMap 的 data 字段中的每个键值对将作为一个文件被投射到卷中, 这个文件的名称是键名,而文件的内容是键的取值。 如果指定 items,则所列出的键将被投射到指定的路径中,且不会显示未列出的键。 如果指定的键不在 ConfigMap 中,则卷设置将出错,除非对应的键被标记为可选。 路径必须是相对路径,不能包含 “..” 路径,也不能以 “..” 开头。

      • projected.sources.downwardAPI (DownwardAPIProjection)

        与要投射的 downward API 数据有关的 downward API 信息。

        表示投射到投射卷的 Downward API 信息。请注意,这等同于没有默认模式的 downwardAPI 卷源。

        • projected.sources.downwardAPI.items ([]DownwardAPIVolumeFile)

          items 是 DownwardAPIVolume 文件的列表。

      • projected.sources.secret (SecretProjection)

        与要投射的 Secret 数据有关的 Secret 信息。

        将 Secret 适配到一个投射卷中。 目标 Secret 的 data 字段的内容将以文件的形式呈现在一个投射卷中,使用 data 字段中的键名作为文件名。 请注意,这等同于没有默认模式的 Secret 卷源。

        • projected.sources.secret.optional (boolean)

          optional 字段指定是否 Secret 或其键必须已经定义。

        • projected.sources.secret.items ([]KeyToPath)

          如果未指定 items,则所引用的 Secret 的 data 字段中的每个键值对将作为一个文件被投射到卷中, 这个文件的名称是键名,而文件的内容是键的取值。 如果指定 items,则所列出的键将被投射到指定的路径中,且不会显示未列出的键。 如果指定的键不在 Secret 中,则卷设置将出错,除非对应的键被标记为可选。 路径必须是相对路径,不能包含 “..” 路径,也不能以 “..” 开头。

      • projected.sources.serviceAccountToken (ServiceAccountTokenProjection)

        serviceAccountToken 是与要投射的服务账号令牌数据有关的信息。

        ServiceAccountTokenProjection 表示一个投射的服务账号令牌卷。 这种投射可用于将服务账号令牌插入到 Pod 运行时文件系统,供访问 API(Kubernetes API Server 或其他)使用。

        • projected.sources.serviceAccountToken.path (string),必需

          path 是相对于令牌投射目标文件的挂载点的路径。

        • projected.sources.serviceAccountToken.audience (string)

          audience 是令牌的目标受众。 令牌的接收方必须用令牌受众中指定的一个标识符来标识自己,否则应拒绝此令牌。 受众默认为 apiserver 的标识符。

        • projected.sources.serviceAccountToken.expirationSeconds (int64)

          expirationSeconds 是所请求的服务账号令牌的有效期。 当令牌即将到期时,kubelet 卷插件将主动轮换服务账号令牌。 如果令牌超过其生存时间的 80% 或令牌超过 24 小时,kubelet 将开始尝试轮换令牌。 默认为 1 小时且必须至少为 10 分钟。

本地/临时目录

持久卷

  • awsElasticBlockStore (AWSElasticBlockStoreVolumeSource)

    awsElasticBlockStore 表示挂接到 kubelet 的主机随后暴露给 Pod 的一个 AWS Disk 资源。更多信息: https://kubernetes.io/zh-cn/docs/concepts/storage/volumes#awselasticblockstore

    表示 AWS 上的 Persistent Disk 资源。挂载到一个容器之前 AWS EBS 磁盘必须存在。 该磁盘还必须与 kubelet 位于相同的 AWS 区域中。AWS EBS 磁盘只能以读/写一次进行挂载。 AWS EBS 卷支持所有权管理和 SELinux 重新打标签。

    • awsElasticBlockStore.partition (int32)

      partition 是你要挂载的卷中的分区。如果省略,则默认为按卷名称进行挂载。例如:对于卷 /dev/sda1, 将分区指定为 “1”。类似地,/dev/sda 的卷分区为 “0”(或可以将属性留空)。

    • awsElasticBlockStore.readOnly (boolean)

      readOnly 值为 true 将使得卷挂载被强制设置为 readOnly。更多信息: https://kubernetes.io/zh-cn/docs/concepts/storage/volumes#awselasticblockstore

  • azureDisk (AzureDiskVolumeSource)

    azureDisk 表示挂载到主机上并绑定挂载到 Pod 上的 Azure 数据盘。

    azureDisk 表示挂载到主机上并绑定挂载到 Pod 上的 Azure 数据盘。

    • azureDisk.diskName (string),必需

      diskName 是 Blob 存储中数据盘的名称。

    • azureDisk.diskURI (string),必需

      diskURI 是 Blob 存储中数据盘的 URI。

    • azureDisk.cachingMode (string)

      cachingMode 是主机缓存(Host Caching)模式:None、Read Only、Read Write。

    • azureDisk.fsType (string)

      fsType 是要挂载的文件系统类型。必须是主机操作系统所支持的文件系统类型之一。 例如 “ext4”、“xfs”、“ntfs”。如果未指定,则隐式推断为 “ext4”。

    • azureDisk.kind (string)

      kind 预期值包括:

      • Shared:每个存储帐户多个 Blob 磁盘;
      • Dedicated:每个存储帐户单个 Blob 磁盘;
      • Managed:azure 托管的数据盘(仅托管的可用性集合中)。

      默认为 Shared。

    • azureDisk.readOnly (boolean)

      readOnly 默认为 false(读/写)。此处的 readOnly 将强制设置卷挂载中的 readOnly 属性。

  • azureFile (AzureFileVolumeSource)

    azureDisk 表示挂载到主机上并绑定挂载到 Pod 上的 Azure File Service。

    azureFile 表示挂载到主机上并绑定挂载到 Pod 上的 Azure File Service。

    • azureFile.secretName (string),必需

      secretName 是包含 Azure 存储账号名称和主键的 Secret 的名称。

    • azureFile.shareName (string),必需

      shareName 是 Azure 共享名称。

    • azureFile.readOnly (boolean)

      readOnly 默认为 false(读/写)。此处的 readOnly 将强制设置卷挂载中的 readOnly 属性。

  • cinder (CinderVolumeSource)

    cinder 表示 kubelet 主机上挂接和挂载的 Cinder 卷。更多信息: https://examples.k8s.io/mysql-cinder-pd/README.md

    表示 Openstack 中的一个 Cinder 卷资源。挂载到一个容器之前 Cinder 卷必须已经存在。 该卷还必须与 kubelet 位于相同的地区中。cinder 卷支持所有权管理和 SELinux 重新打标签。

    • cinder.fsType (string)

      fsType 是要挂载的文件系统类型。必须是主机操作系统所支持的文件系统类型之一。例如:“ext4”、“xfs”、“ntfs”。 如果未指定,则隐式推断为“ext4”。更多信息: https://examples.k8s.io/mysql-cinder-pd/README.md

    • cinder.readOnly (boolean)

      readOnly 默认为 false(读/写)。此处的 readOnly 将强制设置卷挂载中的 readOnly 属性。 更多信息: https://examples.k8s.io/mysql-cinder-pd/README.md

    • cinder.secretRef (LocalObjectReference)

      secretRef 是可选的。指向 Secret 对象,内含的参数用于连接到 OpenStack。

  • csi (CSIVolumeSource)

    csi 表示由某个外部容器存储接口(Container Storage Interface,CSI)驱动处理的临时存储(Beta 特性)。

    表示要挂载的卷的源位置,由外部 CSI 驱动进行管理。

    • csi.driver (string),必需

      driver 是处理此卷的 CSI 驱动的名称。咨询你的管理员以获取在集群中注册的正确名称。

    • csi.fsType (string)

      要挂载的 fsType。例如 “ext4”、“xfs”、“ntfs”。 如果未提供,则将空值传递给关联的 CSI 驱动,以便决定要应用的默认文件系统。

    • csi.nodePublishSecretRef (LocalObjectReference)

      nodePublishSecretRef 是对包含敏感信息的 Secret 对象的引用, 该 Secret 对象将被传递到 CSI 驱动以完成 CSI NodePublishVolume 和 NodeUnpublishVolume 调用。 此字段是可选的,如果不需要 Secret,则此字段可以为空。 如果 Secret 对象包含多个 Secret,则所有 Secret 引用将被传递。

    • csi.readOnly (boolean)

      readOnly 指定供卷使用的只读配置。默认为 false(读/写)。

    • csi.volumeAttributes (map[string]string)

      volumeAttributes 存储传递给 CSI 驱动且特定于驱动的属性。查阅你的驱动文档,了解支持的值。

  • ephemeral (EphemeralVolumeSource)

    ephemeral 表示由一个集群存储驱动处理的卷。此卷的生命周期与定义该卷的 Pod 相关联。 Pod 启动前创建此卷,Pod 移除时删除此卷。

    使用此字段的情形包括: a) 仅在 Pod 运行时才需要此卷, b) 需要从快照恢复或容量跟踪等正常卷的功能特性, c) 通过存储类指定存储驱动,以及 d) 存储驱动支持通过 PersistentVolumeClaim 进行动态卷制备 (有关此卷类型和 PersistentVolumeClaim 之间连接的更多信息,请参考 EphemeralVolumeSource)。

    对于持续时间超过单个 Pod 生命周期的卷,使用 PersistentVolumeClaim 或某种特定于供应商的 API。

    如果打算以这种方式使用 CSI 驱动,则将 CSI 用于轻量级本地临时卷。更多的相关信息,请参考驱动文档。

    一个 Pod 可以同时使用临时卷和持久卷这两种类别的卷。

    表示由一个正常存储驱动处理的临时卷。

    • ephemeral.volumeClaimTemplate (PersistentVolumeClaimTemplate)

      将用于创建独立的 PVC 以制备卷。 嵌入了 EphemeralVolumeSource 的 Pod 将是 PVC 的所有者,即 PVC 将与 Pod 一起删除。 PVC 的名称将是 <pod 名称>-<卷名称>,其中 <卷名称> 是来自 PodSpec.Volumes 数组条目的名称。 如果串联的名称对于 PVC 无效(例如太长),则 Pod 验证将拒绝该 Pod。

      如果具有此名称的现有 PVC 不属于此 Pod,则这一 PVC 将 不会 被用于此 Pod,以避免错误地使用不相关的卷。 如果出现这种情况,Pod 的启动操作会被阻塞直到不相关的 PVC 被移除。 如果 Pod 准备使用这样一个预先创建的 PVC,那么一旦此 Pod 出现,就必须更新 PVC, 将其属主引用指向该 Pod。通常没有必要这样做,但这对手动重构损坏的集群时可能很有用。

      此字段是只读的,PVC 被创建后 Kubernetes 不会对其进行任何更改。

      必需,不能为 nil。

      PersistentVolumeClaimTemplate 用于作为 EphemeralVolumeSource 的一部分生成 PersistentVolumeClaim 对象。

      • ephemeral.volumeClaimTemplate.spec (PersistentVolumeClaimSpec),必需

        PersistentVolumeClaim 的规约。整个规约的内容将被原封不动地复制到从此模板创建的 PVC 中。 与 PersistentVolumeClaim 相同的字段在此处也有效。

      • ephemeral.volumeClaimTemplate.metadata (ObjectMeta)

        可能包含一些标签和注解,在创建 PVC 时,这些数据会被复制到 PVC 中。 在验证期间,其他字段都不允许设置,即便设置也会在验证阶段被拒绝。

  • fc (FCVolumeSource)

    fc 表示挂接到 kubelet 的主机随后暴露给 Pod 的一个 Fibre Channel 资源。

    表示 Fibre Channel 卷。Fibre Channel 卷只能以读/写一次进行挂载。 Fibre Channel 卷支持所有权管理和 SELinux 重新打标签。

    • fc.fsType (string)

      fsType 是要挂载的文件系统类型。必须是主机操作系统所支持的文件系统类型之一。 例如 “ext4”、“xfs”、“ntfs”。如果未指定,则隐式推断为 “ext4”。

    • fc.lun (int32)

      lun 是可选的:FC 目标 lun 编号。

    • fc.readOnly (boolean)

      readOnly 是可选的。默认为 false(读/写)。此处的 readOnly 将强制设置卷挂载中的 readOnly 属性。

    • fc.targetWWNs ([]string)

      targetWWNs 是可选的。FC 目标全球名称(WWN)。

    • fc.wwids ([]string)

      wwids 是可选的。FC 卷全球识别号(wwids)。 必须设置 wwids 或 targetWWNs 及 lun 的组合,但不能同时设置两者。

  • flexVolume (FlexVolumeSource)

    flexVolume 表示使用基于 exec 的插件制备/挂接的通用卷资源。

    flexVolume 表示使用基于 exec 的插件制备/挂接的通用卷资源。

    • flexVolume.driver (string),必需

      driver 是供此卷使用的驱动的名称。

    • flexVolume.fsType (string)

      fsType 是要挂载的文件系统类型。必须是主机操作系统所支持的文件系统类型之一。例如 “ext4”、“xfs”、“ntfs”。 默认的文件系统取决于 flexVolume 脚本。

    • flexVolume.options (map[string]string)

      options 是可选的。此字段包含额外的命令选项(如果有)。

    • flexVolume.readOnly (boolean)

      readOnly 是可选的。默认为 false(读/写)。此处的 readOnly 将强制设置卷挂载中的 readOnly 属性。

    • flexVolume.secretRef (LocalObjectReference)

      secretRef 是可选的。secretRef 是对包含敏感信息的 Secret 对象的引用,该 Secret 会被传递到插件脚本。 如果未指定 Secret 对象,则此字段可以为空。如果 Secret 对象包含多个 Secret,则所有 Secret 被传递到插件脚本。

  • flocker (FlockerVolumeSource)

    flocker 表示挂接到一个 kubelet 主机的 Flocker 卷。Flocker 卷依赖于正在运行的 Flocker 控制服务。

    表示 Flocker 代理挂载的 Flocker 卷。应设置一个且仅设置 datasetName 和 datasetUUID 中的一个。 Flocker 卷不支持所有权管理或 SELinux 重新打标签。

    • flocker.datasetName (string)

      datasetName 是存储为元数据的数据集的名称。Flocker 数据集的名称应视为已弃用。

    • flocker.datasetUUID (string)

      datasetUUID 是数据集的 UUID。这是 Flocker 数据集的唯一标识符。

  • iscsi (ISCSIVolumeSource)

    iscsi 表示挂接到 kubelet 的主机随后暴露给 Pod 的一个 ISCSI Disk 资源。更多信息: https://examples.k8s.io/volumes/iscsi/README.md

    表示一个 ISCSI 磁盘。ISCSI 卷只能以读/写一次进行挂载。ISCSI 卷支持所有权管理和 SELinux 重新打标签。

    • iscsi.iqn (string),必需

      iqn 是目标 iSCSI 限定名称。

    • iscsi.lun (int32),必需

      lun 表示 iSCSI 目标逻辑单元号。

    • iscsi.targetPortal (string),必需

      targetPortal 是 iSCSI 目标门户。 如果不是默认端口(通常是 TCP 端口 860 和 3260),则 Portal 为 IP 或 ip_addr:port。

    • iscsi.chapAuthDiscovery (boolean)

      chapAuthDiscovery 定义是否支持 iSCSI Discovery CHAP 身份认证。

    • iscsi.chapAuthSession (boolean)

      chapAuthSession 定义是否支持 iSCSI Session CHAP 身份认证。

    • iscsi.fsType (string)

      fsType 是你要挂载的卷的文件系统类型。提示:确保主机操作系统支持此文件系统类型。 例如:“ext4”、“xfs”、“ntfs”。如果未指定,则隐式推断为 “ext4”。更多信息: https://kubernetes.io/zh-cn/docs/concepts/storage/volumes#iscsi

    • iscsi.initiatorName (string)

      initiatorName 是自定义的 iSCSI 发起程序名称(iSCSI Initiator Name)。 如果同时用 iscsiInterface 指定 initiatorName,将为连接创建新的 iSCSI 接口 <目标门户>:<卷名称>。

    • iscsi.iscsiInterface (string)

      iscsiInterface 是使用 iSCSI 传输的接口名称。默认为 “default”(tcp)。

    • iscsi.portals ([]string)

      portals 是 iSCSI 目标门户列表(iSCSI Target Portal List)。 如果不是默认端口(通常是 TCP 端口 860 和 3260),则 Portal 为 IP 或 ip_addr:port。

    • iscsi.readOnly (boolean)

      此处的 readOnly 将强制设置卷挂载中的 readOnly 属性。默认为 false。

    • iscsi.secretRef (LocalObjectReference)

      secretRef 是 iSCSI 目标和发起程序身份认证所用的 CHAP Secret。

  • photonPersistentDisk (PhotonPersistentDiskVolumeSource)

    photonPersistentDisk 表示 kubelet 主机上挂接和挂载的 PhotonController 持久磁盘。

    表示 Photon Controller 持久磁盘资源。

    • photonPersistentDisk.pdID (string),必需

      pdID 是标识 Photon Controller 持久磁盘的 ID。

    • photonPersistentDisk.fsType (string)

      fsType 是要挂载的文件系统类型。必须是主机操作系统所支持的文件系统类型之一。 例如 “ext4”、“xfs”、“ntfs”。如果未指定,则隐式推断为 “ext4”。

  • portworxVolume (PortworxVolumeSource)

    portworxVolume 表示 kubelet 主机上挂接和挂载的 portworx 卷。

    PortworxVolumeSource 表示 Portworx 卷资源。

    • portworxVolume.volumeID (string),必需

      volumeID 唯一标识 Portworx 卷。

    • portworxVolume.fsType (string)

      fSType 表示要挂载的文件系统类型。必须是主机操作系统支持的文件系统类型。例如 “ext4”、“xfs”。 如果未指定,则隐式推断为 “ext4”。

    • portworxVolume.readOnly (boolean)

      readOnly 默认为 false(读/写)。此处的 readOnly 将强制设置卷挂载中的 readOnly 属性。

  • quobyte (QuobyteVolumeSource)

    quobyte 表示在共享 Pod 生命周期的主机上挂载的 Quobyte。

    表示在 Pod 的生命周期内持续的 Quobyte 挂载。Quobyte 卷不支持所有权管理或 SELinux 重新打标签。

    • quobyte.registry (string),必需

      registry 表示将一个或多个 Quobyte Registry 服务指定为 host:port 对的字符串形式 (多个条目用英文逗号分隔),用作卷的中央注册表。

    • quobyte.volume (string),必需

      volume 是按名称引用已创建的 Quobyte 卷的字符串。

    • quobyte.group (string)

      group 是将卷访问映射到的组。默认为无组。

    • quobyte.readOnly (boolean)

      此处 readOnly 将强制使用只读权限挂载 Quobyte 卷。默认为 false。

    • quobyte.tenant (string)

      tenant 拥有 Backend Used 中给定的 Quobyte 卷,随动态制备的 Quobyte 卷一起使用,值由插件设置。

    • quobyte.user (string)

      user 是将卷访问映射到的用户。默认为 serivceaccount 用户。

  • scaleIO (ScaleIOVolumeSource)

    scaleIO 表示 Kubernetes 节点上挂接和挂载的 ScaleIO 持久卷。

    ScaleIOVolumeSource 表示一个 ScaleIO 持久卷。

    • scaleIO.gateway (string),必需

      gateway 是 ScaleIO API 网关的主机地址。

    • scaleIO.secretRef (LocalObjectReference),必需

      secretRef 引用到 ScaleIO 用户的 Secret 和其他敏感信息。如果未提供此项,则 Login 操作将失败。

    • scaleIO.system (string),必需

      system 是存储系统的名称,与 ScaleIO 中的配置相同。

    • scaleIO.fsType (string)

      fsType 是要挂载的文件系统类型。必须是主机操作系统所支持的文件系统类型之一。例如 “ext4”、“xfs”、“ntfs”。默认为 “xfs”。

    • scaleIO.protectionDomain (string)

      protectionDomain 是 ScaleIO 保护域(ScaleIO Protection Domain)的名称,用于已配置的存储。

    • scaleIO.readOnly (boolean)

      readOnly 默认为 false(读/写)。此处的 readOnly 将强制设置卷挂载中的 readOnly 属性。

    • scaleIO.sslEnabled (boolean)

      sslEnabled 标志启用/禁用与网关的 SSL 通信,默认为 false。

    • scaleIO.storageMode (string)

      storageMode 指示卷所用的存储应是 ThickProvisioned 或 ThinProvisioned。默认为 ThinProvisioned。

    • scaleIO.storagePool (string)

      storagePool 是与保护域关联的 ScaleIO Storage Pool。

    • scaleIO.volumeName (string)

      volumeName 是在与此卷源关联的 ScaleIO 系统中已创建的卷的名称。

  • storageos (StorageOSVolumeSource)

    storageOS 表示 Kubernetes 节点上挂接和挂载的 StorageOS 卷。

    表示 StorageOS 持久卷资源。

    • storageos.fsType (string)

      fsType 是要挂载的文件系统类型。必须是主机操作系统所支持的文件系统类型之一。 例如 “ext4”、“xfs”、“ntfs”。如果未指定,则隐式推断为 “ext4”。

    • storageos.readOnly (boolean)

      readOnly 默认为 false(读/写)。此处的 readOnly 将强制设置卷挂载中的 readOnly 属性。

    • storageos.secretRef (LocalObjectReference)

      secretRef 指定用于获取 StorageOS API 凭据的 Secret。如果未指定,则将尝试使用默认值。

    • storageos.volumeName (string)

      volumeName 是 StorageOS 卷的人类可读名称。这些卷名称在一个名字空间内是唯一的。

    • storageos.volumeNamespace (string)

      volumeNamespace 指定 StorageOS 内卷的作用域。如果未指定名字空间,则将使用 Pod 的名字空间。 这个设置使得 Kubernetes 的名字作用域可以在 StorageOS 内进行映射,实现更紧密的集成。 将 volumeName 设为任何名称以重载默认的行为。如果你未在 StorageOS 内使用名字空间,则设为“default”。 将创建 StorageOS 内预先不存在的名字空间。

  • vsphereVolume (VsphereVirtualDiskVolumeSource)

    vsphereVolume 表示 kubelet 主机上挂接和挂载的 vSphere 卷。

    表示 vSphere 卷资源。

    • vsphereVolume.volumePath (string),必需

      volumePath 是标识 vSphere 卷 vmdk 的路径。

    • vsphereVolume.fsType (string)

      fsType 是要挂载的文件系统类型。必须是主机操作系统所支持的文件系统类型之一。 例如 “ext4”、“xfs”、“ntfs”。如果未指定,则隐式推断为 “ext4”。

    • vsphereVolume.storagePolicyID (string)

      storagePolicyID 是与 StoragePolicyName 关联的基于存储策略的管理(SPBM)配置文件 ID。

    • vsphereVolume.storagePolicyName (string)

      storagePolicyName 是基于存储策略的管理(SPBM)配置文件名称。

已弃用

  • gitRepo (GitRepoVolumeSource)

    gitRepo 表示特定修订版本的 git 仓库。(注意:GitRepo 已被弃用。)如果与为某容器提速 Git 仓库, 可以先将 emptyDir 挂载到 InitContainer 上,由后者使用 git 克隆仓库,然后将 emptyDir 挂载到 Pod 的容器中。

    表示用 Git 仓库的内容进行填充的一个卷。Git 仓库卷不支持所有权管理。Git 仓库卷支持 SELinux 重新打标签。 (注意:GitRepo 已被弃用。)如果与为某容器提速 Git 仓库, 可以先将 emptyDir 挂载到 InitContainer 上,由后者使用 git 克隆仓库,然后将 emptyDir 挂载到 Pod 的容器中。

    • gitRepo.repository (string),必需

      repository 是仓库的 URL。

    • gitRepo.directory (string)

      directory 是目标目录的名称。不得包含 “..” 或以 “..” 开头。如果提供了 “.”,则卷目录将是 Git 仓库。 否则,如果指定,卷将用给定名称的子目录中存放 Git 仓库。

    • gitRepo.revision (string)

      revision 是指定修订版本的提交哈希值。

DownwardAPIVolumeFile

DownwardAPIVolumeFile 表示创建包含 Pod 字段的文件的信息。


  • path (string),必需

    必需。path 是要创建的文件的相对路径名称。不得使用绝对路径,也不得包含 “..” 路径。 必须用 UTF-8 进行编码。相对路径的第一项不得用 “..” 开头。

  • fieldRef (ObjectFieldSelector)

    必需。选择 Pod 的字段:仅支持注解、标签、名称和名字空间。

  • mode (int32)

    可选:模式位用于设置文件的权限,必须是 0000 到 0777 之间的八进制值或 0 到 511 之间的十进制值。 YAML 既接受八进制值也接受十进制值,JSON 针对模式位需要十进制值。 如果未指定,则将使用卷 defaultMode。 这可能与影响文件模式的其他选项(如 fsGroup)有冲突,且结果可以是其他模式位也被设置。

  • resourceFieldRef (ResourceFieldSelector)

    选择容器的资源:目前仅支持资源限制与请求(limits.cpu、limits.memory、requests.cpu 和 requests.memory)。

KeyToPath

将一个字符串键映射到卷中的一个路径。


  • key (string),必需

    key 是要投射的键。

  • path (string),必需

    path 是将键映射到的文件的相对路径。不能是绝对路径。不能包含路径元素 “..”。不能以字符串 “..” 开头。

  • mode (int32)

    mode 是可选的:模式位用于为文件设置权限。必须是 0000 到 0777 之间的八进制值或 0 到 511 之间的十进制值。 YAML 既接受八进制值也接受十进制值,JSON 针对模式位需要十进制值。 如果未指定,则将使用卷 defaultMode。 这可能与影响文件模式的其他选项(如 fsGroup)有冲突,且结果可以是其他模式位也被设置。

3.4 - PersistentVolumeClaim

PersistentVolumeClaim 是用户针对一个持久卷的请求和申领。

apiVersion: v1

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

PersistentVolumeClaim

PersistentVolumeClaim 是用户针对一个持久卷的请求和申领。


  • apiVersion: v1

  • kind: PersistentVolumeClaim

PersistentVolumeClaimSpec

PersistentVolumeClaimSpec 描述存储设备的常用参数,并支持通过 source 来设置特定于提供商的属性。


  • resources (ResourceRequirements)

    resources 表示卷应拥有的最小资源。 如果启用了 RecoverVolumeExpansionFailure 功能特性,则允许用户指定这些资源要求, 此值必须低于之前的值,但必须高于申领的状态字段中记录的容量。更多信息: https://kubernetes.io/zh-cn/docs/concepts/storage/persistent-volumes#resources

    ResourceRequirements 描述计算资源要求。

    • resources.claims ([]ResourceClaim)

      集合:键 name 的唯一值将在合并期间被保留

      claims 列出了此容器使用的、在 spec.resourceClaims 中定义的资源的名称。

      这是一个 Alpha 字段,需要启用 DynamicResourceAllocation 特性门控。

      此字段是不可变的。

      <a name="ResourceClaim"></a>
      

      ResourceClaim 引用 PodSpec.ResourceClaims 中的一个条目。

      • resources.claims.name (string),必需

        对于使用此字段的 Pod,name 必须与 pod.spec.resourceClaims 中的一个条目的名称匹配。

    limits 描述允许的最大计算资源量。更多信息: https://kubernetes.io/zh-cn/docs/concepts/configuration/manage-resources-containers/

  • volumeName (string)

    volumeName 是对此申领所对应的 PersistentVolume 的绑定引用。

  • storageClassName (string)

    storageClassName 是此申领所要求的 StorageClass 名称。更多信息: https://kubernetes.io/zh-cn/docs/concepts/storage/persistent-volumes#class-1

  • volumeMode (string)

    volumeMode 定义申领需要哪种类别的卷。当申领规约中未包含此字段时,意味着取值为 Filesystem。

Beta 级别

  • dataSource (TypedLocalObjectReference)

    dataSource 字段可用于二选一:

    • 现有的 VolumeSnapshot 对象(snapshot.storage.k8s.io/VolumeSnapshot)

    • 现有的 PVC (PersistentVolumeClaim)

    如果制备器或外部控制器可以支持指定的数据源,则它将根据指定数据源的内容创建新的卷。 当 AnyVolumeDataSource 特性门控被启用时,dataSource 内容将被复制到 dataSourceRef, 当 dataSourceRef.namespace 未被指定时,dataSourceRef 内容将被复制到 dataSource。 如果名字空间被指定,则 dataSourceRef 不会被复制到 dataSource。

  • dataSourceRef (TypedObjectReference)

    dataSourceRef 指定一个对象,当需要非空卷时,可以使用它来为卷填充数据。 此字段值可以是来自非空 API 组(非核心对象)的任意对象,或一个 PersistentVolumeClaim 对象。 如果设置了此字段,则仅当所指定对象的类型与所安装的某些卷填充器或动态制备器匹配时,卷绑定才会成功。 此字段将替换 dataSource 字段的功能,因此如果两个字段非空,其取值必须相同。 为了向后兼容,当未在 dataSourceRef 中指定名字空间时, 如果(dataSource 和 dataSourceRef)其中一个字段为空且另一个字段非空,则两个字段将被自动设为相同的值。 在 dataSourceRef 中指定名字空间时,dataSource 未被设置为相同的值且必须为空。 dataSource 和 dataSourceRef 之间有三个重要的区别:

    • dataSource 仅允许两个特定类型的对象,而 dataSourceRef 允许任何非核心对象以及 PersistentVolumeClaim 对象。
    • dataSource 忽略不允许的值(这类值会被丢弃),而 dataSourceRef 保留所有值并在指定不允许的值时产生错误。
    • dataSource 仅允许本地对象,而 dataSourceRef 允许任意名字空间中的对象。

    (Beta) 使用此字段需要启用 AnyVolumeDataSource 特性门控。 (Alpha) 使用 dataSourceRef 的名字空间字段需要启用 CrossNamespaceVolumeDataSource 特性门控。

    • dataSourceRef.kind (string),必需

    kind 是正被引用的资源的类型。

    • dataSourceRef.name (string),必需

      name 是正被引用的资源的名称。

    • dataSourceRef.apiGroup (string)

    apiGroup 是正被引用的资源的组。如果 apiGroup 未被指定,则指定的 kind 必须在核心 API 组中。 对于任何第三方类型,apiGroup 是必需的。

    • dataSourceRef.namespace (string)

      namespace 是正被引用的资源的名字空间。请注意,当指定一个名字空间时, 在引用的名字空间中 gateway.networking.k8s.io/ReferenceGrant 对象是必需的, 以允许该名字空间的所有者接受引用。有关详细信息,请参阅 ReferenceGrant 文档。 (Alpha) 此字段需要启用 CrossNamespaceVolumeDataSource 特性门控。

PersistentVolumeClaimStatus

PersistentVolumeClaimStatus 是持久卷申领的当前状态。


  • allocatedResourceStatuses (map[string]string)

    allocatedResourceStatuses 存储为给定 PVC 而调整大小的资源的状态。键名遵循标准的 Kubernetes 标签语法。 有效值为:

    • 未加前缀的键:
      • storage - 卷的容量。
    • 自定义资源必须使用实现定义的带前缀的名称,如 "example.com/my-custom-resource"。 除上述值之外,未加前缀或具有 kubernetes.io 前缀的键被视为保留键,因此不能使用。

    ClaimResourceStatus 可以处于以下任一状态:

    • ControllerResizeInProgress:大小调整控制器开始在控制平面中调整卷大小时所设置的状态。
    • ControllerResizeFailed:大小调整控制器出现致命错误导致大小调整失败时所设置的状态。
    • NodeResizePending:大小调整控制器已完成对卷大小的调整但需要在节点上进一步调整卷大小时的状态。
    • NodeResizeInProgress:kubelet 开始调整卷大小时所设置的状态。
    • NodeResizeFailed:kubelet 在出现致命错误而导致大小调整失败时所设置的状态。 临时错误不会设置 NodeResizeFailed。

    例如:如果扩展 PVC 以获取更多的容量,则此字段可以是以下状态之一:

    • pvc.status.allocatedResourceStatus['storage'] = "ControllerResizeInProgress"
      • pvc.status.allocatedResourceStatus['storage'] = "ControllerResizeFailed"
      • pvc.status.allocatedResourceStatus['storage'] = "NodeResizePending"
      • pvc.status.allocatedResourceStatus['storage'] = "NodeResizeInProgress"
      • pvc.status.allocatedResourceStatus['storage'] = "NodeResizeFailed" 当未设置此字段时,表示没有针对给定 PVC 执行大小调整操作。

    如果控制器收到具有先前未知的 resourceName 或 ClaimResourceStatus 的 PVC 更新, 则该控制器应忽略此项更新才能按预期工作。例如,仅负责调整卷容量大小的控制器应忽略更改与 PVC 关联的其他合法资源的 PVC 更新。

    这是一个 Alpha 字段,需要启用 RecoverVolumeExpansionFailure 功能特性。

  • allocatedResources (map[string]Quantity)

    allocatedResources 跟踪分配给 PVC 的资源,包括其容量。键名遵循标准的 Kubernetes 标签语法。 有效值为:

    • 未加前缀的键:
      • storage - 卷的容量。
    • 自定义资源必须使用实现定义的带前缀的名称,如 "example.com/my-custom-resource"。 除上述值之外,未加前缀或具有 kubernetes.io 前缀的键被视为保留键,因此不能使用。

    当出现卷扩充操作请求时,此字段可能大于实际的容量。 就存储配额而言,将使用 allocatedResources 和 PVC.spec.resources 二者中的更大值。 如果未设置 allocatedResources,则 PVC.spec.resources 单独用于配额计算。 如果减小一个卷扩充容量请求,则仅当没有正在进行的扩充操作且实际卷容量等于或小于请求的容量时, 才会减小 allocatedResources。

    如果控制器收到具有先前未知的 resourceName 的 PVC 更新,则该控制器应忽略此项更新才能按预期工作。 例如,仅负责调整卷容量大小的控制器应忽略更改与 PVC 关联的其他合法资源的 PVC 更新。

    这是一个 Alpha 字段,需要启用 RecoverVolumeExpansionFailure 功能特性。

  • capacity (map[string]Quantity)

    capacity 表示底层卷的实际资源。

  • conditions ([]PersistentVolumeClaimCondition)

    补丁策略:按照键 type 合并

    conditions 是持久卷声明的当前的状况。 如果正在调整底层持久卷的大小,则状况将被设为 “ResizeStarted”。

    PersistentVolumeClaimCondition 包含有关 PVC 状态的详细信息。

  • conditions.status (string),必需

  • conditions.type (string),必需

  • conditions.lastProbeTime (Time)

    lastProbeTime 是我们探测 PVC 状况的时间。

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

  • conditions.lastTransitionTime (Time)

    lastTransitionTime 是状况从一个状态转换为另一个状态的时间。

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

  • conditions.message (string)

    message 是人类可读的消息,指示有关上一次转换的详细信息。

  • conditions.reason (string)

    reason 是唯一的,它应该是一个机器可理解的简短字符串,指明上次状况转换的原因。 如果它报告 “ResizeStarted”,则意味着正在调整底层持久卷的大小。

  • phase (string)

    phase 表示 PersistentVolumeClaim 的当前阶段。

PersistentVolumeClaimList

PersistentVolumeClaimList 是 PersistentVolumeClaim 各项的列表。


  • apiVersion: v1

  • kind: PersistentVolumeClaimList

操作


get 读取指定的 PersistentVolumeClaim

HTTP 请求

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

参数

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

    PersistentVolumeClaim 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (PersistentVolumeClaim): OK

401: Unauthorized

get 读取指定的 PersistentVolumeClaim 的状态

HTTP 请求

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

参数

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

    PersistentVolumeClaim 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (PersistentVolumeClaim): OK

401: Unauthorized

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

HTTP 请求

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

参数

响应

200 (PersistentVolumeClaimList): OK

401: Unauthorized

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

HTTP 请求

GET /api/v1/persistentvolumeclaims

参数

响应

200 (PersistentVolumeClaimList): OK

401: Unauthorized

create 创建 PersistentVolumeClaim

HTTP 请求

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

参数

响应

200 (PersistentVolumeClaim): OK

201 (PersistentVolumeClaim): Created

202 (PersistentVolumeClaim): Accepted

401: Unauthorized

update 替换指定的 PersistentVolumeClaim

HTTP 请求

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

参数

响应

200 (PersistentVolumeClaim): OK

201 (PersistentVolumeClaim): Created

401: Unauthorized

update 替换指定的 PersistentVolumeClaim 的状态

HTTP 请求

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

参数

响应

200 (PersistentVolumeClaim): OK

201 (PersistentVolumeClaim): Created

401: Unauthorized

patch 部分更新指定的 PersistentVolumeClaim

HTTP 请求

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

参数

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

    PersistentVolumeClaim 的名称

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

    namespace

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (PersistentVolumeClaim): OK

201 (PersistentVolumeClaim): Created

401: Unauthorized

patch 部分更新指定的 PersistentVolumeClaim 的状态

HTTP 请求

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

参数

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

    PersistentVolumeClaim 的名称

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

    namespace

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (PersistentVolumeClaim): OK

201 (PersistentVolumeClaim): Created

401: Unauthorized

delete 删除 PersistentVolumeClaim

HTTP 请求

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

参数

响应

200 (PersistentVolumeClaim): OK

202 (PersistentVolumeClaim): Accepted

401: Unauthorized

deletecollection 删除 PersistentVolumeClaim 的集合

HTTP 请求

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

参数

响应

200 (Status): OK

401: Unauthorized

3.5 - PersistentVolume

PersistentVolume (PV) 是管理员制备的一个存储资源。

apiVersion: v1

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

PersistentVolume

PersistentVolume (PV) 是管理员制备的一个存储资源。它类似于一个节点。更多信息: https://kubernetes.io/zh-cn/docs/concepts/storage/persistent-volumes


  • apiVersion: v1

  • kind: PersistentVolume

PersistentVolumeSpec

PersistentVolumeSpec 是持久卷的规约。


  • nodeAffinity (VolumeNodeAffinity)

    nodeAffinity 定义可以从哪些节点访问此卷的约束限制。此字段会影响调度使用此卷的 Pod。

    VolumeNodeAffinity 定义可以从哪些节点访问此卷的约束限制。

    • nodeAffinity.required (NodeSelector)

    required 指定必须满足的硬性节点约束。

    节点选择器表示在一组节点上一个或多个标签查询结果的并集; 也就是说,它表示由节点选择器条件表示的选择器的逻辑或计算结果。

    • nodeAffinity.required.nodeSelectorTerms ([]NodeSelectorTerm),必需

      必需。节点选择器条件的列表。这些条件是逻辑或的计算结果。

      一个 null 或空的节点选择器条件不会与任何对象匹配。这些条件会按逻辑与的关系来计算。 TopologySelectorTerm 类别实现了 NodeSelectorTerm 的子集。

      • nodeAffinity.required.nodeSelectorTerms.matchExpressions ([]NodeSelectorRequirement)

        基于节点标签所设置的节点选择器要求的列表。

      • nodeAffinity.required.nodeSelectorTerms.matchFields ([]NodeSelectorRequirement)

        基于节点字段所设置的节点选择器要求的列表。

  • persistentVolumeReclaimPolicy (string)

    persistentVolumeReclaimPolicy 定义当从持久卷声明释放持久卷时会发生什么。 有效的选项为 Retain(手动创建 PersistentVolumes 所用的默认值)、 Delete(动态制备 PersistentVolumes 所用的默认值)和 Recycle(已弃用)。 Recycle 选项必须被 PersistentVolume 下层的卷插件所支持才行。更多信息: https://kubernetes.io/zh-cn/docs/concepts/storage/persistent-volumes#reclaiming

  • storageClassName (string)

    storageClassName 是这个持久卷所属于的 StorageClass 的名称。 空值意味着此卷不属于任何 StorageClass。

  • volumeMode (string)

    volumeMode 定义一个卷是带着已格式化的文件系统来使用还是保持在原始块状态来使用。 当 spec 中未包含此字段时,意味着取值为 Filesystem。

Local

  • local (LocalVolumeSource)

    local 表示具有节点亲和性的直连式存储。

    local 表示具有节点亲和性的直连式存储(Beta 特性)。

    • local.path (string),必需

      指向节点上卷的完整路径。它可以是一个目录或块设备(磁盘、分区...)。

    • local.fsType (string)

      fsType 是要挂载的文件系统类型。它仅适用于 path 是一个块设备的情况。 必须是主机操作系统所支持的文件系统类型之一。例如 “ext4”、“xfs”、“ntfs”。 在未指定的情况下,默认值是自动选择一个文件系统。

持久卷

  • awsElasticBlockStore (AWSElasticBlockStoreVolumeSource)

    awsElasticBlockStore 表示挂接到 kubelet 的主机随后暴露给 Pod 的一个 AWS Disk 资源。 更多信息: https://kubernetes.io/zh-cn/docs/concepts/storage/volumes#awselasticblockstore

    表示 AWS 上的 Persistent Disk 资源。挂载到一个容器之前 AWS EBS 磁盘必须存在。 该磁盘还必须与 kubelet 位于相同的 AWS 区域中。AWS EBS 磁盘只能以读/写一次进行挂载。 AWS EBS 卷支持所有权管理和 SELinux 重新打标签。

  • azureDisk (AzureDiskVolumeSource)

    azureDisk 表示主机上挂载的 Azure Data Disk 并绑定挂载到 Pod 上。

    azureDisk 表示主机上挂载的 Azure Data Disk 并绑定挂载到 Pod 上。

    • azureDisk.diskName (string),必需

      diskName 是 Blob 存储中数据盘的名称。

    • azureDisk.diskURI (string),必需

      diskURI 是 Blob 存储中数据盘的 URI。

    • azureDisk.cachingMode (string)

      cachingMode 是主机缓存(Host Caching)模式:None、Read Only、Read Write。

    • azureDisk.fsType (string)

      fsType 是要挂载的文件系统类型。必须是主机操作系统所支持的文件系统类型之一。 例如 “ext4”、“xfs”、“ntfs”。如果未指定,则隐式推断为 “ext4”。

    • azureDisk.kind (string)

      kind 预期值包括:

      • Shared:每个存储帐户多个 Blob 磁盘;
      • Dedicated:每个存储帐户单个 Blob 磁盘;
      • Managed:azure 托管的数据盘(仅托管的可用性集合中)。 默认为 Shared。
    • azureDisk.readOnly (boolean)

      readOnly 默认为 false(读/写)。此处 readOnly 将在 VolumeMounts 中强制设置 readOnly。

  • azureFile (AzureFilePersistentVolumeSource)

    azureDisk 表示主机上挂载的 Azure File Service 并绑定挂载到 Pod 上。

    azureFile 表示主机上挂载的 Azure File Service 并绑定挂载到 Pod 上。

    • azureFile.secretName (string),必需

      secretName 是包含 Azure 存储账号名称和主键的 Secret 的名称。

    • azureFile.shareName (string),必需

      shareName 是 azure Share Name。

    • azureFile.readOnly (boolean)

      readOnly 默认为 false(读/写)。此处 readOnly 将在 VolumeMounts 中强制设置 readOnly。

    • azureFile.secretNamespace (string)

      secretNamespace 是包含 Azure 存储账号名称和主键的 Secret 的名字空间,默认与 Pod 相同。

  • cephfs (CephFSPersistentVolumeSource)

    cephfs 表示在主机上挂载的 Ceph FS,该文件系统挂载与 Pod 的生命周期相同。

    表示在 Pod 的生命周期内持续的 Ceph Filesystem 挂载。cephfs 卷不支持所有权管理或 SELinux 重新打标签。

    • cephfs.secretRef (SecretReference)

      secretRef 是可选的。secretRef 是针对用户到身份认证 Secret 的引用,默认为空。更多信息: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it

      SecretReference 表示对某 Secret 的引用,其中包含足够的信息来访问任何名字空间中的 Secret。

      • cephfs.secretRef.name (string)

        name 在名字空间内是唯一的,以引用一个 Secret 资源。

      • cephfs.secretRef.namespace (string)

        namespace 指定一个名字空间,Secret 名称在该名字空间中必须唯一。

    • cephfs.user (string)

      user 是可选的。user 是 rados 用户名,默认为 admin。更多信息: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it

  • cinder (CinderPersistentVolumeSource)

    cinder 表示 kubelet 主机上挂接和挂载的 Cinder 卷。更多信息: https://examples.k8s.io/mysql-cinder-pd/README.md

    表示 OpenStack 中的一个 Cinder 卷资源。挂载到一个容器之前 Cinder 卷必须已经存在。 该卷还必须与 kubelet 位于相同的地区中。cinder 卷支持所有权管理和 SELinux 重新打标签。

    • cinder.secretRef (SecretReference)

      secretRef 是可选的。指向 Secret 对象,内含的参数用于连接到 OpenStack。

      SecretReference 表示对某 Secret 的引用,其中包含足够的信息来访问任何名字空间中的 Secret。

      • cinder.secretRef.name (string)

        name 在名字空间内是唯一的,以引用一个 Secret 资源。

      • cinder.secretRef.namespace (string)

        namespace 指定一个名字空间,Secret 名称在该名字空间中必须唯一。

  • csi (CSIPersistentVolumeSource)

    csi 表示由一个外部 CSI 驱动处理的存储(Beta 特性)。

    表示由一个外部 CSI 卷驱动管理的存储(Beta 特性)。

    • csi.driver (string),必需

      driver 是此卷所使用的驱动的名称。必需。

    • csi.volumeHandle (string),必需

      volumeHandle 是 CSI 卷插件的 CreateVolume 所返回的唯一卷名称,用于在所有后续调用中引用此卷。必需。

    • csi.controllerExpandSecretRef (SecretReference)

      controllerExpandSecretRef 是对包含敏感信息的 Secret 对象的引用, 该 Secret 会被传递到 CSI 驱动以完成 CSI ControllerExpandVolume 调用。 此字段是可选的,且如果不需要 Secret,则此字段可以为空。 如果 Secret 对象包含多个 Secret,则所有 Secret 被传递。

      SecretReference 表示对某 Secret 的引用,其中包含足够的信息来访问任何名字空间中的 Secret。

      • csi.controllerExpandSecretRef.name (string)

        name 在名字空间内是唯一的,以引用一个 Secret 资源。

      • csi.controllerExpandSecretRef.namespace (string)

        namespace 指定一个名字空间,Secret 名称在该名字空间中必须唯一。

    • csi.controllerPublishSecretRef (SecretReference)

      controllerPublishSecretRef 是对包含敏感信息的 Secret 对象的引用, 该 Secret 会被传递到 CSI 驱动以完成 CSI ControllerPublishVolume 和 ControllerUnpublishVolume 调用。 此字段是可选的,且如果不需要 Secret,则此字段可以为空。 如果 Secret 对象包含多个 Secret,则所有 Secret 被传递。

      SecretReference 表示对某 Secret 的引用,其中包含足够的信息来访问任何名字空间中的 Secret。

      • csi.controllerPublishSecretRef.name (string)

        name 在名字空间内是唯一的,以引用一个 Secret 资源。

      • csi.controllerPublishSecretRef.namespace (string)

        namespace 指定一个名字空间,Secret 名称在该名字空间中必须唯一。

    • csi.fsType (string)

      要挂载的 fsType。必须是主机操作系统所支持的文件系统类型之一。例如 “ext4”、“xfs”、“ntfs”。

    • csi.nodeExpandSecretRef (SecretReference)

      nodeExpandSecretRef 是对包含敏感信息的 Secret 对象的引用, 从而传递到 CSI 驱动以完成 CSI NodeExpandVolume 和 NodeUnpublishVolume 调用。 这是一个 Beta 字段,通过 CSINodeExpandSecret 特性门控默认启用。 此字段是可选的,且如果不需要 Secret,则此字段可以为空。 如果 Secret 对象包含多个 Secret,则所有 Secret 被传递。

      SecretReference 表示对某 Secret 的引用,其中包含足够的信息来访问任何名字空间中的 Secret。

      • csi.nodeExpandSecretRef.name (string)

        name 在名字空间内是唯一的,以引用一个 Secret 资源。

      • csi.nodeExpandSecretRef.namespace (string)

        namespace 指定一个名字空间,Secret 名称在该名字空间中必须唯一。

    • csi.nodePublishSecretRef (SecretReference)

      nodePublishSecretRef 是对包含敏感信息的 Secret 对象的引用, 以传递到 CSI 驱动以完成 CSI NodePublishVolume 和 NodeUnpublishVolume 调用。 此字段是可选的,且如果不需要 Secret,则此字段可以为空。 如果 Secret 对象包含多个 Secret,则所有 Secret 被传递。

      SecretReference 表示对某 Secret 的引用,其中包含足够的信息来访问任何名字空间中的 Secret。

      • csi.nodePublishSecretRef.name (string)

        name 在名字空间内是唯一的,以引用一个 Secret 资源。

      • csi.nodePublishSecretRef.namespace (string)

        namespace 定义了 Secret 名称必须唯一的空间。

    • csi.nodeStageSecretRef (SecretReference)

      nodeStageSecretRef 是对包含敏感信息的 Secret 对象的引用, 从而传递到 CSI 驱动以完成 CSI NodeStageVolume、NodeStageVolume 和 NodeUnstageVolume 调用。 此字段是可选的,且如果不需要 Secret,则此字段可以为空。 如果 Secret 对象包含多个 Secret,则所有 Secret 被传递。

      SecretReference 表示对某 Secret 的引用,其中包含足够的信息来访问任何名字空间中的 Secret。

      • csi.nodeStageSecretRef.name (string)

        name 在名字空间内是唯一的,以引用一个 Secret 资源。

      • csi.nodeStageSecretRef.namespace (string)

        namespace 指定一个名字空间,Secret 名称在该名字空间中必须唯一。

    • csi.readOnly (boolean)

      传递到 ControllerPublishVolumeRequest 的 readOnly 值。默认为 false(读/写)。

    • csi.volumeAttributes (map[string]string)

      要发布的卷的 volumeAttributes。

  • fc (FCVolumeSource)

    fc 表示挂接到 kubelet 的主机并随后暴露给 Pod 的一个光纤通道(FC)资源。

    表示光纤通道卷。光纤通道卷只能以读/写一次进行挂载。光纤通道卷支持所有权管理和 SELinux 重新打标签。

    • fc.fsType (string)

      fsType 是要挂载的文件系统类型。必须是主机操作系统所支持的文件系统类型之一。 例如 “ext4”、“xfs”、“ntfs”。如果未指定,则隐式推断为 “ext4”。

    • fc.lun (int32)

      lun 是可选的。FC 目标 lun 编号。

    • fc.readOnly (boolean)

      readOnly 是可选的。默认为 false(读/写)。 此处 readOnly 将在 VolumeMounts 中强制设置 readOnly。

    • fc.targetWWNs ([]string)

      targetWWNs 是可选的。FC 目标全球名称(WWN)。

    • fc.wwids ([]string)

      wwids 是可选的。FC 卷全球识别号(wwids)。 必须设置 wwids 或 targetWWNs 及 lun 的组合,但不能同时设置两者。

  • flexVolume (FlexPersistentVolumeSource)

    flexVolume 表示使用基于 exec 的插件制备/挂接的通用卷资源。

    FlexPersistentVolumeSource 表示使用基于 exec 的插件制备/挂接的通用持久卷资源。

    • flexVolume.driver (string),必需

      driver 是此卷所使用的驱动的名称。

    • flexVolume.fsType (string)

      fsType 是要挂载的文件系统类型。必须是主机操作系统所支持的文件系统类型之一。 例如 “ext4”、“xfs”、“ntfs”。默认的文件系统取决于 flexVolume 脚本。

    • flexVolume.options (map[string]string)

      options 是可选的。此字段包含额外的命令选项(如果有)。

    • flexVolume.readOnly (boolean)

      readOnly 是可选的。默认为 false(读/写)。 此处 readOnly 将在 VolumeMounts 中强制设置 readOnly。

    • flexVolume.secretRef (SecretReference)

      secretRef 是可选的。secretRef 是对包含敏感信息的 Secret 对象的引用,从而传递到插件脚本。 如果未指定 Secret 对象,则此字段可以为空。如果 Secret 对象包含多个 Secret,则所有 Secret 被传递到插件脚本。

      SecretReference 表示对某 Secret 的引用,其中包含足够的信息来访问任何名字空间中的 Secret。

      • flexVolume.secretRef.name (string)

        name 在名字空间内是唯一的,以引用一个 Secret 资源。

      • flexVolume.secretRef.namespace (string)

        namespace 指定一个名字空间,Secret 名称在该名字空间中必须唯一。

  • flocker (FlockerVolumeSource)

    flocker 表示挂接到 kubelet 的主机并暴露给 Pod 供其使用的 Flocker 卷。 这取决于所运行的 Flocker 控制服务。

    表示 Flocker 代理挂载的 Flocker 卷。应设置且仅设置 datasetName 和 datasetUUID 中的一个。 Flocker 卷不支持所有权管理或 SELinux 重新打标签。

    • flocker.datasetName (string)

      datasetName 是存储为元数据的数据集的名称。针对 Flocker 有关数据集的名称应视为已弃用。

    • flocker.datasetUUID (string)

      datasetUUID 是数据集的 UUID。这是 Flocker 数据集的唯一标识符。

  • iscsi (ISCSIPersistentVolumeSource)

    iscsi 表示挂接到 kubelet 的主机随后暴露给 Pod 的一个 ISCSI Disk 资源。由管理员进行制备。

    ISCSIPersistentVolumeSource 表示一个 ISCSI 磁盘。ISCSI 卷只能以读/写一次进行挂载。ISCSI 卷支持所有权管理和 SELinux 重新打标签。

    • iscsi.iqn (string),必需

      iqn 是目标 iSCSI 限定名称(Target iSCSI Qualified Name)。

    • iscsi.lun (int32),必需

      lun 是 iSCSI 目标逻辑单元号(iSCSI Target Lun)。

    • iscsi.targetPortal (string),必需

      targetPortal 是 iSCSI 目标门户(iSCSI Target Portal)。 如果不是默认端口(通常是 TCP 端口 860 和 3260),则 Portal 为 IP 或 ip_addr:port。

    • iscsi.chapAuthDiscovery (boolean)

      chapAuthDiscovery 定义是否支持 iSCSI Discovery CHAP 身份认证。

    • iscsi.chapAuthSession (boolean)

      chapAuthSession 定义是否支持 iSCSI Session CHAP 身份认证。

    • iscsi.fsType (string)

      fsType 是你要挂载的卷的文件系统类型。提示:确保主机操作系统支持此文件系统类型。 例如:“ext4”、“xfs”、“ntfs”。如果未指定,则隐式推断为 “ext4”。更多信息: https://kubernetes.io/zh-cn/docs/concepts/storage/volumes#iscsi

    • iscsi.initiatorName (string)

      initiatorName 是自定义的 iSCSI 发起程序名称(iSCSI Initiator Name)。 如果同时用 iscsiInterface 指定 initiatorName,将为连接创建新的 iSCSI 接口 <目标门户>:<卷名称>。

    • iscsi.iscsiInterface (string)

      iscsiInterface 是使用 iSCSI 传输的接口名称。默认为 “default”(tcp)。

    • iscsi.portals ([]string)

      portals 是 iSCSI 目标门户列表(iSCSI Target Portal List)。 如果不是默认端口(通常是 TCP 端口 860 和 3260),则 Portal 为 IP 或 ip_addr:port。

    • iscsi.readOnly (boolean)

      此处 readOnly 将在 VolumeMounts 中强制设置 readOnly。默认为 false。

    • iscsi.secretRef (SecretReference)

      secretRef 是 iSCSI 目标和发起程序身份认证所用的 CHAP Secret。

      SecretReference 表示对某 Secret 的引用,其中包含足够的信息来访问任何名字空间中的 Secret。

      • iscsi.secretRef.name (string)

        name 在名字空间内是唯一的,以引用一个 Secret 资源。

      • iscsi.secretRef.namespace (string)

        namespace 指定一个名字空间,Secret 名称在该名字空间中必须唯一。

  • photonPersistentDisk (PhotonPersistentDiskVolumeSource)

    photonPersistentDisk 表示 kubelet 主机上挂接和挂载的 PhotonController 持久磁盘。

    表示 Photon Controller 持久磁盘资源。

    • photonPersistentDisk.pdID (string),必需

      pdID 是标识 Photon Controller 持久磁盘的 ID。

    • photonPersistentDisk.fsType (string)

      fsType 是要挂载的文件系统类型。必须是主机操作系统所支持的文件系统类型之一。 例如 “ext4”、“xfs”、“ntfs”。如果未指定,则隐式推断为 “ext4”。

  • portworxVolume (PortworxVolumeSource)

    portworxVolume 表示 kubelet 主机上挂接和挂载的 portworx 卷。

    PortworxVolumeSource 表示 Portworx 卷资源。

    • portworxVolume.volumeID (string),必需

      volumeID 唯一标识 Portworx 卷。

    • portworxVolume.fsType (string)

      fSType 表示要挂载的文件系统类型。必须是主机操作系统所支持的文件系统类型之一。 例如 “ext4”、“xfs”。如果未指定,则隐式推断为 “ext4”。

    • portworxVolume.readOnly (boolean)

      readOnly 默认为 false(读/写)。此处 readOnly 将在 VolumeMounts 中强制设置 readOnly。

  • quobyte (QuobyteVolumeSource)

    quobyte 表示在共享 Pod 生命周期的主机上挂载的 Quobyte。

    表示在 Pod 的生命周期内持续的 Quobyte 挂载。Quobyte 卷不支持所有权管理或 SELinux 重新打标签。

    • quobyte.registry (string),必需

      registry 表示将一个或多个 Quobyte Registry 服务指定为 host:port 对的字符串形式(多个条目用英文逗号分隔),用作卷的中央注册表。

    • quobyte.volume (string),必需

      volume 是一个字符串,通过名称引用已创建的 Quobyte 卷。

    • quobyte.group (string)

      group 是将卷访问映射到的组。默认为无组。

    • quobyte.readOnly (boolean)

      此处 readOnly 将强制使用只读权限挂载 Quobyte 卷。默认为 false。

    • quobyte.tenant (string)

      后台中拥有给定 Quobyte 卷的租户。用于动态制备的 Quobyte 卷,其值由插件设置。

    • quobyte.user (string)

      user 是将卷访问映射到的用户。默认为 serivceaccount 用户。

  • scaleIO (ScaleIOPersistentVolumeSource)

    scaleIO 表示 Kubernetes 节点上挂接和挂载的 ScaleIO 持久卷。

    ScaleIOPersistentVolumeSource 表示一个 ScaleIO 持久卷。

    • scaleIO.gateway (string),必需

      gateway 是 ScaleIO API 网关的主机地址。

    • scaleIO.secretRef (SecretReference),必需

      secretRef 引用包含 ScaleIO 用户和其他敏感信息的 Secret。如果未提供此项,则 Login 操作将失败。

      SecretReference 表示对某 Secret 的引用,其中包含足够的信息来访问任何名字空间中的 Secret。

      • scaleIO.secretRef.name (string)

        name 在名字空间内是唯一的,以引用一个 Secret 资源。

      • scaleIO.secretRef.namespace (string)

        namespace 指定一个名字空间,Secret 名称在该名字空间中必须唯一。

    • scaleIO.system (string),必需

      system 是 ScaleIO 中所配置的存储系统的名称。

    • scaleIO.fsType (string)

      fsType 是要挂载的文件系统类型。必须是主机操作系统所支持的文件系统类型之一。 例如 “ext4”、“xfs”、“ntfs”。默认为 “xfs”。

    • scaleIO.protectionDomain (string)

      protectionDomain 是 ScaleIO 保护域(ScaleIO Protection Domain)的名称,用于已配置的存储。

    • scaleIO.readOnly (boolean)

      readOnly 默认为 false(读/写)。此处 readOnly 将在 VolumeMounts 中强制设置 readOnly。

    • scaleIO.sslEnabled (boolean)

      sslEnabled 是启用/禁用与网关(Gateway)进行 SSL 通信的标志,默认为 false。

    • scaleIO.storageMode (string)

      storageMode 指示卷所用的存储应是 ThickProvisioned 或 ThinProvisioned。 默认为 ThinProvisioned。

    • scaleIO.storagePool (string)

      storagePool 是与保护域关联的 ScaleIO Storage Pool。

    • scaleIO.volumeName (string)

      volumeName 是在与此卷源关联的 ScaleIO 系统中已创建的卷的名称。

  • storageos (StorageOSPersistentVolumeSource)

    storageOS 表示一个 StorageOS 卷,该卷被挂接到 kubelet 的主机并挂载到 Pod 中。更多信息: https://examples.k8s.io/volumes/storageos/README.md

    表示 StorageOS 持久卷资源。

    • storageos.fsType (string)

      fsType 是要挂载的文件系统类型。必须是主机操作系统所支持的文件系统类型之一。 例如 “ext4”、“xfs”、“ntfs”。如果未指定,则隐式推断为 “ext4”。

    • storageos.readOnly (boolean)

      readOnly 默认为 false(读/写)。此处 readOnly 将在 VolumeMounts 中强制设置 readOnly。

    • storageos.secretRef (ObjectReference)

      secretRef 指定用于获取 StorageOS API 凭据的 Secret。如果未指定,则将尝试使用默认值。

    • storageos.volumeName (string)

      volumeName 是 StorageOS 卷的人类可读名称。这些卷名称在一个名字空间内是唯一的。

    • storageos.volumeNamespace (string)

      volumeNamespace 指定 StorageOS 内卷的作用域。如果未指定名字空间,则将使用 Pod 的名字空间。 这一字段的存在允许 Kubernetes 中名称作用域与 StorageOS 进行映射,实现更紧密的集成。 将 volumeName 设为任何名称均可以重载默认的行为。 如果你未在 StorageOS 内使用名字空间,则设为 “default”。 StorageOS 内预先不存在的名字空间会被创建。

  • vsphereVolume (VsphereVirtualDiskVolumeSource)

    vsphereVolume 表示 kubelet 主机上挂接和挂载的 vSphere 卷。

    表示 vSphere 卷资源。

    • vsphereVolume.volumePath (string),必需

      volumePath 是标识 vSphere 卷 vmdk 的路径。

    • vsphereVolume.fsType (string)

      fsType 是要挂载的文件系统类型。必须是主机操作系统所支持的文件系统类型之一。 例如 “ext4”、“xfs”、“ntfs”。如果未指定,则隐式推断为 “ext4”。

    • vsphereVolume.storagePolicyID (string)

      storagePolicyID 是与 StoragePolicyName 关联的基于存储策略的管理(SPBM)配置文件 ID。

    • vsphereVolume.storagePolicyName (string)

      storagePolicyName 是基于存储策略的管理(SPBM)配置文件名称。

PersistentVolumeStatus

PersistentVolumeStatus 是持久卷的当前状态。


  • lastPhaseTransitionTime (Time)

    lastPhaseTransitionTime 是从一个阶段转换到另一个阶段的时间,每次卷阶段转换时都会自动重置为当前时间。 这是一个 Alpha 字段,需要启用 PersistentVolumeLastPhaseTransitionTime 特性。

    Time 是 time.Time 的包装器,支持正确编组为 YAML 和 JSON,它为 time 包提供的许多工厂方法提供了包装器。

  • message (string)

    message 是一条人类可读的消息,指明有关卷为何处于此状态的详细信息。

  • phase (string)

    phase 表示一个卷是否可用,是否绑定到一个 PVC 或是否由某个 PVC 释放。更多信息: https://kubernetes.io/zh-cn/docs/concepts/storage/persistent-volumes#phase

  • reason (string)

    reason 是一个描述任何故障的简短 CamelCase 字符串,用于机器解析并在 CLI 中整齐地显示。

PersistentVolumeList

PersistentVolumeList 是 PersistentVolume 各项的列表。


  • apiVersion: v1

  • kind: PersistentVolumeList

操作


get 读取指定的 PersistentVolume

HTTP 请求

GET /api/v1/persistentvolumes/{name}

参数

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

    PersistentVolume 的名称

  • pretty (查询参数): string

    pretty

响应

200 (PersistentVolume): OK

401: Unauthorized

get 读取指定的 PersistentVolume 的状态

HTTP 请求

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

参数

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

    PersistentVolume 的名称

  • pretty (查询参数): string

    pretty

响应

200 (PersistentVolume): OK

401: Unauthorized

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

HTTP 请求

GET /api/v1/persistentvolumes

参数

响应

200 (PersistentVolumeList): OK

401: Unauthorized

create 创建 PersistentVolume

HTTP 请求

POST /api/v1/persistentvolumes

参数

响应

200 (PersistentVolume): OK

201 (PersistentVolume): Created

202 (PersistentVolume): Accepted

401: Unauthorized

update 替换指定的 PersistentVolume

HTTP 请求

PUT /api/v1/persistentvolumes/{name}

参数

响应

200 (PersistentVolume): OK

201 (PersistentVolume): Created

401: Unauthorized

update 替换指定的 PersistentVolume 的状态

HTTP 请求

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

参数

响应

200 (PersistentVolume): OK

201 (PersistentVolume): Created

401: Unauthorized

patch 部分更新指定的 PersistentVolume

HTTP 请求

PATCH /api/v1/persistentvolumes/{name}

参数

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

    PersistentVolume 的名称

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (PersistentVolume): OK

201 (PersistentVolume): Created

401: Unauthorized

patch 部分更新指定的 PersistentVolume 的状态

HTTP 请求

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

参数

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

    PersistentVolume 的名称

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (PersistentVolume): OK

201 (PersistentVolume): Created

401: Unauthorized

delete 删除 PersistentVolume

HTTP 请求

DELETE /api/v1/persistentvolumes/{name}

参数

响应

200 (PersistentVolume): OK

202 (PersistentVolume): Accepted

401: Unauthorized

deletecollection 删除 PersistentVolume 的集合

HTTP 请求

DELETE /api/v1/persistentvolumes

参数

响应

200 (Status): OK

401: Unauthorized

3.6 - StorageClass

StorageClass 为可以动态制备 PersistentVolume 的存储类描述参数。

apiVersion: storage.k8s.io/v1

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

StorageClass

StorageClass 为可以动态制备 PersistentVolume 的存储类描述参数。

StorageClass 是不受名字空间作用域限制的;按照 etcd 设定的存储类的名称位于 ObjectMeta.Name 中。


  • apiVersion: storage.k8s.io/v1

  • kind: StorageClass

  • allowedTopologies ([]TopologySelectorTerm)

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

    allowedTopologies 限制可以动态制备卷的节点拓扑。每个卷插件定义其自己支持的拓扑规约。 空的 TopologySelectorTerm 列表意味着没有拓扑限制。 只有启用 VolumeScheduling 功能特性的服务器才能使用此字段。

    拓扑选择器条件表示标签查询的结果。 一个 null 或空的拓扑选择器条件不会匹配任何对象。各个条件的要求按逻辑与的关系来计算。 此选择器作为 NodeSelectorTerm 所提供功能的子集。此功能为 Alpha 特性,将来可能会变更。

  • allowedTopologies.matchLabelExpressions ([]TopologySelectorLabelRequirement)

    按标签设置的拓扑选择器要求的列表。

    拓扑选择器要求是与给定标签匹配的一个选择器。此功能为 Alpha 特性,将来可能会变更。

    • allowedTopologies.matchLabelExpressions.key (string),必需

      选择器所针对的标签键。

    • allowedTopologies.matchLabelExpressions.values ([]string),必需

      字符串数组。一个值必须与要选择的标签匹配。values 中的每个条目按逻辑或的关系来计算。

  • mountOptions ([]string)

    mountOptions 控制此存储类动态制备的 PersistentVolume 的挂载配置。 (例如 ["ro", "soft"])。 系统对选项作检查——如果有一个选项无效,则这些 PV 的挂载将失败。

  • parameters (map[string]string)

    parameters 包含应创建此存储类卷的制备器的参数。

  • reclaimPolicy (string)

    reclaimPolicy 控制此存储类动态制备的 PersistentVolume 的 reclaimPolicy。默认为 Delete。

  • volumeBindingMode (string)

    volumeBindingMode 指示应该如何制备和绑定 PersistentVolumeClaim。 未设置时,将使用 VolumeBindingImmediate。 只有启用 VolumeScheduling 功能特性的服务器才能使用此字段。

StorageClassList

StorageClassList 是存储类的集合。


  • apiVersion: storage.k8s.io/v1

  • kind: StorageClassList

操作


get 读取指定的 StorageClass

HTTP 请求

GET /apis/storage.k8s.io/v1/storageclasses/{name}

参数

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

    StorageClass 的名称

  • pretty (查询参数): string

    pretty

响应

200 (StorageClass): OK

401: Unauthorized

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

HTTP 请求

GET /apis/storage.k8s.io/v1/storageclasses

参数

响应

200 (StorageClassList): OK

401: Unauthorized

create 创建 StorageClass

HTTP 请求

POST /apis/storage.k8s.io/v1/storageclasses

参数

响应

200 (StorageClass): OK

201 (StorageClass): Created

202 (StorageClass): Accepted

401: Unauthorized

update 替换指定的 StorageClass

HTTP 请求

PUT /apis/storage.k8s.io/v1/storageclasses/{name}

参数

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

    StorageClass 的名称

  • body: StorageClass,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (StorageClass): OK

201 (StorageClass): Created

401: Unauthorized

patch 部分更新指定的 StorageClass

HTTP 请求

PATCH /apis/storage.k8s.io/v1/storageclasses/{name}

参数

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

    StorageClass 的名称

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (StorageClass): OK

201 (StorageClass): Created

401: Unauthorized

delete 删除 StorageClass

HTTP 请求

DELETE /apis/storage.k8s.io/v1/storageclasses/{name}

参数

响应

200 (StorageClass): OK

202 (StorageClass): Accepted

401: Unauthorized

deletecollection 删除 StorageClass 的集合

HTTP 请求

DELETE /apis/storage.k8s.io/v1/storageclasses

参数

响应

200 (Status): OK

401: Unauthorized

3.7 - VolumeAttachment

VolumeAttachment 抓取将指定卷挂接到指定节点或从指定节点解除挂接指定卷的意图。

apiVersion: storage.k8s.io/v1

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

VolumeAttachment

VolumeAttachment 抓取将指定卷挂接到指定节点或从指定节点解除挂接指定卷的意图。

VolumeAttachment 对象未划分命名空间。


  • apiVersion: storage.k8s.io/v1

  • kind: VolumeAttachment

  • status (VolumeAttachmentStatus)

    status 表示 VolumeAttachment 请求的状态。由完成挂接或解除挂接操作的实体(即外部挂接器)进行填充。

VolumeAttachmentSpec

VolumeAttachmentSpec 是 VolumeAttachment 请求的规约。


  • attacher (string),必需

    attacher 表示必须处理此请求的卷驱动的名称。这是由 GetPluginName() 返回的名称。

  • nodeName (string),必需

    nodeName 表示卷应挂接到的节点。

  • source (VolumeAttachmentSource),必需

    source 表示应挂接的卷。

    VolumeAttachmentSource 表示应挂接的卷。现在只能通过外部挂接器挂接 PersistenVolume, 将来我们可能还允许 Pod 中的内联卷。只能设置一个成员。

    • source.inlineVolumeSpec (PersistentVolumeSpec)

      inlineVolumeSpec 包含挂接由 Pod 的内联 VolumeSource 定义的持久卷时所有必需的信息。 仅为 CSIMigation 功能填充此字段。 它包含从 Pod 的内联 VolumeSource 转换为 PersistentVolumeSpec 的字段。 此字段处于 Beta 阶段,且只有启用 CSIMigration 功能的服务器才能使用此字段。

    • source.persistentVolumeName (string)

      persistentVolumeName 是要挂接的持久卷的名称。

VolumeAttachmentStatus

VolumeAttachmentStatus 是 VolumeAttachment 请求的状态。


  • attached (boolean),必需

    attached 表示卷被成功挂接。此字段只能由完成挂接操作的实体(例如外部挂接器)进行设置。

  • attachError (VolumeError)

    attachError 表示挂接操作期间遇到的最后一个错误,如果有。 此字段只能由完成挂接操作的实体(例如外部挂接器)进行设置。

    VolumeError 抓取卷操作期间遇到的一个错误。

    • attachError.message (string)

      message 表示挂接或解除挂接操作期间遇到的错误。 此字符串可以放入日志,因此它不应包含敏感信息。

    • attachError.time (Time)

      遇到错误的时间。

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

  • attachmentMetadata (map[string]string)

    成功挂接时,attachmentMetadata 字段将由挂接操作返回的任何信息进行填充, 这些信息必须传递到后续的 WaitForAttach 或 Mount 调用中。 此字段只能由完成挂接操作的实体(例如外部挂接器)进行设置。

  • detachError (VolumeError)

    detachError 表示解除挂接操作期间遇到的最后一个错误,如果有。 此字段只能由完成解除挂接操作的实体(例如外部挂接器)进行设置。

    VolumeError 抓取卷操作期间遇到的一个错误。

    • detachError.message (string)

      message 表示挂接或解除挂接操作期间遇到的错误。 此字符串可以放入日志,因此它不应包含敏感信息。

    • detachError.time (Time)

      time 表示遇到错误的时间。

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

VolumeAttachmentList

VolumeAttachmentList 是 VolumeAttachment 对象的集合。


  • apiVersion: storage.k8s.io/v1

  • kind: VolumeAttachmentList

操作


get 读取指定的 VolumeAttachment

HTTP 请求

GET /apis/storage.k8s.io/v1/volumeattachments/{name}

参数

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

    VolumeAttachment 的名称

  • pretty (查询参数): string

    pretty

响应

200 (VolumeAttachment): OK

401: Unauthorized

get 读取指定的 VolumeAttachment 的状态

HTTP 请求

GET /apis/storage.k8s.io/v1/volumeattachments/{name}/status

参数

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

    VolumeAttachment 的名称

  • pretty (查询参数): string

    pretty

响应

200 (VolumeAttachment): OK

401: Unauthorized

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

HTTP 请求

GET /apis/storage.k8s.io/v1/volumeattachments

参数

响应

200 (VolumeAttachmentList): OK

401: Unauthorized

create 创建 VolumeAttachment

HTTP 请求

POST /apis/storage.k8s.io/v1/volumeattachments

参数

响应

200 (VolumeAttachment): OK

201 (VolumeAttachment): Created

202 (VolumeAttachment): Accepted

401: Unauthorized

update 替换指定的 VolumeAttachment

HTTP 请求

PUT /apis/storage.k8s.io/v1/volumeattachments/{name}

参数

响应

200 (VolumeAttachment): OK

201 (VolumeAttachment): Created

401: Unauthorized

update 替换指定的 VolumeAttachment 的状态

HTTP 请求

PUT /apis/storage.k8s.io/v1/volumeattachments/{name}/status

参数

响应

200 (VolumeAttachment): OK

201 (VolumeAttachment): Created

401: Unauthorized

patch 部分更新指定的 VolumeAttachment

HTTP 请求

PATCH /apis/storage.k8s.io/v1/volumeattachments/{name}

参数

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

    VolumeAttachment 的名称

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (VolumeAttachment): OK

201 (VolumeAttachment): Created

401: Unauthorized

patch 部分更新指定的 VolumeAttachment 的状态

HTTP 请求

PATCH /apis/storage.k8s.io/v1/volumeattachments/{name}/status

参数

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

    VolumeAttachment 的名称

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (VolumeAttachment): OK

201 (VolumeAttachment): Created

401: Unauthorized

delete 删除 VolumeAttachment

HTTP 请求

DELETE /apis/storage.k8s.io/v1/volumeattachments/{name}

参数

响应

200 (VolumeAttachment): OK

202 (VolumeAttachment): Accepted

401: Unauthorized

deletecollection 删除 VolumeAttachment 的集合

HTTP 请求

DELETE /apis/storage.k8s.io/v1/volumeattachments

参数

响应

200 (Status): OK

401: Unauthorized

3.8 - CSIDriver

CSIDriver 抓取集群上部署的容器存储接口(CSI)卷驱动有关的信息。

apiVersion: storage.k8s.io/v1

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

CSIDriver

CSIDriver 抓取集群上部署的容器存储接口(CSI)卷驱动有关的信息。 Kubernetes 挂接/解除挂接控制器使用此对象来决定是否需要挂接。 Kubelet 使用此对象决定挂载时是否需要传递 Pod 信息。 CSIDriver 对象未划分命名空间。


  • apiVersion: storage.k8s.io/v1

  • kind: CSIDriver

CSIDriverSpec

CSIDriverSpec 是 CSIDriver 的规约。


  • attachRequired (boolean)

    attachRequired 表示这个 CSI 卷驱动需要挂接操作 (因为它实现了 CSI ControllerPublishVolume() 方法), Kubernetes 挂接/解除挂接控制器应调用挂接卷接口, 以检查卷挂接(volumeattachment)状态并在继续挂载之前等待卷被挂接。 CSI 外部挂接器与 CSI 卷驱动配合使用,并在挂接操作完成时更新 volumeattachment 状态。 如果 CSIDriverRegistry 特性门控被启用且此值指定为 false,将跳过挂接操作。 否则将调用挂接操作。

    此字段不可变更。

  • fsGroupPolicy (string)

    fsGroupPolicy 定义底层卷是否支持在挂载之前更改卷的所有权和权限。 有关更多详细信息,请参考特定的 FSGroupPolicy 值。

    此字段不可变更。

    默认为 ReadWriteOnceWithFSType,这会检查每个卷,以决定 Kubernetes 是否应修改卷的所有权和权限。 采用默认策略时,如果定义了 fstype 且卷的访问模式包含 ReadWriteOnce,将仅应用定义的 fsGroup。

  • podInfoOnMount (boolean)

    如果 podInfoOnMount 设为 true,则表示在挂载操作期间这个 CSI 卷驱动需要更多的 Pod 信息(例如 podName 和 podUID 等)。 如果设为 false,则挂载时将不传递 Pod 信息。默认为 false。

    CSI 驱动将 podInfoOnMount 指定为驱动部署的一部分。 如果为 true,Kubelet 将在 CSI NodePublishVolume() 调用中作为 VolumeContext 传递 Pod 信息。 CSI 驱动负责解析和校验作为 VolumeContext 传递进来的信息。

    如果 podInfoOnMount 设为 true,将传递以下 VolumeConext。 此列表可能变大,但将使用前缀。

    • "csi.storage.k8s.io/pod.name": pod.name
    • "csi.storage.k8s.io/pod.namespace": pod.namespace
    • "csi.storage.k8s.io/pod.uid": string(pod.UID)
    • "csi.storage.k8s.io/ephemeral": 如果此卷是 CSIVolumeSource 定义的一个临时内联卷,则为 “true”,否则为 “false”

    “csi.storage.k8s.io/ephemeral” 是 Kubernetes 1.16 中一个新的功能特性。 只有同时支持 “Persistent” 和 “Ephemeral” VolumeLifecycleMode 的驱动,此字段才是必需的。 其他驱动可以保持禁用 Pod 信息或忽略此字段。 由于 Kubernetes 1.15 不支持此字段,所以在这类集群上部署驱动时,只能支持一种模式。 该部署就决定了是哪种模式,例如通过驱动的命令行参数。

    此字段不可变更。

  • requiresRepublish (boolean)

    requiresRepublish 表示 CSI 驱动想要 NodePublishVolume 被周期性地调用, 以反映已挂载卷中的任何可能的变化。 此字段默认为 false。

    注:成功完成对 NodePublishVolume 的初始调用后,对 NodePublishVolume 的后续调用只应更新卷的内容。 新的挂载点将不会被运行的容器察觉。

  • seLinuxMount (boolean)

    seLinuxMount 指定 CSI 驱动是否支持 "-o context" 挂载选项。

    当值为 “true” 时,CSI 驱动必须确保该 CSI 驱动提供的所有卷可以分别用不同的 -o context 选项进行挂载。 这对于将卷作为块设备上的文件系统或作为独立共享卷提供的存储后端来说是典型的方法。 当 Kubernetes 挂载在 Pod 中使用的已显式设置 SELinux 上下文的 ReadWriteOncePod 卷时, 将使用 "-o context=xyz" 挂载选项调用 NodeStage / NodePublish。 未来可能会扩展到其他的卷访问模式(AccessModes)。在任何情况下,Kubernetes 都会确保该卷仅使用同一 SELinux 上下文进行挂载。

    当值为 “false” 时,Kubernetes 不会将任何特殊的 SELinux 挂载选项传递给驱动。 这通常用于代表更大共享文件系统的子目录的卷。

    默认为 “false”。

  • storageCapacity (boolean)

    如果设为 true,则 storageCapacity 表示 CSI 卷驱动希望 Pod 调度时考虑存储容量, 驱动部署将通过创建包含容量信息的 CSIStorageCapacity 对象来报告该存储容量。

    部署驱动时可以立即启用这个检查。 这种情况下,只有此驱动部署已发布某些合适的 CSIStorageCapacity 对象, 才会继续制备新的卷,然后进行绑定。

    换言之,可以在未设置此字段或此字段为 false 的情况下部署驱动, 并且可以在发布存储容量信息后再修改此字段。

    此字段在 Kubernetes 1.22 及更早版本中不可变更,但现在可以变更。

  • tokenRequests ([]TokenRequest)

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

    tokenRequests 表示 CSI 驱动需要供挂载卷所用的 Pod 的服务帐户令牌,进行必要的鉴权。 Kubelet 将在 CSI NodePublishVolume 调用中传递 VolumeContext 中的令牌。 CSI 驱动应解析和校验以下 VolumeContext:

    "csi.storage.k8s.io/serviceAccount.tokens": {
      "<audience>": {
        "token": <token>,
        "expirationTimestamp": <expiration timestamp in RFC3339>,
      },
      ...
    }
    

    注:每个 tokenRequest 中的受众应该不同,且最多有一个令牌是空字符串。 要在令牌过期后接收一个新的令牌,requiresRepublish 可用于周期性地触发 NodePublishVolume。

    tokenRequest 包含一个服务帐户令牌的参数。

    • tokenRequests.audience (string),必需

    audience 是 “TokenRequestSpec” 中令牌的目标受众。 它默认为 kube apiserver 的受众。

    • tokenRequests.expirationSeconds (int64)

      expirationSeconds 是 “TokenRequestSpec” 中令牌的有效期。 它具有与 “TokenRequestSpec” 中 “expirationSeconds” 相同的默认值。

  • volumeLifecycleModes ([]string)

    集合:唯一值将在合并期间被保留

    volumeLifecycleModes 定义这个 CSI 卷驱动支持哪种类别的卷。 如果列表为空,则默认值为 “Persistent”,这是 CSI 规范定义的用法, 并通过常用的 PV/PVC 机制在 Kubernetes 中实现。

    另一种模式是 “Ephemeral”。 在这种模式下,在 Pod 规约中用 CSIVolumeSource 以内联方式定义卷,其生命周期与该 Pod 的生命周期相关联。 驱动必须感知到这一点,因为只有针对这种卷才会接收到 NodePublishVolume 调用。

    有关实现此模式的更多信息,请参阅 https://kubernetes-csi.github.io/docs/ephemeral-local-volumes.html。 驱动可以支持其中一种或多种模式,将来可能会添加更多模式。

    此字段处于 Beta 阶段。此字段不可变更。

CSIDriverList

CSIDriverList 是 CSIDriver 对象的集合。


  • apiVersion: storage.k8s.io/v1

  • kind: CSIDriverList

操作


get 读取指定的 CSIDriver

HTTP 请求

GET /apis/storage.k8s.io/v1/csidrivers/{name}

参数

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

    CSIDriver 的名称。

  • pretty (查询参数): string

    pretty

响应

200 (CSIDriver): OK

401: Unauthorized

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

HTTP 请求

GET /apis/storage.k8s.io/v1/csidrivers

参数

响应

200 (CSIDriverList): OK

401: Unauthorized

create 创建 CSIDriver

HTTP 请求

POST /apis/storage.k8s.io/v1/csidrivers

参数

响应

200 (CSIDriver): OK

201 (CSIDriver): Created

202 (CSIDriver): Accepted

401: Unauthorized

update 替换指定的 CSIDriver

HTTP 请求

PUT /apis/storage.k8s.io/v1/csidrivers/{name}

参数

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

    CSIDriver 的名称。

  • body: CSIDriver,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (CSIDriver): OK

201 (CSIDriver): Created

401: Unauthorized

patch 部分更新指定的 CSIDriver

HTTP 请求

PATCH /apis/storage.k8s.io/v1/csidrivers/{name}

参数

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

    CSIDriver 的名称。

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (CSIDriver): OK

201 (CSIDriver): Created

401: Unauthorized

delete 删除 CSIDriver

HTTP 请求

DELETE /apis/storage.k8s.io/v1/csidrivers/{name}

参数

响应

200 (CSIDriver): OK

202 (CSIDriver): Accepted

401: Unauthorized

deletecollection 删除 CSIDriver 的集合

HTTP 请求

DELETE /apis/storage.k8s.io/v1/csidrivers

参数

响应

200 (Status): OK

401: Unauthorized

3.9 - CSINode

CSINode 包含节点上安装的所有 CSI 驱动有关的信息。

apiVersion: storage.k8s.io/v1

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

CSINode

CSINode 包含节点上安装的所有 CSI 驱动有关的信息。CSI 驱动不需要直接创建 CSINode 对象。 只要这些驱动使用 node-driver-registrar 边车容器,kubelet 就会自动为 CSI 驱动填充 CSINode 对象, 作为 kubelet 插件注册操作的一部分。CSINode 的名称与节点名称相同。 如果不存在此对象,则说明该节点上没有可用的 CSI 驱动或 Kubelet 版本太低无法创建该对象。 CSINode 包含指向相应节点对象的 OwnerReference。


  • apiVersion: storage.k8s.io/v1

  • kind: CSINode

  • metadata (ObjectMeta)

    标准的对象元数据。metadata.name 必须是 Kubernetes 节点的名称。

  • spec (CSINodeSpec),必需

    spec 是 CSINode 的规约。

CSINodeSpec

CSINodeSpec 包含一个节点上安装的所有 CSI 驱动规约有关的信息。


  • drivers ([]CSINodeDriver),必需

    补丁策略:按照键 name 合并

    drivers 是节点上存在的所有 CSI 驱动的信息列表。如果列表中的所有驱动均被卸载,则此字段可以为空。

    CSINodeDriver 包含一个节点上安装的一个 CSI 驱动规约有关的信息。

    • drivers.name (string),必需

      name 表示该对象引用的 CSI 驱动的名称。此字段值必须是针对该驱动由 CSI GetPluginName() 调用返回的相同名称。

    • drivers.nodeID (string),必需

      从驱动角度来看,这是节点的 nodeID。 对于未与节点共享相同命名法的存储系统,此字段使得 Kubernetes 能够与之进行通信。 例如,Kubernetes 可能将给定节点视为 "node1",但存储系统可以将同一节点视为 "nodeA"。 当 Kubernetes 向存储系统发出一条命令将一个卷挂接到特定的节点时, 它可以藉此字段使用存储系统所理解的 ID 引用节点名称,例如使用 “nodeA” 而不是 “node1”。 此字段是必需的。

    • drivers.allocatable (VolumeNodeResources)

      allocatable 表示一个节点上可供调度的卷资源。此字段处于 beta 阶段。

      VolumeNodeResources 是调度卷时所用的一组资源限制。

      • drivers.allocatable.count (int32)

        这是一个节点上可使用的、由 CSI 驱动管理的独立卷个数的上限。 挂接并挂载到一个节点上的卷被视为被使用一次,不是两次。 相同的规则适用于同一个节点上多个 Pod 之间共享的同一个卷。 如果未指定此字段,则该节点上支持的卷数量是无限的。

    • drivers.topologyKeys ([]string)

      topologyKeys 是驱动支持的键的列表。 在集群上初始化一个驱动时,该驱动将提供一组自己理解的拓扑键 (例如 “company.com/zone”、“company.com/region”)。 在一个节点上初始化一个驱动时,该驱动将提供相同的拓扑键和值。 Kubelet 将在其自己的节点对象上将这些拓扑键暴露为标签。 当 Kubernetes 进行拓扑感知的制备时,可以使用此列表决定应从节点对象中检索哪些标签并传回驱动。 不同的节点可以使用不同的拓扑键。 如果驱动不支持拓扑,则此字段可以为空。

CSINodeList

CSINodeList 是 CSINode 对象的集合。


  • apiVersion: storage.k8s.io/v1

  • kind: CSINodeList

操作


get 读取指定的 CSINode

HTTP 请求

GET /apis/storage.k8s.io/v1/csinodes/{name}

参数

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

    CSINode 的名称

  • pretty (查询参数): string

    pretty

响应

200 (CSINode): OK

401: Unauthorized

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

HTTP 请求

GET /apis/storage.k8s.io/v1/csinodes

参数

响应

200 (CSINodeList): OK

401: Unauthorized

create 创建 CSINode

HTTP 请求

POST /apis/storage.k8s.io/v1/csinodes

参数

响应

200 (CSINode): OK

201 (CSINode): Created

202 (CSINode): Accepted

401: Unauthorized

update 替换指定的 CSINode

HTTP 请求

PUT /apis/storage.k8s.io/v1/csinodes/{name}

参数

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

    CSINode 的名称

  • body: CSINode,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (CSINode): OK

201 (CSINode): Created

401: Unauthorized

patch 部分更新指定的 CSINode

HTTP 请求

PATCH /apis/storage.k8s.io/v1/csinodes/{name}

参数

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

    CSINode 的名称

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (CSINode): OK

201 (CSINode): Created

401: Unauthorized

delete 删除 CSINode

HTTP 请求

DELETE /apis/storage.k8s.io/v1/csinodes/{name}

参数

响应

200 (CSINode): OK

202 (CSINode): Accepted

401: Unauthorized

deletecollection 删除 CSINode 的集合

HTTP 请求

DELETE /apis/storage.k8s.io/v1/csinodes

参数

响应

200 (Status): OK

401: Unauthorized

3.10 - CSIStorageCapacity

CSIStorageCapacity 存储一个 CSI GetCapacity 调用的结果。

apiVersion: storage.k8s.io/v1

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

CSIStorageCapacity

CSIStorageCapacity 存储一个 CSI GetCapacity 调用的结果。 对于给定的 StorageClass,此结构描述了特定拓扑段中可用的容量。 当考虑在哪里实例化新的 PersistentVolume 时可以使用此项。

例如,此结构可以描述如下内容:

  • “standard” 的 StorageClass 容量为 “1234 GiB”,可用于 “topology.kubernetes.io/zone=us-east1”
  • “localssd” 的 StorageClass 容量为 “10 GiB”,可用于 “kubernetes.io/hostname=knode-abc123”

以下三种情况均暗示了某些组合没有可用的容量:

  • 不存在拓扑和存储类名称合适的对象
  • 这种对象存在,但容量未设置
  • 这种对象存在,但容量为零

这些对象的制作方可以决定哪种方法更合适。

当 CSI 驱动选择使用 CSIDriverSpec.StorageCapacity 进行容量感知调度时,kube-scheduler 会使用这些对象。 该调度器将 MaximumVolumeSize 与 pending 卷的请求大小进行比较,以过滤掉不合适的节点。 如果未设置 MaximumVolumeSize,则回退为与不太精确的容量(Capacity)进行比较。 如果还是未设置,则该调度器假定容量不足并尝试某些其他节点。


  • apiVersion: storage.k8s.io/v1

  • kind: CSIStorageCapacity

  • storageClassName (string),必需

    storageClassName 是已报告容量所对应的 StorageClass 的名称。 它必须满足与 StorageClass 对象名称相同的要求(非空,DNS 子域名)。 如果该对象不再存在,则 CSIStorageCapacity 对象将被废弃且应由创建者移除。 此字段不可变更。

  • capacity (Quantity)

    capacity 是 CSI 驱动在其 GetCapacityResponse 中为 GetCapacityRequest 报告的值,其拓扑和参数与之前的字段匹配。

    该语义目前(CSI 规范 1.2)定义为:可用于制备卷的可用存储容量(单位为字节)。 如果未设置,则该信息目前不可用。

  • maximumVolumeSize (Quantity)

    maximumVolumeSize 是 CSI 驱动在其 GetCapacityResponse 中为 GetCapacityRequest 报告的值,其拓扑和参数与之前的字段匹配。

    自从 CSI 规范 1.4.0 起,这定义为 CreateVolumeRequest.capacity_range.required_bytes 字段中可以使用的最大值, 以便用 GetCapacityRequest 中相同的参数创建一个卷。 Kubernetes API 中的相应值是卷声明中的 ResourceRequirements.Requests。

  • nodeTopology (LabelSelector)

    nodeTopology 定义了哪些节点有权访问已报告容量的存储。 如果未设置,则不能从集群中的任意节点访问此存储。 如果留空,则可以从所有节点访问此存储。此字段不可变更。

CSIStorageCapacityList

CSIStorageCapacityList 是 CSIStorageCapacity 对象的集合。


  • apiVersion: storage.k8s.io/v1

  • kind: CSIStorageCapacityList

操作


get 读取指定的 CSIStorageCapacity

HTTP 请求

GET /apis/storage.k8s.io/v1/namespaces/{namespace}/csistoragecapacities/{name}

参数

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

    CSIStorageCapacity 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (CSIStorageCapacity): OK

401: Unauthorized

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

HTTP 请求

GET /apis/storage.k8s.io/v1/namespaces/{namespace}/csistoragecapacities

参数

响应

200 (CSIStorageCapacityList): OK

401: Unauthorized

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

HTTP 请求

GET /apis/storage.k8s.io/v1/csistoragecapacities

参数

响应

200 (CSIStorageCapacityList): OK

401: Unauthorized

create 创建 CSIStorageCapacity

HTTP 请求

POST /apis/storage.k8s.io/v1/namespaces/{namespace}/csistoragecapacities

参数

响应

200 (CSIStorageCapacity): OK

201 (CSIStorageCapacity): Created

202 (CSIStorageCapacity): Accepted

401: Unauthorized

update 替换指定的 CSIStorageCapacity

HTTP 请求

PUT /apis/storage.k8s.io/v1/namespaces/{namespace}/csistoragecapacities/{name}

参数

响应

200 (CSIStorageCapacity): OK

201 (CSIStorageCapacity): Created

401: Unauthorized

patch 部分更新指定的 CSIStorageCapacity

HTTP 请求

PATCH /apis/storage.k8s.io/v1/namespaces/{namespace}/csistoragecapacities/{name}

参数

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

    CSIStorageCapacity 的名称

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

    namespace

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (CSIStorageCapacity): OK

201 (CSIStorageCapacity): Created

401: Unauthorized

delete 删除 CSIStorageCapacity

HTTP 请求

DELETE /apis/storage.k8s.io/v1/namespaces/{namespace}/csistoragecapacities/{name}

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 CSIStorageCapacity 的集合

HTTP 请求

DELETE /apis/storage.k8s.io/v1/namespaces/{namespace}/csistoragecapacities

参数

响应

200 (Status): OK

401: Unauthorized

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

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

  • sendInitialEvents (查询参数): boolean

sendInitialEvents

  • watch (查询参数): boolean

    watch

响应

200 (ServiceAccountList): OK

401: Unauthorized

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

HTTP 请求

GET /api/v1/serviceaccounts

参数

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

  • sendInitialEvents (查询参数): boolean

sendInitialEvents

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

    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

参数

  • dryRun (查询参数): string

    dryRun

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

  • sendInitialEvents (查询参数): boolean

sendInitialEvents

响应

200 (Status): OK

401: Unauthorized

4.2 - TokenRequest

TokenRequest 为给定的服务账号请求一个令牌。

apiVersion: authentication.k8s.io/v1

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

TokenRequest

TokenRequest 为给定的服务账号请求一个令牌。


  • apiVersion: authentication.k8s.io/v1

  • kind: TokenRequest

TokenRequestSpec

TokenRequestSpec 包含客户端提供的令牌请求参数。


  • audiences ([]string),必需

    audiences 是令牌预期的受众。 令牌的接收方必须在令牌的受众列表中用一个标识符来标识自己,否则应拒绝该令牌。 为多个受众签发的令牌可用于认证所列举的任意受众的身份,但这意味着目标受众彼此之间的信任程度较高。

  • boundObjectRef (BoundObjectReference)

    boundObjectRef 是对令牌所绑定的一个对象的引用。该令牌只有在绑定对象存在时才有效。 注:API 服务器的 TokenReview 端点将校验 boundObjectRef,但其他受众可能不用这样。 如果你想要快速撤销,请为 expirationSeconds 设一个较小的值。

    BoundObjectReference 是对令牌所绑定的一个对象的引用。

    • boundObjectRef.apiVersion (string)

    引用对象的 API 版本。

    • boundObjectRef.kind (string)

      引用对象的类别。有效的类别为 “Pod” 和 “Secret”。

    • boundObjectRef.name (string)

      引用对象的名称。

    • boundObjectRef.uid (string) 引用对象的 UID。

  • expirationSeconds (int64)

    expirationSeconds 是请求生效的持续时间。 令牌签发方可能返回一个生效期不同的令牌,因此客户端需要检查响应中的 “expiration” 字段。

TokenRequestStatus

TokenRequestStatus 是一个令牌请求的结果。


  • expirationTimestamp (Time),必需

    expirationTimestamp 是已返回令牌的到期时间。

    Time 是 time.Time 的包装器,支持正确编组为 YAML 和 JSON。为 time 包提供的许多工厂方法提供了包装器。

  • token (string),必需

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

操作


create 创建 ServiceAccount 的令牌

HTTP 请求

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

参数

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

    TokenRequest 的名称

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

    namespace

  • body: TokenRequest,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (TokenRequest): OK

201 (TokenRequest): Created

202 (TokenRequest): Accepted

401: Unauthorized

4.3 - 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 保存实现 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

4.4 - CertificateSigningRequest

CertificateSigningRequest 对象提供了一种通过提交证书签名请求并异步批准和颁发 x509 证书的机制。

apiVersion: certificates.k8s.io/v1

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

证书签名请求 CertificateSigningRequest

CertificateSigningRequest 对象提供了一种通过提交证书签名请求并异步批准和颁发 x509 证书的机制。

Kubelets 使用 CertificateSigningRequest API 来获取:

  1. 向 kube-apiserver 进行身份认证的客户端证书(使用 “kubernetes.io/kube-apiserver-client-kubelet” signerName)。
  2. kube-apiserver 可以安全连接到 TLS 端点的服务证书(使用 “kubernetes.io/kubelet-serving” signerName)。

此 API 可用于请求客户端证书以向 kube-apiserver 进行身份验证(使用 “kubernetes.io/kube-apiserver-client” 签名者名称),或从自定义非 Kubernetes 签名者那里获取证书。


  • apiVersion: certificates.k8s.io/v1

  • kind: CertificateSigningRequest

  • metadata (ObjectMeta)

  • spec ( CertificateSigningRequestSpec),必需

    spec 包含证书请求,并且在创建后是不可变的。 只有 request、signerName、expirationSeconds 和 usages 字段可以在创建时设置。 其他字段由 Kubernetes 派生,用户无法修改。

  • status ( CertificateSigningRequestStatus)

    status 包含有关请求是被批准还是拒绝的信息,以及签名者颁发的证书或指示签名者失败的状况。

CertificateSigningRequestSpec

CertificateSigningRequestSpec 包含证书请求。


  • signerName (string),必需

    signerName 表示请求的签名者,是一个限定名。

    CertificateSigningRequests 的 list/watch 请求可以使用 “spec.signerName=NAME” 字段选择器进行过滤。

    众所周知的 Kubernetes 签名者有:

    1. “kubernetes.io/kube-apiserver-client”:颁发客户端证书,用于向 kube-apiserver 进行身份验证。 对此签名者的请求永远不会被 kube-controller-manager 自动批准, 可以由 kube-controller-manager 中的 “csrsigning” 控制器颁发。
    2. “kubernetes.io/kube-apiserver-client-kubelet”:颁发客户端证书,kubelet 用于向 kube-apiserver 进行身份验证。 对此签名者的请求可以由 kube-controller-manager 中的 “csrapproving” 控制器自动批准, 并且可以由 kube-controller-manager 中的 “csrsigning” 控制器颁发。
    3. “kubernetes.io/kubelet-serving” 颁发服务证书,kubelet 用于服务 TLS 端点,kube-apiserver 可以安全的连接到这些端点。 对此签名者的请求永远不会被 kube-controller-manager 自动批准, 可以由 kube-controller-manager 中的 “csrsigning” 控制器颁发。

    更多详细信息,请访问 https://kubernetes.io/zh-cn/docs/reference/access-authn-authz/certificate-signing-requests/#kubernetes-signers

    也可以指定自定义 signerName。签名者定义如下:

    1. 信任分发:信任(CA 证书包)是如何分发的。
    2. 许可的主体:当请求不允许的主体时的行为。
    3. 请求中必需、许可或禁止的 x509 扩展(包括是否允许 subjectAltNames、哪些类型、对允许值的限制) 以及请求不允许的扩展时的行为。
    4. 必需、许可或禁止的密钥用途/扩展密钥用途。
    5. 过期/证书生命周期:是否由签名者确定,管理员可配置。
    6. 是否允许申请 CA 证书。
  • expirationSeconds (int32)

    expirationSeconds 是所颁发证书的所请求的有效期。 证书签署者可以颁发具有不同有效期的证书, 因此客户端必须检查颁发证书中 notBefore 和 notAfter 字段之间的增量以确定实际持续时间。

    众所周知的 Kubernetes 签名者在 v1.22+ 版本内实现将遵守此字段, 只要请求的持续时间不大于最大持续时间,它们将遵守 Kubernetes 控制管理器的 --cluster-signing-duration CLI 标志。

    由于各种原因,证书签名者可能忽略此字段:

    1. 不认识此字段的旧签名者(如 v1.22 版本之前的实现)
    2. 配置的最大持续时间小于请求持续时间的签名者
    3. 配置的最小持续时间大于请求持续时间的签名者

    expirationSeconds 的最小有效值为 600,即 10 分钟。

  • extra (map[string][]string)

    extra 包含创建 CertificateSigningRequest 的用户的额外属性。 在创建时由 API 服务器填充,且不可变。

  • groups ([]string)

    Atomic:将在合并过程中被替换

    groups 包含创建 CertificateSigningRequest 的用户的组成员关系。 在创建时由 API 服务器填充,且不可变。

  • uid (string)

    uid 包含创建 CertificateSigningRequest 的用户的 uid 。 在创建时由 API 服务器填充,且不可变。

  • usages ([]string)

    Atomic:将在合并期间被替换

    usages 指定颁发证书中请求的一组密钥用途。

    TLS 客户端证书的请求通常要求:"digital signature"、"key encipherment"、"client auth"。

    TLS 服务证书的请求通常要求:"key encipherment"、"digital signature"、"server auth"。

    有效值: "signing"、"digital signature"、"content commitment"、 "key encipherment"、"key agreement"、"data encipherment"、 "cert sign"、"crl sign"、"encipher only"、"decipher only"、"any"、 "server auth"、"client auth"、 "code signing"、"email protection"、"s/mime"、 "ipsec end system"、"ipsec tunnel"、"ipsec user"、 "timestamping"、"ocsp signing"、"microsoft sgc"、"netscape sgc"。

  • username (string)

    username 包含创建 CertificateSigningRequest 的用户名。 在创建时由 API 服务器填充,且不可变。

CertificateSigningRequestStatus

CertificateSigningRequestStatus 包含用于指示请求的批准/拒绝/失败状态和颁发证书的状况。


  • certificate ([]byte)

    Atomic:将在合并期间被替换

    certificate 在出现 Approved 状况后,由签名者使用已颁发的证书填充。 这个字段通过 /status 子资源设置。填充后,该字段将不可变。

    如果证书签名请求被拒绝,则添加类型为 “Denied” 的状况,并且保持该字段为空。 如果签名者不能颁发证书,则添加类型为 “Failed” 的状况,并且保持该字段为空。

    验证要求:

    1. 证书必须包含一个或多个 PEM 块。
    2. 所有的 PEM 块必须有 “CERTIFICATE” 标签,不包含头和编码的数据, 必须是由 BER 编码的 ASN.1 证书结构,如 RFC5280 第 4 节所述。
    3. 非 PEM 内容可能出现在 “CERTIFICATE”PEM 块之前或之后,并且是未验证的, 允许如 RFC7468 5.2 节中描述的解释性文本。

    如果存在多个 PEM 块,并且所请求的 spec.signerName 的定义没有另外说明, 那么第一个块是颁发的证书,后续的块应该被视为中间证书并在 TLS 握手中呈现。

    证书编码为 PEM 格式。

    当序列化为 JSON 或 YAML 时,数据额外采用 base64 编码,它包括:

    base64(
        -----BEGIN CERTIFICATE-----
        ...
        -----END CERTIFICATE-----
    )
    
  • conditions ([]CertificateSigningRequestCondition)

    Map:键类型的唯一值将在合并期间保留

    应用于请求的状况。已知的状况有 "Approved"、"Denied" 与 "Failed"。

    CertificateSigningRequestCondition 描述 CertificateSigningRequest 对象的状况。

    • conditions.status (string),必需

    状况的状态,True、False、Unknown 之一。Approved、Denied 与 Failed 的状况不可以是 "False" 或 "Unknown"。

    • conditions.type (string),必需

    状况的类型。已知的状况是 "Approved"、"Denied" 与 "Failed"。

    通过 /approval 子资源添加 “Approved” 状况,表示请求已被批准并且应由签名者颁发。

    通过 /approval 子资源添加 “Denied” 状况,指示请求被拒绝并且不应由签名者颁发。

    通过 /status 子资源添加 “Failed” 状况,表示签名者未能颁发证书。

    Approved 和 Denied 状况是相互排斥的。Approved、Denied 和 Failed 状况一旦添加就无法删除。

    给定类型只允许设置一种状况。

    • conditions.lastTransitionTime (Time)

      lastTransitionTime 是状况上一次从一种状态转换到另一种状态的时间。 如果未设置,当添加新状况类型或更改现有状况的状态时,服务器默认为当前时间。

      Time 是 time.Time 的包装器,支持正确编码为 YAML 和 JSON。为 time 包提供的许多工厂方法提供了包装器。

    • conditions.lastUpdateTime (Time)

    lastUpdateTime 是该状况最后一次更新的时间。

    Time 是 time.Time 的包装器,支持正确编组为 YAML 和 JSON。为 time 包提供的许多工厂方法提供了包装器。

    • conditions.message (string)

    message 包含一个人类可读的消息,包含关于请求状态的详细信息。

    • conditions.reason (string)

    reason 表示请求状态的简短原因。

CertificateSigningRequestList

CertificateSigningRequestList 是 CertificateSigningRequest 对象的集合。


  • apiVersion: certificates.k8s.io/v1

  • kind: CertificateSigningRequestList

  • metadata (ListMeta)

  • items ([]CertificateSigningRequest),必需

    items 是 CertificateSigningRequest 对象的集合。

操作


get 读取指定的 CertificateSigningRequest

HTTP 请求

GET /apis/certificates.k8s.io/v1/certificatesigningrequests/{name}

参数

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

    CertificateSigningRequest 的名称。

  • pretty (查询参数): string

    pretty

响应

200 (CertificateSigningRequest): OK

401: Unauthorized

get 读取指定 CertificateSigningRequest 的批准信息

HTTP 请求

GET /apis/certificates.k8s.io/v1/certificatesigningrequests/{name}/approval

参数

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

    CertificateSigningRequest 的名称。

  • pretty (查询参数): string

    pretty

响应

200 (CertificateSigningRequest): OK

401: Unauthorized

get 读取指定 CertificateSigningRequest 的状态

HTTP 请求

GET /apis/certificates.k8s.io/v1/certificatesigningrequests/{name}/status

参数

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

    CertificateSigningRequest 的名称。

  • pretty (查询参数): string

    pretty

响应

200 (CertificateSigningRequest): OK

401: Unauthorized

list list 或 watch CertificateSigningRequest 类型的对象

HTTP 请求

GET /apis/certificates.k8s.io/v1/certificatesigningrequests

参数

响应

200 (CertificateSigningRequestList): OK

401: Unauthorized

create 创建一个 CertificateSigningRequest

HTTP 请求

POST /apis/certificates.k8s.io/v1/certificatesigningrequests

参数

响应

200 (CertificateSigningRequest): OK

201 (CertificateSigningRequest): Created

202 (CertificateSigningRequest): Accepted

401: Unauthorized

update 替换指定的 CertificateSigningRequest

HTTP 请求

PUT /apis/certificates.k8s.io/v1/certificatesigningrequests/{name}

参数

响应

200 (CertificateSigningRequest): OK

201 (CertificateSigningRequest): Created

401: Unauthorized

update 替换对指定 CertificateSigningRequest 的批准信息

HTTP 请求

PUT /apis/certificates.k8s.io/v1/certificatesigningrequests/{name}/approval

参数

响应

200 (CertificateSigningRequest): OK

201 (CertificateSigningRequest): Created

401: Unauthorized

update 替换指定 CertificateSigningRequest 的状态

HTTP 请求

PUT /apis/certificates.k8s.io/v1/certificatesigningrequests/{name}/status

参数

响应

200 (CertificateSigningRequest): OK

201 (CertificateSigningRequest): Created

401: Unauthorized

patch 部分更新指定的 CertificateSigningRequest

HTTP 请求

PATCH /apis/certificates.k8s.io/v1/certificatesigningrequests/{name}

参数

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

    CertificateSigningRequest 的名称。

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

响应

200 (CertificateSigningRequest): OK

201 (CertificateSigningRequest): Created

401: Unauthorized

patch 部分更新指定 CertificateSigningRequest 的批准信息

HTTP 请求

PATCH /apis/certificates.k8s.io/v1/certificatesigningrequests/{name}/approval

参数

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

    CertificateSigningRequest 的名称。

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

响应

200 (CertificateSigningRequest): OK

201 (CertificateSigningRequest): Created

401: Unauthorized

patch 部分更新指定 CertificateSigningRequest 的状态

HTTP 请求

PATCH /apis/certificates.k8s.io/v1/certificatesigningrequests/{name}/status

参数

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

    CertificateSigningRequest 的名称。

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

响应

200 (CertificateSigningRequest): OK

201 (CertificateSigningRequest): Created

401: Unauthorized

delete 删除一个 CertificateSigningRequest

HTTP 请求

DELETE /apis/certificates.k8s.io/v1/certificatesigningrequests/{name}

参数

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

    CertificateSigningRequest 的名称。

  • body: DeleteOptions

  • dryRun (查询参数): string

    dryRun

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 CertificateSigningRequest 集合

HTTP 请求

DELETE /apis/certificates.k8s.io/v1/certificatesigningrequests

参数

响应

200 (Status): OK

401: Unauthorized

4.5 - ClusterTrustBundle v1alpha1

ClusterTrustBundle 是一个集群范围的容器,用于存放 X.509 信任锚(根证书)。

apiVersion: certificates.k8s.io/v1alpha1

import "k8s.io/api/certificates/v1alpha1"

ClusterTrustBundle

ClusterTrustBundle 是一个集群范围的容器,用于存放 X.509 信任锚(根证书)。

ClusterTrustBundle 对象被视为可被集群中的任何已通过身份验证的用户读取, 因为此对象可以由使用 clusterTrustBundle 投射的 Pod 挂载。 所有服务账号默认都有对 ClusterTrustBundle 的读取权限。 对于仅对集群具有命名空间级访问权限的用户,可以通过伪装他们可以访问的服务账号来读取 ClusterTrustBundle。

ClusterTrustBundle 可以选择与特定的签名程序相关联,此时它包含该签名程序的一组有效信任锚。 签名程序可以有多个关联的 ClusterTrustBundle; 对于该签名程序而言每个 ClusterTrustBundle 都是独立的一组信任锚。 准入控制用于确保只有对签名程序有访问权限的用户才能创建或修改相应的捆绑包。


  • apiVersion: certificates.k8s.io/v1alpha1

  • kind: ClusterTrustBundle

ClusterTrustBundleSpec

ClusterTrustBundleSpec 包含签名程序和信任锚。


  • trustBundle (string),必需

    trustBundle 包含此捆绑包的各个 X.509 信任锚,这个 PEM 捆绑包是采用 PEM 包装的 DER 格式的若干 X.509 证书。

    数据必须仅由可解析为有效 X.509 证书的 PEM 证书块组成。 每个证书必须包含设置了 CA 标志的基本约束扩展。 API 服务器将拒绝包含重复证书或使用 PEM 块头的对象。

    ClusterTrustBundles 的使用者(包括 kubelet)可以根据自己的逻辑对此文件中的证书块进行重新排序和去重, 也可以删除 PEM 块头和块间数据。

  • signerName (string)

    signerName 表示关联的签名程序(如果有)。

    要创建或更新设置了 signerName 属性的 ClusterTrustBundle,你必须具备以下集群范围的权限:

    group=certificates.k8s.io resource=signers resourceName=\<签名程序名称> verb=attest

    如果 signerName 不为空,则 ClusterTrustBundle 对象的名称必须以签名程序名称作为前缀(将斜杠转换为冒号)。 例如,对于签名程序名称 example.com/foo,有效的 ClusterTrustBundle 对象名称包括 example.com:foo:abcexample.com:foo:v1

    如果 signerName 为空,则 ClusterTrustBundle 对象的名称不能具有此类前缀。

    针对 ClusterTrustBundles 的列举/监视请求可以使用 spec.signerName=NAME 字段选择算符针对此字段进行过滤。

ClusterTrustBundleList

ClusterTrustBundleList 是 ClusterTrustBundle 对象的集合。


  • apiVersion: certificates.k8s.io/v1alpha1

  • kind: ClusterTrustBundleList

  • metadata (ListMeta)

    metadata 包含列表的元数据。

  • items ([]ClusterTrustBundle),必需

    items 是 ClusterTrustBundle 对象的集合。

操作


get 读取指定的 ClusterTrustBundle

HTTP 请求

GET /apis/certificates.k8s.io/v1alpha1/clustertrustbundles/{name}

参数

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

    ClusterTrustBundle 的名称。

  • pretty查询参数):string

    pretty

响应

200 (ClusterTrustBundle): OK

401: Unauthorized

list 列举或监视类别为 ClusterTrustBundle 的对象

HTTP 请求

GET /apis/certificates.k8s.io/v1alpha1/clustertrustbundles

参数

响应

200 (ClusterTrustBundleList): OK

401: Unauthorized

create 创建 ClusterTrustBundle

HTTP 请求

POST /apis/certificates.k8s.io/v1alpha1/clustertrustbundles

参数

响应

200 (ClusterTrustBundle): OK

201 (ClusterTrustBundle): Created

202 (ClusterTrustBundle): Accepted

401: Unauthorized

update 替换指定的 ClusterTrustBundle

HTTP 请求

PUT /apis/certificates.k8s.io/v1alpha1/clustertrustbundles/{name}

参数

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

    ClusterTrustBundle 的名称。

  • body: ClusterTrustBundle,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • pretty查询参数):string

    pretty

响应

200 (ClusterTrustBundle): OK

201 (ClusterTrustBundle): Created

401: Unauthorized

patch 部分更新指定的 ClusterTrustBundle

HTTP 请求

PATCH /apis/certificates.k8s.io/v1alpha1/clustertrustbundles/{name}

参数

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

    ClusterTrustBundle 的名称。

  • body: Patch,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (ClusterTrustBundle): OK

201 (ClusterTrustBundle): Created

401: Unauthorized

delete 删除 ClusterTrustBundle

HTTP 请求

DELETE /apis/certificates.k8s.io/v1alpha1/clustertrustbundles/{name}

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 ClusterTrustBundle 的集合

HTTP 请求

DELETE /apis/certificates.k8s.io/v1alpha1/clustertrustbundles

参数

响应

200 (Status): OK

401: Unauthorized

4.6 - SelfSubjectReview

SelfSubjectReview 包含 kube-apiserver 所拥有的与发出此请求的用户有关的用户信息。

apiVersion: authentication.k8s.io/v1

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

SelfSubjectReview

SelfSubjectReview 包含 kube-apiserver 所拥有的与发出此请求的用户有关的用户信息。 使用伪装时,用户将收到被伪装用户的用户信息。 如果使用伪装或请求头部进行身份验证,则所有额外的键都将被忽略大小写并以小写形式返回结果。


SelfSubjectReviewStatus

SelfSubjectReviewStatus 由 kube-apiserver 进行填充并发送回用户。


  • userInfo (UserInfo)

    发出此请求的用户的用户属性。

    userInfo 包含实现 user.Info 接口所需的用户相关信息。

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

      由身份认证组件提供的所有附加信息。

    • userInfo.groups ([]string)

      此用户所属的用户组的名称。

    • userInfo.uid (string)

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

    • userInfo.username (string)

      在所有活跃用户中标识此用户的名称。

操作


create 创建 SelfSubjectReview

HTTP 请求

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

参数

响应

200 (SelfSubjectReview): OK

201 (SelfSubjectReview): Created

202 (SelfSubjectReview): 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

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

  • 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 检查用户或组是否可以执行某操作。


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 组中的其中一个枚举资源来请求任何操作。 "" 表示核心 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 的名称

  • bodyClusterRole,必需

  • 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 的名称

  • bodyPatch,必需

  • 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

操作


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 组中的其中一个枚举资源来请求任何操作。 "" 表示核心 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 - 策略资源

6.1 - LimitRange

LimitRange 设置名字空间中每个资源类别的资源用量限制。

apiVersion: v1

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

LimitRange

LimitRange 设置名字空间中每个资源类别的资源用量限制。


  • apiVersion: v1

  • kind: LimitRange

LimitRangeSpec

LimitRangeSpec 定义与类别匹配的资源的最小/最大使用限制。


  • limits ([]LimitRangeItem),必需

    limits 是强制执行的 LimitRangeItem 对象的列表。

    LimitRangeItem 定义与类别匹配的任意资源的最小/最大使用限制。

    • limits.type (string),必需

      此限制应用到的资源的类型。

    • limits.default (map[string]Quantity)

      资源限制被省略时按资源名称设定的默认资源要求限制值。

    • limits.defaultRequest (map[string]Quantity)

      defaultRequest 是资源请求被省略时按资源名称设定的默认资源要求请求值。

    • limits.max (map[string]Quantity)

      按资源名称针对这种类别的最大使用约束。

    • limits.maxLimitRequestRatio (map[string]Quantity)

      如果指定 maxLimitRequestRatio,则所指定的资源必须设置非零的请求和限制值, 且限制除以请求小于或等于这里列举的值;此属性用来表示所指定资源的最大突发用量。

    • limits.min (map[string]Quantity)

      按资源名称区分的,针对这种类别对象的最小用量约束。

LimitRangeList

LimitRangeList 是 LimitRange 项的列表。


  • apiVersion: v1

  • kind: LimitRangeList

操作


get 读取指定的 LimitRange

HTTP 请求

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

参数

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

    LimitRange 的名称

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (LimitRange): OK

401: Unauthorized

list 列出或监视 LimitRange 类别的对象

HTTP 请求

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

参数

响应

200 (LimitRangeList): OK

401: Unauthorized

list 列出或监视 LimitRange 类别的对象

HTTP 请求

GET /api/v1/limitranges

参数

响应

200 (LimitRangeList): OK

401: Unauthorized

create 创建 LimitRange

HTTP 请求

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

参数

响应

200 (LimitRange): OK

201 (LimitRange): Created

202 (LimitRange): Accepted

401: Unauthorized

update 替换指定的 LimitRange

HTTP 请求

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

参数

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

    LimitRange 的名称

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

    namespace

  • body: LimitRange,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (LimitRange): OK

201 (LimitRange): Created

401: Unauthorized

patch 部分更新指定的 LimitRange

HTTP 请求

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

参数

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

    LimitRange 的名称

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

    namespace

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (LimitRange): OK

201 (LimitRange): Created

401: Unauthorized

delete 删除 LimitRange

HTTP 请求

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

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 LimitRange 的集合

HTTP 请求

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

参数

响应

200 (Status): OK

401: Unauthorized

6.2 - ResourceQuota

ResourceQuota 设置每个命名空间强制执行的聚合配额限制。

apiVersion: v1

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

ResourceQuota

ResourceQuota 设置每个命名空间强制执行的聚合配额限制。


ResourceQuotaSpec

ResourceQuotaSpec 定义为 Quota 强制执行所需的硬限制。


  • hard (map[string]Quantity)

    hard 是每种指定资源所需的硬性限制集合。 更多信息: https://kubernetes.io/docs/concepts/policy/resource-quotas/

  • scopeSelector (ScopeSelector)

    scopeSelector 也是一组过滤器的集合,和 scopes 类似, 必须匹配配额所跟踪的每个对象,但使用 ScopeSelectorOperator 结合可能的值来表示。 对于要匹配的资源,必须同时匹配 scopes 和 scopeSelector(如果在 spec 中设置了的话)。

    scope 选择算符表示的是由限定范围的资源选择算符进行 逻辑与 计算得出的结果。

    • scopeSelector.matchExpressions ([]ScopedResourceSelectorRequirement)

      按资源范围划分的范围选择算符需求列表。

      限定范围的资源选择算符需求是一种选择算符,包含值、范围名称和将二者关联起来的运算符。

      • scopeSelector.matchExpressions.operator (string),必需

        表示范围与一组值之间的关系。有效的运算符为 In、NotIn、Exists、DoesNotExist。

      • scopeSelector.matchExpressions.scopeName (string),必需

        选择器所适用的范围的名称。

      • scopeSelector.matchExpressions.values ([]string)

        字符串值数组。 如果操作符是 In 或 NotIn,values 数组必须是非空的。 如果操作符是 Exists 或 DoesNotExist,values 数组必须为空。 该数组将在策略性合并补丁操作期间被替换。

  • scopes ([]string)

    一个匹配被配额跟踪的所有对象的过滤器集合。 如果没有指定,则默认匹配所有对象。

ResourceQuotaStatus

ResourceQuotaStatus 定义硬性限制和观测到的用量。


ResourceQuotaList

ResourceQuotaList 是 ResourceQuota 列表。


操作


get 读取指定的 ResourceQuota

HTTP 请求

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

参数

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

    ResourceQuota 的名称

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

    namespace

  • pretty查询参数): string

    pretty

响应

200 (ResourceQuota): OK

401: Unauthorized

get 读取指定的 ResourceQuota 的状态

HTTP 请求

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

参数

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

    ResourceQuota 的名称

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

    namespace

  • pretty查询参数): string

    pretty

响应

200 (ResourceQuota): OK

401: Unauthorized

list 列出或监视 ResourceQuota 类别的对象

HTTP 请求

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

参数

响应

200 (ResourceQuotaList): OK

401: Unauthorized

list 列出或监视 ResourceQuota 类别的对象

HTTP 请求

GET /api/v1/resourcequotas

参数

响应

200 (ResourceQuotaList): OK

401: Unauthorized

create 创建一个 ResourceQuota

HTTP 请求

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

参数

响应

200 (ResourceQuota): OK

201 (ResourceQuota): Created

202 (ResourceQuota): Accepted

401: Unauthorized

update 更新指定的 ResourceQuota

HTTP 请求

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

参数

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

    ResourceQuota 的名称

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

    namespace

  • body: ResourceQuota, 必需

  • dryRun查询参数): string

    dryRun

  • fieldManager查询参数): string

    fieldManager

  • fieldValidation查询参数): string

    fieldValidation

  • pretty查询参数): string

    pretty

响应

200 (ResourceQuota): OK

201 (ResourceQuota): Created

401: Unauthorized

update 更新指定 ResourceQuota 的状态

HTTP 请求

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

参数

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

    ResourceQuota 的名称

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

    namespace

  • body: ResourceQuota, 必需

  • dryRun查询参数): string

    dryRun

  • fieldManager查询参数): string

    fieldManager

  • fieldValidation查询参数): string

    fieldValidation

  • pretty查询参数): string

    pretty

响应

200 (ResourceQuota): OK

201 (ResourceQuota): Created

401: Unauthorized

patch 部分更新指定的 ResourceQuota

HTTP 请求

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

参数

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

    ResourceQuota 的名称

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

    namespace

  • body: Patch, 必需

  • dryRun查询参数): string

    dryRun

  • fieldManager查询参数): string

    fieldManager

  • fieldValidation查询参数): string

    fieldValidation

  • force查询参数): boolean

    force

  • pretty查询参数): string

    pretty

响应

200 (ResourceQuota): OK

201 (ResourceQuota): Created

401: Unauthorized

patch 部分更新指定 ResourceQuota 的状态

HTTP 请求

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

参数

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

    ResourceQuota 的名称

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

    namespace

  • body: Patch, 必需

  • dryRun查询参数): string

    dryRun

  • fieldManager查询参数): string

    fieldManager

  • fieldValidation查询参数): string

    fieldValidation

  • force查询参数): boolean

    force

  • pretty查询参数): string

    pretty

响应

200 (ResourceQuota): OK

201 (ResourceQuota): Created

401: Unauthorized

delete 删除 ResourceQuota

HTTP 请求

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

参数

响应

200 (ResourceQuota): OK

202 (ResourceQuota): Accepted

401: Unauthorized

deletecollection 删除 ResourceQuota 的集合

HTTP 请求

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

参数

响应

200 (Status): OK

401: Unauthorized

6.3 - NetworkPolicy

NetworkPolicy 描述针对一组 Pod 所允许的网络流量。

apiVersion: networking.k8s.io/v1

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

NetworkPolicy

NetworkPolicy 描述针对一组 Pod 所允许的网络流量。


NetworkPolicySpec

NetworkPolicySpec 定义特定 NetworkPolicy 所需的所有信息.


  • podSelector (LabelSelector),必需

    podSelector 选择此网络策略所适用的一组 Pod。一组 Ingress 入口策略将应用于此字段选择的所有 Pod。 多个网络策略可以选择同一组 Pod。 在这种情况下,这些列表条目的 Ingress 规则效果会被叠加。此字段不是可选的,并且遵循标准标签选择算符语义。 空值的 podSelector 匹配此命名空间中的所有 Pod。

  • policyTypes ([]string)

    policyTypes 是 NetworkPolicy 相关的规则类型列表。有效选项为 [“Ingress”][“Egress”][“Ingress”, “Egress”]。 如果不指定此字段,则默认值取决是否存在 Ingress 或 Egress 规则;规则里包含 Egress 部分的策略将会影响出站流量, 并且所有策略(无论它们是否包含 Ingress 部分)都将会影响 入站流量。 如果要仅定义出站流量策略,则必须明确指定 [ "Egress" ]。 同样,如果要定义一个指定拒绝所有出站流量的策略,则必须指定一个包含 “Egress” 的 policyTypes 值 (因为这样不包含 Egress 部分的策略,将会被默认为只有 [ "Ingress" ] )。此字段在 1.8 中为 Beta。

  • ingress ([]NetworkPolicyIngressRule)

    ingress 是应用到所选 Pod 的入站规则列表。在没有被任何 NetworkPolicy 选择到 Pod 的情况下(同时假定集群策略允许对应流量), 或者如果流量源是 Pod 的本地节点,或者流量与所有 NetworkPolicy 中的至少一个入站规则(Ingress) 匹配, 则进入 Pod 的流量是被允许的。如果此字段为空,则此 NetworkPolicy 不允许任何入站流量 (这种设置用来确保它所选择的 Pod 在默认情况下是被隔离的)。

    NetworkPolicyIngressRule 定义 NetworkPolicySpec 的 podSelector 所选 Pod 的入站规则的白名单列表, 流量必须同时匹配 ports 和 from。

    • ingress.from ([]NetworkPolicyPeer)

      from 是流量来源列表,列表中的来源可以访问被此规则选中的 Pod。此列表中的流量来源使用逻辑或操作进行组合。 如果此字段为空值或缺失(未设置), 则此规则匹配所有流量来源(也即允许所有入站流量)。如果此字段存在并且至少包含一项来源,则仅当流量与来自列表中的至少一项匹配时, 此规则才允许流量访问被选中的 Pod 集合。

      NetworkPolicyPeer 描述了允许进出流量的对等点。这个参数只允许某些字段组合。

      • ingress.from.ipBlock (IPBlock)

        ipBlock 针对特定 IPBlock 定义策略。如果设置了此字段,则不可以设置其他字段。

        IPBlock 定义一个特定的 CIDR 范围(例如 192.168.1.0/242001:db8::/64), 来自这个 IP 范围的流量来源将会被允许访问与 NetworkPolicySpec 的 podSelector 匹配的 Pod 集合。 except 字段则设置应排除在此规则之外的 CIDR 范围。

        • ingress.from.ipBlock.cidr (string),必需

          cidr 是表示 IP 组块的字符串,例如 "192.168.1.0/24""2001:db8::/64"

        • ingress.from.ipBlock.except ([]string)

          except 是一个由 CIDR 范围组成的列表,其中指定的 CIDR 都应排除在此 IP 区块范围之外。 例如 "192.168.1.0/24""2001:db8::/64"。 如果 except 字段的值超出 ipBlock.cidr 的范围则被视为无效策略。

      • ingress.from.namespaceSelector (LabelSelector)

        namespaceSelector 使用集群范围标签来选择特定的 Namespace。此字段遵循标准标签选择算符语义; 如果此字段存在但为空值,则会选择所有名字空间。

        如果 podSelector 也被定义了, 那么 NetworkPolicyPeer 将选择那些同时满足 namespaceSelector 所选名字空间下和 podSelector 规则匹配的 Pod。 反之选择 namespaceSelector 所选名字空间下所有的 Pod。

      • ingress.from.podSelector (LabelSelector)

        podSelector 是负责选择 Pod 的标签选择算符。该字段遵循标准标签选择算符语义;如果字段存在但为空值,则选择所有 Pod。

        如果 namespaceSelector 也被定义,那么 NetworkPolicyPeer 将选择那些同时满足 namespaceSelector 定义的名字空间下和 podSelector 规则匹配的 Pod。 反之会在策略所在的名字空间中选择与 podSelector 匹配的 Pod。

    • ingress.ports ([]NetworkPolicyPort)

      ports 是在此规则选中的 Pod 上应可访问的端口列表。此列表中的个项目使用逻辑或操作组合。如果此字段为空或缺失, 则此规则匹配所有端口(进入流量可访问任何端口)。 如果此字段存在并且包含至少一个有效值,则此规则仅在流量至少匹配列表中的一个端口时才允许访问。

      NetworkPolicyPort 定义可以连接的端口

      • ingress.ports.port (IntOrString)

        port 表示符合给定协议的端口。字段值可以是 Pod 上的数字或命名端口。如果未提供此字段,则匹配所有端口名和端口号。 如果定义了,则仅允许对给定的协议和端口的入口流量。

        IntOrString 是一种可以包含 int32 或字符串值的类型。在 JSON 或 YAML 编组和解组中使用时,它会生成或使用内部类型。 例如,这允许你拥有一个可以接受名称或数字的 JSON 字段。

      • ingress.ports.endPort (int32)

        endPort 表示如果设置了此字段,则策略应该允许 port 与 endPort 之间(包含二者)的所有端口。 如果未定义 port 或将 port 字段值为命名端口(字符串),则不可以使用 endPort。 endPort 必须等于或大于 port 值。

      • ingress.ports.protocol (string)

        protocol 表示流量必须匹配的网络协议(TCP、UDP 或 SCTP)。如果未指定,此字段默认为 TCP。

  • egress ([]NetworkPolicyEgressRule)

    egress 是应用到所选 Pod 的出站规则的列表。如果没有 NetworkPolicy 选中指定 Pod(并且其他集群策略也允许出口流量), 或者在所有通过 podSelector 选中了某 Pod 的 NetworkPolicy 中,至少有一条出站规则与出站流量匹配, 则该 Pod 的出站流量是被允许的。 如果此字段为空,则此 NetworkPolicy 拒绝所有出站流量(这策略可以确保它所选中的 Pod 在默认情况下是被隔离的)。 egress 字段在 1.8 中为 Beta 级别。

    NetworkPolicyEgressRule 针对被 NetworkPolicySpec 的 podSelector 所选中 Pod,描述其被允许的出站流量。 流量必须同时匹配 ports 和 to 设置。此类型在 1.8 中为 Beta 级别。

    • egress.to ([]NetworkPolicyPeer)

      to 是针对此规则所选择的 Pod 的出口流量的目的地列表。此列表中的目的地使用逻辑或操作进行组合。如果此字段为空或缺失, 则此规则匹配所有目的地(流量不受目的地限制)。如果此字段存在且至少包含一项目的地,则仅当流量与目标列表中的至少一个匹配时, 此规则才允许出口流量。

      NetworkPolicyPeer 描述允许进出流量的对等点。这个对象只允许某些字段组合。

      • egress.to.ipBlock (IPBlock)

        ipBlock 针对特定的 IP 区块定义策略。如果设置了此字段,则其他不可以设置其他字段。

        IPBlock 描述一个特定的 CIDR 范围(例如 192.168.1.0/242001:db8::/64), 与 NetworkPolicySpec 的 podSelector 匹配的 Pod 将被允许连接到这个 IP 范围,作为其出口流量目的地。 except 字段则设置了不被此规则影响的 CIDR 范围。

        • egress.to.ipBlock.cidr (string),必需

          cidr 是用来表达 IP 组块的字符串,例如 "192.168.1.0/24""2001:db8::/64"

        • egress.to.ipBlock.except ([]string)

          except 定义不应包含在 ipBlock 内的 CIDR 范围列表。例如 "192.168.1.0/24""2001:db8::/64"。 如果 except 的值超出 ipBlock.cidr 的范围则被拒绝。

      • egress.to.namespaceSelector (LabelSelector)

        namespaceSelector 使用集群范围标签来选择特定的名字空间。该字段遵循标准标签选择算符语义; 如果字段存在但为空值,那会选择所有名字空间。

        如果 podSelector 也被定义了, 那么 NetworkPolicyPeer 将选择那些同时满足 namespaceSelector 指定的名字空间下和 podSelector 规则匹配的 Pod。 反之选择 namespaceSelector 指定的名字空间下所有的 Pod。

      • egress.to.podSelector (LabelSelector)

        podSelector 是负责选择一组 Pod 的标签选择算符。该字段遵循标准标签选择算符语义; 如果字段存在但为空值,则选择所有 Pod。

        如果 egress.to.namespaceSelector 也被定义,则 NetworkPolicyPeer 将选择 namespaceSelector 所指定的名字空间下和 podSelector 规则匹配的 Pod。 反之会在策略所属的名字空间中选择与 podSelector 匹配的 Pod。

    • egress.ports ([]NetworkPolicyPort)

      ports 是出站流量目的地的端口列表。此列表中的各个项目使用逻辑或操作进行组合。如果此字段为空或缺失, 则此规则匹配所有端口(可访问出口流量目的地的任何端口)。如果此字段存在并且包含至少一个有效值, 则此规则仅在流量与列表中的至少一个端口匹配时才允许访问。

      NetworkPolicyPort 定义出口流量目的地的端口。

      • egress.ports.port (IntOrString)

        port 表示符合给定协议的端口。字段值可以是 Pod 上的数字或命名端口。如果未提供此字段,则匹配所有端口名和端口号。 如果定义此字段,则仅允许针对给定的协议和端口的出站流量。

        IntOrString 是一种可以包含 int32 或字符串值的类型。在 JSON 或 YAML 编组和解组中使用时,它会生成或使用内部类型。 例如,这允许你拥有一个可以接受名称或数字的 JSON 字段。

      - **egress.ports.endPort** (int32)
      

      如果设置了 endPort,则用来指定策略所允许的从 port 到 endPort 的端口范围(包含边界值)。 如果未设置 port 或 port 字段值为端口名称(字符串),则不可以指定 endPort。 endPort 必须等于或大于 port 值。

      • egress.ports.protocol (string)

        protocol 表示流量必须匹配的网络协议(TCP、UDP 或 SCTP)。如果未指定,此字段默认为 TCP。

NetworkPolicyList

NetworkPolicyList 是 NetworkPolicy 的集合。


  • apiVersion: networking.k8s.io/v1

  • kind: NetworkPolicyList

  • items ([]NetworkPolicy),必需

    items 是 NetworkPolicy 的列表。

操作


get 读取指定的 NetworkPolicy

HTTP 请求

GET /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name}

参数

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

    NetworkPolicy 的名称。

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (NetworkPolicy): OK

401: Unauthorized

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

HTTP 请求

GET /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies

参数

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

    namespace

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

  • watch (查询参数): boolean

    watch

响应

200 (NetworkPolicyList): OK

401: Unauthorized

list 列出或监视 NetworkPolicy 类

HTTP Request

GET /apis/networking.k8s.io/v1/networkpolicies

参数

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

  • watch (查询参数): boolean

    watch

响应

200 (NetworkPolicyList): OK

401: Unauthorized

create 创建 NetworkPolicy

HTTP 请求

POST /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies

参数

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

  • body: NetworkPolicy,必需

响应

200 (NetworkPolicy): OK

201 (NetworkPolicy): Created

202 (NetworkPolicy): Accepted

401: Unauthorized

update 替换指定的 NetworkPolicy

HTTP 请求

PUT /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name}

参数

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

    NetworkPolicy 的名称。

响应

200 (NetworkPolicy): OK

201 (NetworkPolicy): Created

401: Unauthorized

patch 部分更新指定的 NetworkPolicy

HTTP 请求

PATCH /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name}

参数

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

    NetworkPolicy 的名称。

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

    namespace

  • body: Patch,必需

响应

200 (NetworkPolicy): OK

201 (NetworkPolicy): Created

401: Unauthorized

delete 删除 NetworkPolicy

HTTP 请求

DELETE /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name}

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 NetworkPolicy 的集合

HTTP 请求

DELETE /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies

参数

响应

200 (Status): OK

401: Unauthorized

6.4 - PodDisruptionBudget

PodDisruptionBudget 是一个对象,用于定义可能对一组 Pod 造成的最大干扰。

apiVersion: policy/v1

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

PodDisruptionBudget

PodDisruptionBudget 是一个对象,用于定义可能对一组 Pod 造成的最大干扰。


  • apiVersion: policy/v1

  • kind: PodDisruptionBudget

PodDisruptionBudgetSpec

PodDisruptionBudgetSpec 是对 PodDisruptionBudget 的描述。


  • maxUnavailable (IntOrString)

    如果 “selector” 所选中的 Pod 中最多有 “maxUnavailable” Pod 在驱逐后不可用(即去掉被驱逐的 Pod 之后),则允许驱逐。 例如,可以通过将此字段设置为 0 来阻止所有自愿驱逐。此字段是与 “minAvailable” 互斥的设置。

    IntOrString 是一种可以包含 int32 或字符串数值的类型。在 JSON 或 YAML 编组和解组时, 会生成或使用内部类型。例如,此类型允许你定义一个可以接受名称或数字的 JSON 字段。

  • minAvailable (IntOrString)

    如果 “selector” 所选中的 Pod 中,至少 “minAvailable” 个 Pod 在驱逐后仍然可用(即去掉被驱逐的 Pod 之后),则允许驱逐。 因此,你可以通过将此字段设置为 “100%” 来禁止所有自愿驱逐。

    IntOrString 是一种可以包含 int32 或字符串数值的类型。在 JSON 或 YAML 编组和解组时, 会生成或使用内部类型。例如,此类型允许你定义一个可以接受名称或数字的 JSON 字段。

  • selector (LabelSelector)

    标签查询,用来选择其驱逐由干扰预算来管理的 Pod 集合。 选择算符为 null 时将不会匹配任何 Pod,而空 ({}) 选择算符将选中名字空间内的所有 Pod。

  • unhealthyPodEvictionPolicy (string)

    unhealthyPodEvictionPolicy 定义不健康的 Pod 应被考虑驱逐时的标准。 当前的实现将健康的 Pod 视为具有 status.conditions 项且 type="Ready"、status="True" 的 Pod。

    有效的策略是 IfHealthyBudget 和 AlwaysAllow。 如果没有策略被指定,则使用与 IfHealthyBudget 策略对应的默认行为。

    IfHealthyBudget 策略意味着正在运行(status.phase="Running")但还不健康的 Pod 只有在被守护的应用未受干扰(status.currentHealthy 至少等于 status.desiredHealthy) 时才能被驱逐。健康的 Pod 将受到 PDB 的驱逐。

    AlwaysAllow 策略意味着无论是否满足 PDB 中的条件,所有正在运行(status.phase="Running")但还不健康的 Pod 都被视为受干扰且可以被驱逐。这意味着受干扰应用的透视运行 Pod 可能没有机会变得健康。 健康的 Pod 将受到 PDB 的驱逐。

    将来可能会添加其他策略。如果客户端在该字段遇到未识别的策略,则做出驱逐决定的客户端应禁止驱逐不健康的 Pod。

    该字段是 Alpha 级别的。当特性门控 PDBUnhealthyPodEvictionPolicy 被启用(默认禁用)时,驱逐 API 使用此字段。

PodDisruptionBudgetStatus

PodDisruptionBudgetStatus 表示有关此 PodDisruptionBudget 状态的信息。状态可能会反映系统的实际状态。


  • currentHealthy (int32), 必需

    当前健康 Pod 的数量。

  • desiredHealthy (int32), 必需

    健康 Pod 的最小期望值。

  • disruptionsAllowed (int32), 必需

    当前允许的 Pod 干扰计数。

  • expectedPods (int32), 必需

    此干扰预算计入的 Pod 总数

  • conditions ([]Condition)

    补丁策略:根据 type 键执行合并操作

    Map:键 type 的唯一值将在合并期间被保留

    conditions 包含 PDB 的状况。干扰控制器会设置 DisruptionAllowed 状况。 以下是 reason 字段的已知值(将来可能会添加其他原因):

    • SyncFailed:控制器遇到错误并且无法计算允许的干扰计数。因此不允许任何干扰,且状况的状态将变为 False。
    • InsufficientPods:Pod 的数量只能小于或等于 PodDisruptionBudget 要求的数量。 不允许任何干扰,且状况的状态将是 False。
    • SufficientPods:Pod 个数超出 PodDisruptionBudget 所要求的阈值。 此状况为 True 时,基于 disruptsAllowed 属性确定所允许的干扰数目。

    Condition 包含此 API 资源当前状态的一个方面的详细信息。

    • conditions.lastTransitionTime (Time), 必需

      lastTransitionTime 是状况最近一次从一种状态转换到另一种状态的时间。 这种变化通常出现在下层状况发生变化的时候。如果无法了解下层状况变化,使用 API 字段更改的时间也是可以接受的。

      Time 是 time.Time 的包装器,它支持对 YAML 和 JSON 的正确编组。 time 包的许多工厂方法提供了包装器。

    • conditions.message (string), 必需

      message 是一条人类可读的消息,指示有关转换的详细信息。它可能是一个空字符串。

    • conditions.reason (string), 必需

      reason 包含一个程序标识符,指示状况最后一次转换的原因。 特定状况类型的生产者可以定义该字段的预期值和含义,以及这些值是否可被视为有保证的 API。 该值应该是 CamelCase 字符串。此字段不能为空。

    • conditions.status (string), 必需

      状况的状态为 True、False、Unknown 之一。

    • conditions.type (string), 必需

      CamelCase 或 foo.example.com/CamelCase 形式的状况类型。

    • conditions.observedGeneration (int64)

      observedGeneration 表示设置状况时所基于的 .metadata.generation。 例如,如果 .metadata.generation 当前为 12,但 .status.conditions[x].observedGeneration 为 9, 则状况相对于实例的当前状态已过期。

  • disruptedPods (map[string]Time)

    disruptedPods 包含有关 Pod 的一些信息,这些 Pod 的驱逐操作已由 API 服务器上的 eviction 子资源处理程序处理, 但尚未被 PodDisruptionBudget 控制器观察到。 从 API 服务器处理驱逐请求到 PDB 控制器看到该 Pod 已标记为删除(或超时后),Pod 将记录在此映射中。 映射中的键名是 Pod 的名称,键值是 API 服务器处理驱逐请求的时间。 如果删除没有发生并且 Pod 仍然存在,PodDisruptionBudget 控制器将在一段时间后自动将 Pod 从列表中删除。 如果一切顺利,此映射大部分时间应该是空的。映射中的存在大量条目可能表明 Pod 删除存在问题。

    Time 是 time.Time 的包装器,它支持对 YAML 和 JSON 的正确编组。 time 包的许多工厂方法提供了包装器。

  • observedGeneration (int64)

    更新此 PDB 状态时观察到的最新一代。 DisruptionsAllowed 和其他状态信息仅在 observedGeneration 等于 PDB 的对象的代数时才有效。

PodDisruptionBudgetList

PodDisruptionBudgetList 是 PodDisruptionBudget 的集合。


  • apiVersion: policy/v1

  • kind: PodDisruptionBudgetList

操作


get 读取指定的 PodDisruptionBudget

HTTP 请求

GET /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets/{name}

参数

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

    PodDisruptionBudget 的名称。

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (PodDisruptionBudget): OK

401: Unauthorized

get 读取指定 PodDisruptionBudget 的状态

HTTP 请求

GET /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets/{name}/status

参数

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

    PodDisruptionBudget 的名称。

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (PodDisruptionBudget): OK

401: Unauthorized

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

HTTP 请求

GET /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets

参数

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

    namespace

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

  • watch (查询参数): boolean

    watch

响应

200 (PodDisruptionBudgetList): OK

401: Unauthorized

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

HTTP 请求

GET /apis/policy/v1/poddisruptionbudgets

参数

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

  • watch (查询参数): boolean

    watch

响应

200 (PodDisruptionBudgetList): OK

401: Unauthorized

create 创建一个 PodDisruptionBudget

HTTP 请求

POST /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets

参数

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

    namespace

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

202 (PodDisruptionBudget): Accepted

401: Unauthorized

update 替换指定的 PodDisruptionBudget

HTTP 请求

PUT /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets/{name}

参数

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

    PodDisruptionBudget 的名称。

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

    namespace

  • dryRun (查询参数): string

    dryRun

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

401: Unauthorized

update 替换指定 PodDisruptionBudget 的状态

HTTP 请求

PUT /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets/{name}/status

参数

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

    PodDisruptionBudget 的名称。

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

    namespace

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

401: Unauthorized

patch 部分更新指定的 PodDisruptionBudget

HTTP 请求

PATCH /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets/{name}

参数

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

    PodDisruptionBudget 的名称

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

    namespace

  • dryRun (查询参数): string

    dryRun

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

401: Unauthorized

patch 部分更新指定 PodDisruptionBudget 的状态

HTTP 请求

PATCH /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets/{name}/status

参数

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

    PodDisruptionBudget 的名称。

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

    namespace

  • dryRun (查询参数): string

    dryRun

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

401: Unauthorized

delete 删除 PodDisruptionBudget

HTTP 请求

DELETE /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets/{name}

参数

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

    PodDisruptionBudget 的名称。

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 PodDisruptionBudget 的集合

HTTP Request

DELETE /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets

参数

  • dryRun (查询参数): string

    dryRun

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

响应

200 (Status): OK

401: Unauthorized

6.5 - IPAddress v1alpha1

IPAddress 表示单个 IP 族的单个 IP。

apiVersion: networking.k8s.io/v1alpha1

import "k8s.io/api/networking/v1alpha1"

IPAddress

IPAddress 表示单个 IP 族的单个 IP。此对象旨在供操作 IP 地址的 API 使用。 此对象由 Service 核心 API 用于分配 IP 地址。 IP 地址可以用不同的格式表示,为了保证 IP 地址的唯一性,此对象的名称是格式规范的 IP 地址。 IPv4 地址由点分隔的四个十进制数字组成,前导零可省略;IPv6 地址按照 RFC 5952 的定义来表示。 有效值:192.168.1.5、2001:db8::1 或 2001:db8:aaaa:bbbb:cccc:dddd:eeee:1。 无效值:10.01.2.3 或 2001:db8:0:0:0::1。


  • apiVersion: networking.k8s.io/v1alpha1

  • kind: IPAddress

IPAddressSpec

IPAddressSpec 描述 IP 地址中的属性。


  • parentRef (ParentReference)

    parentRef 引用挂接 IPAddress 的资源。IPAddress 必须引用一个父对象。

    ParentReference 描述指向父对象的引用。

    • parentRef.group (string)

      group 是被引用的对象的组。

    • parentRef.name (string)

      name 是被引用的对象的名称。

    • parentRef.namespace (string)

      namespace 是被引用的对象的名字空间。

    • parentRef.resource (string)

      resource 是被引用的对象的资源。

    • parentRef.uid (string)

      uid 是被引用的对象的唯一标识符(uid)。

IPAddressList

IPAddressList 包含 IPAddress 的列表。


  • apiVersion: networking.k8s.io/v1alpha1

  • kind: IPAddressList

操作


get 读取指定的 IPAddress

HTTP 请求

GET /apis/networking.k8s.io/v1alpha1/ipaddresses/{name}

参数

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

    IPAddress 的名称。

  • pretty查询参数):string

    pretty

响应

200 (IPAddress): OK

401: Unauthorized

list 列举或监视类别为 IPAddress 的对象

HTTP 请求

GET /apis/networking.k8s.io/v1alpha1/ipaddresses

参数

响应

200 (IPAddressList): OK

401: Unauthorized

create 创建 IPAddress

HTTP 请求

POST /apis/networking.k8s.io/v1alpha1/ipaddresses

参数

响应

200 (IPAddress): OK

201 (IPAddress): Created

202 (IPAddress): Accepted

401: Unauthorized

update 替换指定的 IPAddress

HTTP 请求

PUT /apis/networking.k8s.io/v1alpha1/ipaddresses/{name}

参数

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

    IPAddress 的名称。

  • body: IPAddress,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • pretty查询参数):string

    pretty

响应

200 (IPAddress): OK

201 (IPAddress): Created

401: Unauthorized

patch 部分更新指定的 IPAddress

HTTP 请求

PATCH /apis/networking.k8s.io/v1alpha1/ipaddresses/{name}

参数

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

    IPAddress 的名称。

  • body: Patch,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (IPAddress): OK

201 (IPAddress): Created

401: Unauthorized

delete 删除 IPAddress

HTTP 请求

DELETE /apis/networking.k8s.io/v1alpha1/ipaddresses/{name}

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 IPAddress 的集合

HTTP 请求

DELETE /apis/networking.k8s.io/v1alpha1/ipaddresses

参数

响应

200 (Status): OK

401: Unauthorized

7 - 扩展资源

7.1 - CustomResourceDefinition

CustomResourceDefinition 表示应在 API 服务器上公开的资源。

apiVersion: apiextensions.k8s.io/v1

import "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"

CustomResourceDefinition

CustomResourceDefinition 表示应在 API 服务器上公开的资源。其名称必须采用 <.spec.name>.<.spec.group> 格式。


CustomResourceDefinitionSpec

CustomResourceDefinitionSpec 描述了用户希望资源的呈现方式。


  • group (string),必需

    group 是自定义资源的 API 组。自定义资源在 /apis/<group>/... 下提供。 必须与 CustomResourceDefinition 的名称匹配(格式为 <names.plural>.<group>)。

  • names (CustomResourceDefinitionNames),必需

    names 表示自定义资源的资源和种类名称。

    CustomResourceDefinitionNames 表示提供此 CustomResourceDefinition 资源的名称。

    • names.kind (string),必需

      kind 是资源的序列化类型。它通常是驼峰命名的单数形式。自定义资源实例将使用此值作为 API 调用中的 kind 属性。

    • names.plural (string),必需

      plural 是所提供的资源的复数名称,自定义资源在 /apis/<group>/<version>/.../<plural> 下提供。 必须与 CustomResourceDefinition 的名称匹配(格式为 <names.plural>.<group>)。必须全部小写。

    • names.categories ([]string)

      categories 是自定义资源所属的分组资源列表(例如 'all')。 它在 API 发现文档中发布,并支持客户端像 kubectl get all 这样的调用。

    • names.listKind (string)

      listKind 是此资源列表的序列化类型。默认为 "kindList"。

    • names.shortNames ([]string)

      shortNames 是资源的短名称,在 API 发现文档中公开,并支持客户端调用,如 kubectl get <shortname>。必须全部小写。

    • names.singular (string)

      singular 是资源的单数名称。必须全部小写。默认为小写 kind

  • scope (string),必需

    scope 表示自定义资源是集群作用域还是命名空间作用域。允许的值为 ClusterNamespaced

  • versions ([]CustomResourceDefinitionVersion),必需

    versions 是自定义资源的所有 API 版本的列表。版本名称用于计算服务版本在 API 发现中列出的顺序。 如果版本字符串与 Kubernetes 的版本号形式类似,则它将被排序在非 Kubernetes 形式版本字符串之前。 Kubernetes 的版本号字符串按字典顺序排列。Kubernetes 版本号以 “v” 字符开头, 后面是一个数字(主版本),然后是可选字符串 “alpha” 或 “beta” 和另一个数字(次要版本)。 它们首先按 GA > beta > alpha 排序(其中 GA 是没有 beta 或 alpha 等后缀的版本),然后比较主要版本, 最后是比较次要版本。版本排序列表示例:v10、v2、v1、v11beta2、v10beta3、v3beta1、v12alpha1、v11alpha2、foo1、foo10。

    CustomResourceDefinitionVersion 描述 CRD 的一个版本。

    • versions.name (string),必需

      name 是版本名称,例如 “v1”、“v2beta1” 等。如果 served 是 true,自定义资源在 /apis/<group>/<version>/... 版本下提供。

    • versions.served (boolean),必需

      served 是用于启用/禁用该版本通过 REST API 提供服务的标志。

    • versions.storage (boolean),必需

      storage 表示在将自定义资源持久保存到存储时,应使用此版本。有且仅有一个版本的 storage=true。

    • versions.additionalPrinterColumns ([]CustomResourceColumnDefinition)

      additionalPrinterColumns 表示在表输出中返回的附加列。 有关详细信息,请参阅 https://kubernetes.io/zh-cn/docs/reference/using-api/api-concepts/#receiving-resources-as-tables。 如果没有指定列,则显示自定义资源存活时间(AGE)列。

      CustomResourceColumnDefinition 指定用于服务器端打印的列。

      • versions.additionalPrinterColumns.jsonPath (string),必需

        jsonPath 是一个简单的 JSON 路径(使用数组表示法),它对每个自定义资源进行评估,以生成该列的值。

      • versions.additionalPrinterColumns.name (string),必需

        name 是便于阅读的列名称。

      • versions.additionalPrinterColumns.type (string),必需

        type 是此列的 OpenAPI 类型定义。有关详细信息, 请参阅 https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types

      • versions.additionalPrinterColumns.description (string)

        description 是该列的可读性描述。

      • versions.additionalPrinterColumns.format (string)

        format 是这个列的可选 OpenAPI 类型定义。'name' 格式应用于主标识符列,以帮助客户端识别列是资源名称。 有关详细信息,请参阅 https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types

      • versions.additionalPrinterColumns.priority (int32)

        priority 是一个定义此列相对于其他列的相对重要性的整数。数字越低,优先级越高。 在空间有限的情况下,可以省略的列的优先级应大于 0。

    • versions.deprecated (boolean)

      deprecated 表示此版本的自定义资源 API 已弃用。设置为 true 时,对此版本的 API 请求会在服务器响应头信息中带有警告(warning)信息。此值默认为 false。

    • versions.deprecationWarning (string)

      deprecationWarning 会覆盖返回给 API 客户端的默认警告。只能在 deprecated 为 true 时设置。 默认警告表示此版本已弃用,建议使用最新的同等或更高稳定性版本(如果存在)。

    • versions.schema (CustomResourceValidation)

      schema 描述了用于验证、精简和默认此版本的自定义资源的模式。

      CustomResourceValidation 是 CustomResources 的验证方法列表。

      • versions.schema.openAPIV3Schema (JSONSchemaProps)

        openAPIV3Schema 是用于验证和精简的 OpenAPI v3 模式。

    • versions.subresources (CustomResourceSubresources)

      subresources 指定此版本已定义的自定义资源具有哪些子资源。

      CustomResourceSubresources 定义了 CustomResources 子资源的状态和规模。

      • versions.subresources.scale (CustomResourceSubresourceScale)

        scale 表示自定义资源应该提供一个 /scale 子资源,该子资源返回一个 autoscaling/v1 Scale 对象。

        CustomResourceSubresourceScale 定义了如何为 CustomResources 的 scale 子资源提供服务。

        • versions.subresources.scale.specReplicasPath (string),必需

          specReplicasPath 定义对应于 Scale 的自定义资源内的 JSON 路径 spec.replicas。 只允许没有数组表示法的 JSON 路径。必须是 .spec 下的 JSON 路径。 如果自定义资源中的给定路径下没有值,那么 GET /scale 子资源将返回错误。

        • versions.subresources.scale.statusReplicasPath (string),必需

          statusReplicasPath 定义对应于 Scale 的自定义资源内的 JSON 路径 status.replicas。 只允许不带数组表示法的 JSON 路径。必须是 .status 下的 JSON 路径。 如果自定义资源中给定路径下没有值,则 /scale 子资源中的 status.replicas 值将默认为 0。

        • versions.subresources.scale.labelSelectorPath (string)

          labelSelectorPath 定义对应于 Scale 的自定义资源内的 JSON 路径 status.selector。 只允许不带数组表示法的 JSON 路径。必须是 .status.spec 下的路径。 必须设置为与 HorizontalPodAutoscaler 一起使用。 此 JSON 路径指向的字段必须是字符串字段(不是复杂的选择器结构),其中包含字符串形式的序列化标签选择器。 更多信息: https://kubernetes.io/zh-cn/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions#scale-subresource。 如果自定义资源中给定路径下没有值,则 /scale 子资源中的 status.selector 默认值为空字符串。

      • versions.subresources.status (CustomResourceSubresourceStatus)

        status 表示自定义资源应该为 /status 子资源服务。当启用时:

        1. 对自定义资源主端点的请求会忽略对对象 status 节的改变;
        2. 对自定义资源 /status 子资源的请求忽略对对象 status 节以外的任何变化。

        CustomResourceSubresourceStatus 定义了如何为自定义资源提供 status 子资源。 状态由 CustomResource 中的 .status JSON 路径表示。设置后,

        • 为自定义资源提供一个 /status 子资源。
        • /status 子资源发出的 PUT 请求时,需要提供自定义资源对象,服务器端会忽略对 status 节以外的任何内容更改。
        • 对自定义资源的 PUT/POST/PATCH 请求会忽略对 status 节的更改。
  • conversion (CustomResourceConversion)

    conversion 定义了 CRD 的转换设置。

    CustomResourceConversion 描述了如何转换不同版本的自定义资源。

    • conversion.strategy (string),必需

      strategy 指定如何在版本之间转换自定义资源。允许的值为:

      • "None":转换器仅更改 apiVersion 并且不会触及自定义资源中的任何其他字段。
      • "Webhook":API 服务器将调用外部 Webhook 进行转换。此选项需要其他信息。这要求 spec.preserveUnknownFields 为 false,并且设置 spec.conversion.webhook。
    • conversion.webhook (WebhookConversion)

      webhook 描述了如何调用转换 Webhook。当 strategy 设置为 "Webhook" 时有效。

      WebhookConversion 描述了如何调用转换 Webhook

      • conversion.webhook.conversionReviewVersions ([]string),必需

        conversionReviewVersions 是 Webhook 期望的 ConversionReview 版本的有序列表。 API 服务器将使用它支持的列表中的第一个版本。如果 API 服务器不支持此列表中指定的版本,则自定义资源的转换将失败。 如果持久化的 Webhook 配置指定了允许的版本但其中不包括 API 服务器所了解的任何版本,则对 Webhook 的调用将失败。

      • conversion.webhook.clientConfig (WebhookClientConfig)

        如果 strategy 是 Webhook,那么 clientConfig 是关于如何调用 Webhook 的说明。

        WebhookClientConfig 包含与 Webhook 建立 TLS 连接的信息。

        • conversion.webhook.clientConfig.caBundle ([]byte)

          caBundle 是一个 PEM 编码的 CA 包,用于验证 Webhook 服务器的服务证书。 如果未指定,则使用 API 服务器上的系统根证书。

        • conversion.webhook.clientConfig.service (ServiceReference)

          service 是对此 Webhook 服务的引用。必须指定 service 或 url 字段之一。

          如果在集群中运行 Webhook,那么你应该使用 service

          ServiceReference 保存对 Service.legacy.k8s.io 的一个引用。

          • conversion.webhook.clientConfig.service.name (string),必需

            name 是服务的名称。必需。

          • conversion.webhook.clientConfig.service.namespace (string),必需

            namespace 是服务的命名空间。必需。

          • conversion.webhook.clientConfig.service.path (string)

            path 是一个可选的 URL 路径,Webhook 将通过该路径联系服务。

          • conversion.webhook.clientConfig.service.port (int32)

            port 是 Webhook 联系的可选服务端口。port 应该是一个有效的端口号(1-65535,包含)。 为实现向后兼容,默认端口号为 443。

        • conversion.webhook.clientConfig.url (string)

          url 以标准 URL 的形式(scheme://host:port/path)给出 Webhook 的位置。urlservice 必须指定一个且只能指定一个。

          host 不应引用集群中运行的服务;若使用集群内服务应改为使用 service 字段。 host 值可能会通过外部 DNS 解析(例如,kube-apiserver 无法解析集群内 DNS,因为这将违反分层规则)。 host 也可能是 IP 地址。

          请注意,使用 localhost127.0.0.1 作为 host 是有风险的, 除非你非常小心地在所有运行 API 服务器的主机上运行这个 Webhook,因为这些 API 服务器可能需要调用这个 Webhook。 这样的安装可能是不可移植的,也就是说,不容易在一个新的集群中复现。

          scheme 必须是 "https";URL 必须以 "https://" 开头。

          路径(path)是可选的,如果存在,则可以是 URL 中允许的任何字符串。 你可以使用路径传递一个任意字符串给 Webhook,例如,一个集群标识符。

          不允许使用用户或基本认证,例如 "user:password@",是不允许的。片段("#...")和查询参数("?...")也是不允许的。

  • preserveUnknownFields (boolean)

    preserveUnknownFields 表示将对象写入持久性存储时应保留 OpenAPI 模式中未规定的对象字段。 apiVersion、kind、元数据(metadata)和元数据中的已知字段始终保留。不推荐使用此字段,而建议在 spec.versions[*].schema.openAPIV3Schema 中设置 x-preserve-unknown-fields 为 true。 更多详细信息参见: https://kubernetes.io/zh-cn/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#field-pruning

JSONSchemaProps

JSONSchemaProps 是JSON 模式(JSON-Schema),遵循其规范草案第 4 版(http://json-schema.org/)。


  • $ref (string)

  • $schema (string)

  • additionalItems (JSONSchemaPropsOrBool)

    JSONSchemaPropsOrBool 表示 JSONSchemaProps 或布尔值。布尔属性默认为 true。

  • additionalProperties (JSONSchemaPropsOrBool)

    JSONSchemaPropsOrBool 表示 JSONSchemaProps 或布尔值。布尔属性默认为 true。

  • allOf ([]JSONSchemaProps)

  • anyOf ([]JSONSchemaProps)

  • default (JSON)

    default 是未定义对象字段的默认值。设置默认值操作是 CustomResourceDefaulting 特性门控所控制的一个 Beta 特性。 应用默认值设置时要求 spec.preserveUnknownFields 为 false。

    JSON 表示任何有效的 JSON 值。支持以下类型:bool、int64、float64、string、[]interface{}、map[string]interface{} 和 nil。

  • definitions (map[string]JSONSchemaProps)

  • dependencies (map[string]JSONSchemaPropsOrStringArray)

    JSONSchemaPropsOrStringArray 表示 JSONSchemaProps 或字符串数组。

  • description (string)

  • enum ([]JSON)

    JSON 表示任何有效的 JSON 值。支持以下类型:bool、int64、float64、string、[]interface{}、map[string]interface{} 和 nil。

  • example (JSON)

    JSON 表示任何有效的 JSON 值。支持以下类型:bool、int64、float64、string、[]interface{}、map[string]interface{} 和 nil。

  • exclusiveMaximum (boolean)

  • exclusiveMinimum (boolean)

  • externalDocs (ExternalDocumentation)

    ExternalDocumentation 允许引用外部资源作为扩展文档。

    • externalDocs.description (string)

    • externalDocs.url (string)

  • format (string)

    format 是 OpenAPI v3 格式字符串。未知格式将被忽略。以下格式会被验证合法性:

    • bsonobjectid:一个 bson 对象的 ID,即一个 24 个字符的十六进制字符串
    • uri:由 Go 语言 net/url.ParseRequestURI 解析得到的 URI
    • email:由 Go 语言 net/mail.ParseAddress 解析得到的电子邮件地址
    • hostname:互联网主机名的有效表示,由 RFC 1034 第 3.1 节 [RFC1034] 定义
    • ipv4:由 Go 语言 net.ParseIP 解析得到的 IPv4 协议的 IP
    • ipv6:由 Go 语言 net.ParseIP 解析得到的 IPv6 协议的 IP
    • cidr:由 Go 语言 net.ParseCIDR 解析得到的 CIDR
    • mac:由 Go 语言 net.ParseMAC 解析得到的一个 MAC 地址
    • uuid:UUID,允许大写字母,满足正则表达式 (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$
    • uuid3:UUID3,允许大写字母,满足正则表达式 (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?3[0-9a-f]{3}-?[0-9a-f]{4}-?[0-9a-f]{12}$
    • uuid4:UUID4,允许大写字母,满足正则表达式 (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?4[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$
    • uuid5:UUID5,允许大写字母,满足正则表达式 (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?5[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$
    • isbn:一个 ISBN10 或 ISBN13 数字字符串,如 "0321751043" 或 "978-0321751041"
    • isbn10:一个 ISBN10 数字字符串,如 "0321751043"
    • isbn13:一个 ISBN13 号码字符串,如 "978-0321751041"
    • creditcard:信用卡号码,满足正则表达式 ^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$, 其中混合任意非数字字符
    • ssn:美国社会安全号码,满足正则表达式 ^\d{3}[- ]?\d{2}[- ]?\d{4}$
    • hexcolor:一个十六进制的颜色编码,如 "#FFFFFF",满足正则表达式 ^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
    • rgbcolor:一个 RGB 颜色编码 例如 "rgb(255,255,255)"
    • byte:base64 编码的二进制数据
    • password:任何类型的字符串
    • date:类似 "2006-01-02" 的日期字符串,由 RFC3339 中的完整日期定义
    • duration:由 Go 语言 time.ParseDuration 解析的持续时长字符串,如 "22 ns",或与 Scala 持续时间格式兼容。
    • datetime:一个日期时间字符串,如 "2014-12-15T19:30:20.000Z",由 RFC3339 中的 date-time 定义。
  • id (string)

  • items (JSONSchemaPropsOrArray)

    JSONSchemaPropsOrArray 表示可以是 JSONSchemaProps 或 JSONSchemaProps 数组的值。这里目的主要用于序列化。

  • maxItems (int64)

  • maxLength (int64)

  • maxProperties (int64)

  • maximum (double)

  • minItems (int64)

  • minLength (int64)

  • minProperties (int64)

  • minimum (double)

  • multipleOf (double)

  • not (JSONSchemaProps)

  • nullable (boolean)

  • oneOf ([]JSONSchemaProps)

  • pattern (string)

  • patternProperties (map[string]JSONSchemaProps)

  • properties (map[string]JSONSchemaProps)

  • required ([]string)

  • title (string)

  • type (string)

  • uniqueItems (boolean)

  • x-kubernetes-embedded-resource (boolean)

    x-kubernetes-embedded-resource 定义该值是一个嵌入式 Kubernetes runtime.Object,具有 TypeMeta 和 ObjectMeta。 类型必须是对象。允许进一步限制嵌入对象。会自动验证 kind、apiVersion 和 metadata 等字段值。 x-kubernetes-preserve-unknown-fields 允许为 true,但如果对象已完全指定 (除 kind、apiVersion、metadata 之外),则不必为 true。

  • x-kubernetes-int-or-string (boolean)

    x-kubernetes-int-or-string 指定此值是整数或字符串。如果为 true,则允许使用空类型, 并且如果遵循以下模式之一,则允许作为 anyOf 的子类型:

    1. anyOf:
      • type: integer
      • type: string
    2. allOf:
      • anyOf:
        • type: integer
        • type: string
      • (可以有选择地包含其他类型)
  • x-kubernetes-list-map-keys ([]string)

    X-kubernetes-list-map-keys 通过指定用作 map 索引的键来使用 x-kubernetes-list-type map 注解数组。

    这个标签必须只用于 "x-kubernetes-list-type" 扩展设置为 "map" 的列表。 而且,为这个属性指定的值必须是子结构的标量类型的字段(不支持嵌套)。

    指定的属性必须是必需的或具有默认值,以确保所有列表项都存在这些属性。

  • x-kubernetes-list-type (string)

    x-kubernetes-list-type 注解一个数组以进一步描述其拓扑。此扩展名只能用于列表,并且可能有 3 个可能的值:

    1. atomic: 列表被视为单个实体,就像标量一样。原子列表在更新时将被完全替换。这个扩展可以用于任何类型的列表(结构,标量,…)。
    2. set: set 是不能有多个具有相同值的列表。每个值必须是标量、具有 x-kubernetes-map-type atomic 的对象或具有 x-kubernetes-list-type atomic 的数组。
    3. map: 这些列表类似于映射表,因为它们的元素具有用于标识它们的非索引键。合并时保留顺序。 map 标记只能用于元数类型为 object 的列表。 数组默认为原子数组。
  • x-kubernetes-map-type (string)

    x-kubernetes-map-type 注解一个对象以进一步描述其拓扑。此扩展只能在 type 为 object 时使用,并且可能有 2 个可能的值:

    1. granular: 这些 map 是真实的映射(键值对),每个字段都是相互独立的(它们都可以由不同的角色来操作)。 这是所有 map 的默认行为。
    2. atomic:map 被视为单个实体,就像标量一样。原子 map 更新后将被完全替换。
  • x-kubernetes-preserve-unknown-fields (boolean)

    x-kubernetes-preserve-unknown-fields 针对未在验证模式中指定的字段,禁止 API 服务器的解码步骤剪除这些字段。 这一设置对字段的影响是递归的,但在模式中指定了嵌套 properties 或 additionalProperties 时,会切换回正常的字段剪除行为。 该值可为 true 或 undefined,不能为 false。

  • x-kubernetes-validations ([]ValidationRule)

    补丁策略:基于键 rule 合并

    Map:合并时将保留 rule 键的唯一值

    x-kubernetes-validations 描述了用 CEL 表达式语言编写的验证规则列表。此字段是 Alpha 级别。 使用此字段需要启用 CustomResourceValidationExpressions 特性门控。

    ValidationRule 描述用 CEL 表达式语言编写的验证规则。

    • x-kubernetes-validations.rule (string),必需

      rule 表示将由 CEL 评估的表达式。参考: https://github.com/google/cel-spec。 rule 的作用域为模式中的 x-kubernetes-validation 扩展所在的位置。CEL 表达式中的 self 与作用域值绑定。 例子:rule 的作用域是一个具有状态子资源的资源根:{"rule": "self.status.actual <= self.spec.maxDesired"}。

      如果 rule 的作用域是一个带有属性的对象,那么该对象的可访问属性是通过 self 进行字段选择的, 并且可以通过 has(self.field) 来检查字段是否存在。在 CEL 表达式中,Null 字段被视为不存在的字段。 如果该 rule 的作用域是一个带有附加属性的对象(例如一个 map),那么该 map 的值可以通过 self[mapKey]来访问,map 是否包含某主键可以通过 mapKey in self 来检查。 map 中的所有条目都可以通过 CEL 宏和函数(如 self.all(...))访问。 如果 rule 的作用域是一个数组,数组的元素可以通过 self[i] 访问,也可以通过宏和函数访问。 如果 rule 的作用域为标量,self 绑定到标量值。举例:

      • rule 作用域为对象映射:{"rule": "self.components['Widget'].priority < 10"}
      • rule 作用域为整数列表:{"rule": "self.values.all(value, value >= 0 && value < 100)"}
      • rule 作用域为字符串值:{"rule": "self.startsWith('kube')"}

      apiVersionkindmetadata.namemetadata.generateName 总是可以从对象的根和任何带 x-kubernetes-embedded-resource 注解的对象访问。其他元数据属性都无法访问。

      在 CEL 表达式中无法访问通过 x-kubernetes-preserve-unknown-fields 保存在自定义资源中的未知数据。 这包括:

      • 由包含 x-kubernetes-preserve-unknown-fields 的对象模式所保留的未知字段值;

      • 属性模式为 "未知类型" 的对象属性。"未知类型" 递归定义为:

        • 没有设置 type 但 x-kubernetes-preserve-unknown-fields 设置为 true 的模式。
        • 条目模式为"未知类型"的数组。
        • additionalProperties 模式为"未知类型"的对象。

      只有名称符合正则表达式 [a-zA-Z_.-/][a-zA-Z0-9_.-/]* 的属性才可被访问。 在表达式中访问属性时,可访问的属性名称根据以下规则进行转义:

      • '__' 转义为 'underscores'

      • '.' 转义为 'dot'

      • '-' 转义为 'dash'

      • '/' 转义为 'slash'

      • 恰好匹配 CEL 保留关键字的属性名称转义为 '{keyword}' 。这里的关键字具体包括: "true","false","null","in","as","break","const","continue","else","for","function","if", "import","let","loop","package","namespace","return"。 举例:

        • 规则访问名为 "namespace" 的属性:{"rule": "self.__namespace__ > 0"}
        • 规则访问名为 "x-prop" 的属性:{"rule": "self.x__dash__prop > 0"}
        • 规则访问名为 "redact__d" 的属性:{"rule": "self.redact__underscores__d > 0"}

      对 x-kubernetes-list-type 为 'set' 或 'map' 的数组进行比较时忽略元素顺序,如:[1, 2] == [2, 1]。 使用 x-kubernetes-list-type 对数组进行串接使用下列类型的语义:

      • 'set':X + Y 执行合并,其中 X 保留所有元素的数组位置,并附加不相交的元素 Y,保留其局部顺序。
      • 'map':X + Y 执行合并,保留 X 中所有键的数组位置,但当 XY 的键集相交时,会被 Y 中的值覆盖。 添加 Y 中具有不相交键的元素,保持其局顺序。
    • x-kubernetes-validations.fieldPath (string)

      fieldPath 表示验证失败时返回的字段路径。 它必须是相对 JSON 路径(即,支持数组表示法),范围仅限于此 x-kubernetes-validations 扩展在模式的位置,并引用现有字段。 例如,当验证检查 testMap 映射下是否有 foo 属性时,可以将 fieldPath 设置为 .testMap.foo。 如果验证需要确保两个列表具有各不相同的属性,则可以将 fieldPath 设置到其中任一列表,例如 .testList。 它支持使用子操作引用现有字段,而不支持列表的数字索引。 有关更多信息,请参阅 Kubernetes 中的 JSONPath 支持。 因为其不支持数组的数字索引,所以对于包含特殊字符的字段名称,请使用 ['specialName'] 来引用字段名称。 例如,对于出现在列表 testList 中的属性 foo.34$,fieldPath 可以设置为 .testList['foo.34$']

    • x-kubernetes-validations.message (string)

      message 表示验证失败时显示的消息。如果规则包含换行符,则需要该消息。消息不能包含换行符。 如果未设置,则消息为 "failed rule: {Rule}",如:"must be a URL with the host matching spec.host"

    • x-kubernetes-validations.messageExpression (string)

      messageExpression 声明一个 CEL 表达式,其计算结果是此规则失败时返回的验证失败消息。 由于 messageExpression 用作失败消息,因此它的值必须是一个字符串。 如果在规则中同时存在 message 和 messageExpression,则在验证失败时使用 messageExpression。 如果是 messageExpression 出现运行时错误,则会记录运行时错误,并生成验证失败消息, 就好像未设置 messageExpression 字段一样。如果 messageExpression 求值为空字符串、 只包含空格的字符串或包含换行符的字符串,则验证失败消息也将像未设置 messageExpression 字段一样生成, 并记录 messageExpression 生成空字符串/只包含空格的字符串/包含换行符的字符串的事实。 messageExpression 可以访问的变量与规则相同;唯一的区别是返回类型。 例如:"x must be less than max ("+string(self.max)+")"。

    • x-kubernetes-validations.reason (string)

      reason 提供机器可读的验证失败原因,当请求未通过此验证规则时,该原因会返回给调用者。 返回给调用者的 HTTP 状态代码将与第一个失败的验证规则的原因相匹配。 目前支持的原因有:FieldValueInvalidFieldValueForbiddenFieldValueRequiredFieldValueDuplicate。 如果未设置,则默认使用 FieldValueInvalid。 所有未来添加的原因在读取该值时必须被客户端接受,未知原因应被视为 FieldValueInvalid

CustomResourceDefinitionStatus

CustomResourceDefinitionStatus 表示 CustomResourceDefinition 的状态。


  • acceptedNames (CustomResourceDefinitionNames)

    acceptedNames 是实际用于服务发现的名称。它们可能与规约(spec)中的名称不同。

    CustomResourceDefinitionNames 表示提供此 CustomResourceDefinition 资源的名称。

    • acceptedNames.kind (string),必需

      kind 是资源的序列化类型。它通常是驼峰命名的单数形式。自定义资源实例将使用此值作为 API 调用中的 kind 属性。

    • acceptedNames.plural (string),必需

      plural 是所提供的资源的复数名称,自定义资源在 /apis/<group>/<version>/.../<plural> 下提供。 必须与 CustomResourceDefinition 的名称匹配(格式为 <names.plural>.<group>)。必须全部小写。

    • acceptedNames.categories ([]string)

      categories 是此自定义资源所属的分组资源列表(例如 'all')。 它在 API 发现文档中发布,并被客户端用于支持像 kubectl get all 这样的调用。

    • acceptedNames.listKind (string)

      listKind 是此资源列表的序列化类型。默认为 "<kind>List"。

    • acceptedNames.shortNames ([]string)

      shortNames 是资源的短名称,在 API 发现文档中公开,并支持客户端调用,如 kubectl get <shortname>。必须全部小写。

    • acceptedNames.singular (string)

      singular 是资源的单数名称。必须全部小写。默认为小写形式的 kind

  • conditions ([]CustomResourceDefinitionCondition)

    Map:合并时将保留 type 键的唯一值

    conditions 表示 CustomResourceDefinition 特定方面的状态

    CustomResourceDefinitionCondition 包含此 Pod 当前状况的详细信息。

    • conditions.status (string),必需

      status 表示状况(Condition)的状态,取值为 True、False 或 Unknown 之一。

    • conditions.type (string),必需

      type 是条件的类型。类型包括:Established、NamesAccepted 和 Terminating。

    • conditions.lastTransitionTime (Time)

      lastTransitionTime 是上一次发生状况状态转换的时间。

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

    • conditions.message (string)

      message 是有关上次转换的详细可读信息。

    • conditions.reason (string)

      reason 表述状况上次转换原因的、驼峰格式命名的、唯一的一个词。

  • storedVersions ([]string)

    storedVersions 列出了曾经被持久化的所有 CustomResources 版本。跟踪这些版本可以为 etcd 中的存储版本提供迁移路径。 该字段是可变的,因此迁移控制器可以完成到另一个版本的迁移(确保存储中没有遗留旧对象),然后从该列表中删除其余版本。 当版本在此列表中时,则不能从 spec.versions 中删除。

CustomResourceDefinitionList

CustomResourceDefinitionList 是 CustomResourceDefinition 对象的列表。


Operations


get 读取指定的 CustomResourceDefinition

HTTP 请求

GET /apis/apiextensions.k8s.io/v1/customresourcedefinitions/{name}

参数

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

    CustomResourceDefinition 的名称。

  • pretty查询参数):string

    pretty

响应

200 (CustomResourceDefinition): OK

401: Unauthorized

get 读取指定 CustomResourceDefinition 的状态

HTTP 请求

GET /apis/apiextensions.k8s.io/v1/customresourcedefinitions/{name}/status

参数

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

    CustomResourceDefinition 的名称。

  • pretty查询参数):string

    pretty

响应

200 (CustomResourceDefinition): OK

401: Unauthorized

list 列出或观察 CustomResourceDefinition 类型的对象

HTTP 请求

GET /apis/apiextensions.k8s.io/v1/customresourcedefinitions

参数

响应

200 (CustomResourceDefinitionList): OK

401: Unauthorized

create 创建一个 CustomResourceDefinition

HTTP 请求

POST /apis/apiextensions.k8s.io/v1/customresourcedefinitions

参数

响应

200 (CustomResourceDefinition): OK

201 (CustomResourceDefinition): Created

202 (CustomResourceDefinition): Accepted

401: Unauthorized

update 替换指定的 CustomResourceDefinition

HTTP 请求

PUT /apis/apiextensions.k8s.io/v1/customresourcedefinitions/{name}

参数

响应

200 (CustomResourceDefinition): OK

201 (CustomResourceDefinition): Created

401: Unauthorized

update 替换指定 CustomResourceDefinition 的状态

HTTP 请求

PUT /apis/apiextensions.k8s.io/v1/customresourcedefinitions/{name}/status

参数

响应

200 (CustomResourceDefinition): OK

201 (CustomResourceDefinition): Created

401: Unauthorized

patch 部分更新指定的 CustomResourceDefinition

HTTP 请求

PATCH /apis/apiextensions.k8s.io/v1/customresourcedefinitions/{name}

参数

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

    CustomResourceDefinition 的名称。

  • bodyPatch,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (CustomResourceDefinition): OK

201 (CustomResourceDefinition): Created

401: Unauthorized

patch 部分更新指定 CustomResourceDefinition 的状态

HTTP 请求

PATCH /apis/apiextensions.k8s.io/v1/customresourcedefinitions/{name}/status

参数

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

    CustomResourceDefinition 的名称。

  • bodyPatch,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (CustomResourceDefinition): OK

201 (CustomResourceDefinition): Created

401: Unauthorized

delete 删除一个 CustomResourceDefinition

HTTP 请求

DELETE /apis/apiextensions.k8s.io/v1/customresourcedefinitions/{name}

参数

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

    CustomResourceDefinition 的名称。

  • bodyDeleteOptions

  • dryRun查询参数):string

    dryRun

  • gracePeriodSeconds查询参数):integer

    gracePeriodSeconds

  • pretty查询参数):string

    pretty

  • propagationPolicy查询参数):string

    propagationPolicy

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 CustomResourceDefinition 的集合

HTTP 请求

DELETE /apis/apiextensions.k8s.io/v1/customresourcedefinitions

参数

响应

200 (Status): OK

401: Unauthorized

7.2 - MutatingWebhookConfiguration

MutatingWebhookConfiguration 描述准入 Webhook 的配置,该 Webhook 可在更改对象的情况下接受或拒绝对象请求

apiVersion: admissionregistration.k8s.io/v1

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

MutatingWebhookConfiguration

MutatingWebhookConfiguration 描述准入 Webhook 的配置,该 Webhook 可接受或拒绝对象请求,并且可能变更对象。


  • apiVersion:admissionregistration.k8s.io/v1

  • kind:MutatingWebhookConfiguration

  • webhooks ([]MutatingWebhook)

    补丁策略:根据 name 键执行合并操作

    webhooks 是 Webhook 及其所影响的资源和操作的列表。

    MutatingWebhook 描述了一个准入 Webhook 及其适用的资源和操作。

    • webhooks.admissionReviewVersions ([]string), 必需

      admissionReviewVersions 是 Webhook 期望的 AdmissionReview 版本的优选顺序列表。 API 服务器将尝试使用它所支持的版本列表中的第一个版本。如果 API 服务器不支持此列表中设置的任何版本,则此对象将验证失败。 如果持久化的 Webhook 配置指定了所允许的版本,但其中不包括 API 服务器所知道的任何版本, 则对 Webhook 的调用将失败并根据失败策略进行处理。

    • webhooks.clientConfig (WebhookClientConfig), 必需

      clientConfig 定义了如何与 Webhook 通信。必需。

      WebhookClientConfig 包含与 Webhook 建立 TLS 连接的信息

      • webhooks.clientConfig.caBundle ([]byte)

        caBundle 是一个 PEM 编码的 CA 包,将用于验证 Webhook 的服务证书。如果未指定,则使用 apiserver 上的系统信任根。

      • webhooks.clientConfig.service (ServiceReference)

        service 是对此 Webhook 的服务的引用。必须指定 serviceurl 之一。

        如果 Webhook 在集群中运行,那么你应该使用 service

        ServiceReference 包含对 Service.legacy.k8s.io 的引用

        • webhooks.clientConfig.service.name (string), 必需

          name 是服务的名称。必需。

        • webhooks.clientConfig.service.namespace (string), 必需

          namespace 是服务的命名空间。必需。

        • webhooks.clientConfig.service.path (string)

          path 是一个可选的 URL 路径,在针对此服务的所有请求中都会发送此路径。

        • webhooks.clientConfig.service.port (int32)

          如果指定了,则为托管 Webhook 的服务上的端口。默认为 443 以实现向后兼容。 port 应该是一个有效的端口号(包括 1-65535)。

      • webhooks.clientConfig.url (string)

        url 以标准 URL 形式(scheme://host:port/path)给出了 Webhook 的位置。必须指定 urlservice 中的一个。

        host 不能用来引用集群中运行的服务;这种情况应改用 service 字段。在某些 API 服务器上,可能会通过外部 DNS 解析 host 值。 (例如,kube-apiserver 无法解析集群内 DNS,因为这会违反分层原理)。host 也可以是 IP 地址。

        请注意,使用 localhost127.0.0.1 作为 host 是有风险的,除非你非常小心地在运行 apiserver 的所有主机上运行此 Webhook, 而这些 API 服务器可能需要调用此 Webhook。此类部署可能是不可移植的,即不容易在新集群中重复安装。

        该方案必须是 “https”;URL 必须以 “https://” 开头。

        路径是可选的,如果存在,可以是 URL 中允许的任何字符串。你可以使用路径将任意字符串传递给 Webhook,例如集群标识符。

        不允许使用用户或基本身份验证,例如不允许使用 “user:password@”。 不允许使用片段(“#...”)和查询参数(“?...”)。

    • webhooks.name (string), 必需

      准入 Webhook 的名称。应该是完全限定的名称,例如 imagepolicy.kubernetes.io,其中 “imagepolicy” 是 Webhook 的名称, kubernetes.io 是组织的名称。必需。

    • webhooks.sideEffects (string), 必需

      sideEffects 说明此 Webhook 是否有副作用。可接受的值为:None、NoneOnDryRun (通过 v1beta1 创建的 Webhook 也可以指定 Some 或 Unknown)。 具有副作用的 Webhook 必须实现协调系统,因为请求可能会被准入链中的未来步骤拒绝,因此需要能够撤消副作用。 如果请求与带有 sideEffects == Unknown 或 Some 的 Webhook 匹配,则带有 dryRun 属性的请求将被自动拒绝。

    • webhooks.failurePolicy (string)

      failurePolicy 定义如何处理来自准入端点的无法识别的错误 - 允许的值是 Ignore 或 Fail。默认为 Fail。

    • webhooks.matchConditions ([]MatchCondition)

      补丁策略:根据 name 键执行合并操作

      映射:键 name 的唯一值将在合并过程中保留

      matchConditions 是将请求发送到此 webhook 之前必须满足的条件列表。 匹配条件过滤已经被 rules、namespaceSelector、objectSelector 匹配的请求。 matchConditions 取值为空列表时匹配所有请求。最多允许 64 个匹配条件。

      精确匹配逻辑是(按顺序):

      1. 如果任一 matchCondition 的计算结果为 FALSE,则跳过该 webhook。
      2. 如果所有 matchConditions 的计算结果为 TRUE,则调用该 webhook。
      3. 如果任一 matchCondition 的计算结果为错误(但都不是 FALSE):
        • 如果 failurePolicy=Fail,拒绝该请求;
        • 如果 failurePolicy=Ignore,忽略错误并跳过该 webhook。

      这是一个 Beta 功能特性,由 AdmissionWebhookMatchConditions 特性门控管理。

      MatchCondition 表示将请求发送到 Webhook 之前必须满足的条件。

      • webhooks.matchConditions.expression (string), 必需

        expression 表示将由 CEL 求值的表达式。求值结果必须是 bool 值。CEL 表达式可以访问 以 CEL 变量的形式给出的 AdmissionRequest 和 Authorizer 的内容:

        • 'object' - 来自传入请求的对象。对于 DELETE 请求,该值为 null。

        • 'oldObject' - 现有对象。对于 CREATE 请求,该值为 null。

        • 'request' - 准入请求的属性(/pkg/apis/admission/types.go#AdmissionRequest)。

        • 'authorizer' - CEL 授权者。可用于对请求的主体(用户或服务账号)执行授权检查。

          参阅: https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz

        • 'authorizer.requestResource' - CEL ResourceCheck 从"授权方"构建并配置请求资源。

        CEL 文档: https://kubernetes.io/zh-cn/docs/reference/using-api/cel/

        此字段为必需字段。

        • webhooks.matchConditions.name (string), 必需

          name 是此匹配条件的标识符,用于 MatchConditions 的策略性合并, 以及提供用于日志目的的标识符。一个好的 name 应该是对相关表达式的描述。 name 必须是由字母数字字符 -_. 组成的限定名称, 并且必须以字母、数字字符开头和结尾(例如 MyNamemy.name123-abc, 用于验证 name 的正则表达式是 ([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])。 带有可选的 DNS 子域前缀和 /(例如 example.com/MyName

          此字段为必需字段。

    • webhooks.matchPolicy (string)

      matchPolicy 定义了如何使用 “rules” 列表来匹配传入的请求。允许的值为 “Exact” 或 “Equivalent”。

      • Exact: 仅当请求与指定规则完全匹配时才匹配请求。 例如,如果可以通过 apps/v1、apps/v1beta1 和 extensions/v1beta1 修改 deployments 资源, 但 “rules” 仅包含 apiGroups:["apps"]、apiVersions:["v1"]、resources:["deployments"], 对 apps/v1beta1 或 extensions/v1beta1 的请求不会被发送到 Webhook。

      • Equivalent: 如果针对的资源包含在 “rules” 中,即使请求是通过另一个 API 组或版本提交,也会匹配。 例如,如果可以通过 apps/v1、apps/v1beta1 和 extensions/v1beta1 修改 deployments 资源, 并且 “rules” 仅包含 apiGroups:["apps"]、apiVersions:["v1"]、resources:["deployments "], 对 apps/v1beta1 或 extensions/v1beta1 的请求将被转换为 apps/v1 并发送到 Webhook。

      默认为 “Equivalent”。

    • webhooks.namespaceSelector (LabelSelector)

      namespaceSelector 根据对象的命名空间是否与 selector 匹配来决定是否在该对象上运行 Webhook。 如果对象本身是 Namespace,则针对 object.metadata.labels 执行匹配。 如果对象是其他集群作用域资源,则永远不会跳过 Webhook 的匹配动作。

      例如,为了针对 “runlevel” 不为 “0” 或 “1” 的名字空间中的所有对象运行 Webhook; 你可以按如下方式设置 selector :

      "namespaceSelector": {
        "matchExpressions": [
          {
            "key": "runlevel",
            "operator": "NotIn",
            "values": [
              "0",
              "1"
            ]
          }
        ]
      }
      

      相反,如果你只想针对 “environment” 为 “prod” 或 “staging” 的名字空间中的对象运行 Webhook; 你可以按如下方式设置 selector:

      "namespaceSelector": {
        "matchExpressions": [
          {
            "key": "environment",
            "operator": "In",
            "values": [
              "prod",
              "staging"
            ]
          }
        ]
      }
      

      有关标签选择算符的更多示例,请参阅 https://kubernetes.io/zh-cn/docs/concepts/overview/working-with-objects/labels

      默认为空的 LabelSelector,匹配所有对象。

    • webhooks.objectSelector (LabelSelector)

      objectSelector 根据对象是否具有匹配的标签来决定是否运行 Webhook。 objectSelector 针对将被发送到 Webhook 的 oldObject 和 newObject 进行评估,如果任一对象与选择器匹配,则视为匹配。 空对象(create 时为 oldObject,delete 时为 newObject)或不能有标签的对象(如 DeploymentRollback 或 PodProxyOptions 对象) 认为是不匹配的。 仅当 Webhook 支持时才能使用对象选择器,因为最终用户可以通过设置标签来跳过准入 Webhook。 默认为空的 LabelSelector,匹配所有内容。

    • webhooks.reinvocationPolicy (string)

      reinvocationPolicy 表示这个 Webhook 是否可以被多次调用,作为一次准入评估的一部分。可取值有 “Never” 和 “IfNeeded”。

      • Never: 在一次录取评估中,Webhook 被调用的次数不会超过一次。
      • IfNeeded:如果被录取的对象在被最初的 Webhook 调用后又被其他录取插件修改, 那么该 Webhook 将至少被额外调用一次作为录取评估的一部分。 指定此选项的 Webhook 必须是幂等的,能够处理它们之前承认的对象。 注意:不保证额外调用的次数正好为1。 如果额外的调用导致对对象的进一步修改,Webhook 不保证会再次被调用。 使用该选项的 Webhook 可能会被重新排序,以最小化额外调用的数量。 在保证所有的变更都完成后验证一个对象,使用验证性质的准入 Webhook 代替。

      默认值为 “Never” 。

    • webhooks.rules ([]RuleWithOperations)

      rules 描述了 Webhook 关心的资源/子资源上有哪些操作。Webhook 关心操作是否匹配任何rules。 但是,为了防止 ValidatingAdmissionWebhooks 和 MutatingAdmissionWebhooks 将集群置于只能完全禁用插件才能恢复的状态, ValidatingAdmissionWebhooks 和 MutatingAdmissionWebhooks 永远不会在处理 ValidatingWebhookConfiguration 和 MutatingWebhookConfiguration 对象的准入请求时被调用。

      RuleWithOperations 是操作和资源的元组。建议确保所有元组组合都是有效的。

      • webhooks.rules.apiGroups ([]string)

        Atomic: 将在合并期间被替换

        apiGroups 是资源所属的 API 组列表。* 是所有组。 如果存在 *,则列表的长度必须为 1。必需。

      • webhooks.rules.apiVersions ([]string)

        Atomic: 将在合并期间被替换

        apiVersions 是资源所属的 API 版本列表。* 是所有版本。 如果存在 *,则列表的长度必须为 1。必需。

      • webhooks.rules.operations ([]string)

        Atomic: 将在合并期间被替换

        operations 是准入 Webhook 所关心的操作 —— CREATE、UPDATE、DELETE、CONNECT 或用来指代所有已知操作以及将来可能添加的准入操作的 *。 如果存在 *,则列表的长度必须为 1。必需。

      • webhooks.rules.resources ([]string)

        Atomic: 将在合并期间被替换

        resources 是此规则适用的资源列表。

        • pods 表示 pods,'pods/log' 表示 pods 的日志子资源。* 表示所有资源,但不是子资源。
        • pods/* 表示 pods 的所有子资源,
        • */scale 表示所有 scale 子资源,
        • */* 表示所有资源及其子资源。

        如果存在通配符,则验证规则将确保资源不会相互重叠。

        根据所指定的对象,可能不允许使用子资源。必需。

      • webhooks.rules.scope (string)

        scope 指定此规则的范围。有效值为 “Cluster”, “Namespaced” 和 “”。 “Cluster” 表示只有集群范围的资源才会匹配此规则。 Namespace API 对象是集群范围的。 “Namespaced” 意味着只有命名空间作用域的资源会匹配此规则。 “” 表示没有范围限制。 子资源与其父资源的作用域相同。默认为 “*”。

    • webhooks.timeoutSeconds (int32)

      timeoutSeconds 指定此 Webhook 的超时时间。 超时后,Webhook 的调用将被忽略或 API 调用将根据失败策略失败。 超时值必须在 1 到 30 秒之间。默认为 10 秒。

MutatingWebhookConfigurationList

MutatingWebhookConfigurationList 是 MutatingWebhookConfiguration 的列表。


  • apiVersion: admissionregistration.k8s.io/v1

  • kind: MutatingWebhookConfigurationList

操作


get 读取指定的 MutatingWebhookConfiguration

HTTP 请求

GET /apis/admissionregistration.k8s.io/v1/mutatingwebhookconfigurations/{name}

参数

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

    MutatingWebhookConfiguration 的名称。

  • pretty查询参数):string

    pretty

响应

200 (MutatingWebhookConfiguration): OK

401: Unauthorized

list 列出或观察 MutatingWebhookConfiguration 类型的对象

HTTP 请求

GET /apis/admissionregistration.k8s.io/v1/mutatingwebhookconfigurations

参数

  • continue查询参数):string

    continue

  • limit查询参数):integer

    limit

  • pretty查询参数):string

    pretty

  • watch查询参数):boolean

    watch

响应

200 (MutatingWebhookConfigurationList): OK

401: Unauthorized

create 创建一个 MutatingWebhookConfiguration

HTTP 请求

POST /apis/admissionregistration.k8s.io/v1/mutatingwebhookconfigurations

参数

  • dryRun查询参数):string

    dryRun

  • pretty查询参数):string

    pretty

响应

200 (MutatingWebhookConfiguration): OK

201 (MutatingWebhookConfiguration): Created

202 (MutatingWebhookConfiguration): Accepted

401: Unauthorized

update 替换指定的 MutatingWebhookConfiguration

HTTP 请求

PUT /apis/admissionregistration.k8s.io/v1/mutatingwebhookconfigurations/{name}

参数

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

    MutatingWebhookConfiguration 的名称。

  • dryRun查询参数):string

    dryRun

  • pretty查询参数):string

    pretty

响应

200 (MutatingWebhookConfiguration): OK

201 (MutatingWebhookConfiguration): Created

401: Unauthorized

patch 部分更新指定的 MutatingWebhookConfiguration

HTTP 请求

PATCH /apis/admissionregistration.k8s.io/v1/mutatingwebhookconfigurations/{name}

参数

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

    MutatingWebhookConfiguration 的名称。

  • dryRun查询参数):string

    dryRun

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (MutatingWebhookConfiguration): OK

201 (MutatingWebhookConfiguration): Created

401: Unauthorized

delete 删除 MutatingWebhookConfiguration

HTTP 请求

DELETE /apis/admissionregistration.k8s.io/v1/mutatingwebhookconfigurations/{name}

参数

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

    MutatingWebhookConfiguration 的名称。

  • body: DeleteOptions

  • dryRun查询参数):string

    dryRun

  • pretty查询参数):string

    pretty

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 MutatingWebhookConfiguration 的集合

HTTP 请求

DELETE /apis/admissionregistration.k8s.io/v1/mutatingwebhookconfigurations

参数

  • continue查询参数):string

    continue

  • dryRun查询参数):string

    dryRun

  • limit查询参数):integer

    limit

  • pretty查询参数):string

    pretty

响应

200 (Status): OK

401: Unauthorized

7.3 - ValidatingWebhookConfiguration

ValidatingWebhookConfiguration 描述准入 Webhook 的配置,该 Webhook 可在不更改对象的情况下接受或拒绝对象请求

apiVersion: admissionregistration.k8s.io/v1

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

ValidatingWebhookConfiguration

ValidatingWebhookConfiguration 描述准入 Webhook 的配置,该 Webhook 可在不更改对象的情况下接受或拒绝对象请求。


  • apiVersion: admissionregistration.k8s.io/v1

  • kind: ValidatingWebhookConfiguration

  • webhooks ([]ValidatingWebhook)

    补丁策略:根据 name 键执行合并操作

    webhooks 是 Webhook 以及受影响的资源和操作的列表。

    ValidatingWebhook 描述了一个准入 Webhook 及其适用的资源和操作。

    • webhooks.admissionReviewVersions ([]string), 必需

      admissionReviewVersions 是 Webhook 期望的首选 AdmissionReview 版本的有序列表。 API 服务器将尝试使用它支持的列表中的第一个版本。如果 API 服务器不支持此列表中指定的版本,则此对象将验证失败。 如果持久化的 Webhook 配置指定了允许的版本,并且不包括 API 服务器已知的任何版本,则对 Webhook 的调用将失败并受失败策略的约束。

    • webhooks.clientConfig (WebhookClientConfig), 必需

      clientConfig 定义了如何与 Webhook 通信。必需。

      WebhookClientConfig 包含与 Webhook 建立 TLS 连接的信息

      • webhooks.clientConfig.caBundle ([]byte)

        caBundle 是一个 PEM 编码的 CA 包,将用于验证 Webhook 的服务证书。如果未指定,则使用 apiserver 上的系统信任根。

      • webhooks.clientConfig.service (ServiceReference)

        service 是对此 Webhook 服务的引用。必须指定 serviceurl

        如果 Webhook 在集群中运行,那么你应该使用 service

        ServiceReference 持有对 Service.legacy.k8s.io 的引用

        • webhooks.clientConfig.service.name (string), 必需

          name 是服务的名称。必需。

        • webhooks.clientConfig.service.namespace (string), 必需

          namespace 是服务的命名空间。必需。

        • webhooks.clientConfig.service.path (string)

          path 是一个可选的 URL 路径,它将发送任何请求到此服务。

        • webhooks.clientConfig.service.port (int32)

          如果指定,则为托管 Webhook 的服务上的端口。默认为 443 以实现向后兼容性。port 应该是一个有效的端口号(包括 1-65535)。

      • webhooks.clientConfig.url (string)

        url 以标准 URL 形式(scheme://host:port/path)给出了 Webhook 的位置。必须指定 urlservice 中的一个。

        host 不应指代在集群中运行的服务;请改用 service 字段。在某些 apiserver 中,可能会通过外部 DNS 解析 host。 (例如,kube-apiserver 无法解析集群内 DNS,因为这会违反分层原理)。host 也可以是 IP 地址。

        请注意,使用 localhost127.0.0.1 作为 host 是有风险的,除非你非常小心地在运行 apiserver 的所有主机上运行此 Webhook, 而这些 API 服务器可能需要调用此 Webhook。此类部署可能是不可移植的,即不容易在新集群中重复安装。

        该方案必须是 “https”;URL 必须以 “https://” 开头。

        路径是可选的,如果存在,可以是 URL 中允许的任何字符串。你可以使用路径将任意字符串传递给 Webhook,例如集群标识符。

        不允许使用用户或基本身份验证,例如不允许使用 “user:password@”。 不允许使用片段(“#...”)和查询参数(“?...”)。

    • webhooks.name (string), 必需

      准入 Webhook 的名称。应该是完全限定的名称,例如 imagepolicy.kubernetes.io,其中 “imagepolicy” 是 Webhook 的名称, kubernetes.io 是组织的名称。必需。

    • webhooks.sideEffects (string), 必需

    sideEffects 说明此 Webhook 是否有副作用。可接受的值为:None、NoneOnDryRun(通过 v1beta1 创建的 Webhook 也可以指定 Some 或 Unknown)。 具有副作用的 Webhook 必须实现协调系统,因为请求可能会被准入链中的未来步骤拒绝,因此需要能够撤消副作用。 如果请求与带有 sideEffects == Unknown 或 Some 的 Webhook 匹配,则带有 dryRun 属性的请求将被自动拒绝。

    • webhooks.failurePolicy (string)

    failurePolicy 定义了如何处理来自准入端点的无法识别的错误 - 允许的值是 Ignore 或 Fail。默认为 Fail。

    • webhooks.matchConditions ([]MatchCondition)

    补丁策略:根据 name 键的取值合并

    Map:name 键的唯一值将在合并期间保留

    matchConditions 是将请求发送到此 webhook 之前必须满足的条件列表。 匹配条件过滤已经被 rules、namespaceSelector、objectSelector 匹配的请求。 matchConditions 取值为空列表时匹配所有请求。最多允许 64 个匹配条件。

    精确匹配逻辑是(按顺序):

    1. 如果任一 matchCondition 的计算结果为 FALSE,则跳过该 webhook。
    2. 如果所有 matchConditions 的计算结果为 TRUE,则调用该 webhook。
    3. 如果任一 matchCondition 的计算结果为错误(但都不是 FALSE):
      • 如果 failurePolicy=Fail,拒绝该请求;
      • 如果 failurePolicy=Ignore,忽略错误并跳过该 webhook。

    这是一个 Beta 功能特性,由 AdmissionWebhookMatchConditions 特性门控管理。

    MatchCondition 表示将请求发送到 Webhook 之前必须满足的条件。

    • webhooks.matchConditions.expression (string), 必需

    expression 表示将由 CEL 求值的表达式。求值结果必须是 bool 值。CEL 表达式可以访问 以 CEL 变量的形式给出的 AdmissionRequest 和 Authorizer 的内容:

    • 'object' - 来自传入请求的对象。对于 DELETE 请求,该值为 null。

    • 'oldObject' - 现有对象。对于 CREATE 请求,该值为 null。

    • 'request' - 准入请求的属性(/pkg/apis/admission/types.go#AdmissionRequest)。

    • 'authorizer' - CEL 授权者。可用于对请求的主体(用户或服务帐户)执行授权检查。

      参阅:https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz

    • 'authorizer.requestResource' - CEL ResourceCheck 从"授权方"构建并配置请求资源。

    CEL 文档:https://kubernetes.io/zh-cn/docs/reference/using-api/cel/

    此字段为必需字段。

    • webhooks.matchConditions.name (string), 必需

    name 是此匹配条件的标识符,用于 MatchConditions 的策略性合并, 以及提供用于日志目的的标识符。一个好的 name 应该是对相关表达式的描述。 name 必须是由字母数字字符 -_. 组成的限定名称, 并且必须以字母、数字字符开头和结尾(例如 MyNamemy.name123-abc, 用于验证 name 的正则表达式是 ([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])。 带有可选的 DNS 子域前缀和 /(例如 example.com/MyName

    此字段为必需字段。

    • webhooks.matchPolicy (string)

      matchPolicy 定义了如何使用 "rules" 列表来匹配传入的请求。允许的值为 "Exact" 或 "Equivalent"。

      • Exact: 仅当请求与指定规则完全匹配时才匹配请求。 例如,如果可以通过 apps/v1、apps/v1beta1 和 extensions/v1beta1 修改 deployments 资源, 但 “rules” 仅包含 apiGroups:["apps"]、apiVersions:["v1"]、resources:["deployments "], 对 apps/v1beta1 或 extensions/v1beta1 的请求不会被发送到 Webhook。

      • Equivalent: 如果针对的资源包含在 “rules” 中,即使是通过另一个 API 组或版本,也视作匹配请求。 例如,如果可以通过 apps/v1、apps/v1beta1 和 extensions/v1beta1 修改 deployments 资源, 并且 “rules” 仅包含 apiGroups:["apps"]、apiVersions:["v1"]、resources:["deployments "], 对 apps/v1beta1 或 extensions/v1beta1 的请求将被转换为 apps/v1 并发送到 Webhook。

      默认为 “Equivalent”。

    • webhooks.namespaceSelector (LabelSelector)

      namespaceSelector 根据对象的命名空间是否与 selector 匹配来决定是否在该对象上运行 Webhook。 
      

      如果对象本身是命名空间,则在 object.metadata.labels 上执行匹配。 如果对象是另一个集群范围的资源,则永远不会跳过 Webhook 执行匹配。

      例如,在命名空间与 “0” 或 “1” 的 “runlevel” 不关联的任何对象上运行 Webhook; 你可以按如下方式设置 selector :

      "namespaceSelector": {
      "matchExpressions": [
        {
          "key": "runlevel",
          "operator": "NotIn",
          "values": [
            "0",
            "1"
          ]
        }
      ]
      }
      
      相反,如果你只想在命名空间与 “prod” 或 “staging” 的 “environment” 相关联的对象上运行 Webhook;
      

      你可以按如下方式设置 selector:

      "namespaceSelector": {
      "matchExpressions": [
        {
          "key": "environment",
          "operator": "In",
          "values": [
            "prod",
            "staging"
          ]
        }
      ]
      }
      
      有关标签选择算符的更多示例,请参阅 
      

      https://kubernetes.io/zh-cn/docs/concepts/overview/working-with-objects/labels

      默认为空的 LabelSelector,匹配所有对象。

    • webhooks.objectSelector (LabelSelector)

      objectSelector 根据对象是否具有匹配的标签来决定是否运行 Webhook。 objectSelector 针对将被发送到 Webhook 的 oldObject 和 newObject 进行评估,如果任一对象与选择器匹配,则视为匹配。 空对象(create 时为 oldObject,delete 时为 newObject)或不能有标签的对象(如 DeploymentRollback 或 PodProxyOptions 对象) 认为是不匹配的。 仅当 Webhook 支持时才能使用对象选择器,因为最终用户可以通过设置标签来跳过准入 webhook。 默认为空的 LabelSelector,匹配所有内容。

    • webhooks.rules ([]RuleWithOperations)

      rules 描述了 Webhook 关心的资源/子资源上有哪些操作。Webhook 关心操作是否匹配任何rules。 但是,为了防止 ValidatingAdmissionWebhooks 和 MutatingAdmissionWebhooks 将集群置于只能完全禁用插件才能恢复的状态, ValidatingAdmissionWebhooks 和 MutatingAdmissionWebhooks 永远不会在处理 ValidatingWebhookConfiguration 和 MutatingWebhookConfiguration 对象的准入请求被调用。

      RuleWithOperations 是操作和资源的元组。建议确保所有元组组合都是有效的。

      • webhooks.rules.apiGroups ([]string)

        原子性: 合并期间会被替换

        apiGroups 是资源所属的 API 组列表。'' 是所有组。 如果存在 '',则列表的长度必须为 1。必需。

      • webhooks.rules.apiVersions ([]string)

        原子性: 合并期间会被替换

        apiVersions 是资源所属的 API 版本列表。'' 是所有版本。 如果存在 '',则列表的长度必须为 1。必需。

      • webhooks.rules.operations ([]string)

        原子性: 合并期间会被替换

        operations 是准入 Webhook 所关心的操作 —— CREATE、UPDATE、DELETE、CONNECT 或用来指代所有已知操作以及将来可能添加的准入操作的 *。 如果存在 '*',则列表的长度必须为 1。必需。

      • webhooks.rules.resources ([]string)

        原子性: 合并期间会被替换

        resources 是此规则适用的资源列表。

        • 'pods' 表示 pods,'pods/log' 表示 pods 的日志子资源。'*' 表示所有资源,但不是子资源。
        • 'pods/*' 表示 pods 的所有子资源,
        • '*/scale' 表示所有 scale 子资源,
        • '/' 表示所有资源及其子资源。

        如果存在通配符,则验证规则将确保资源不会相互重叠。

        根据所指定的对象,可能不允许使用子资源。必需。

      • webhooks.rules.scope (string)

        scope 指定此规则的范围。有效值为 "Cluster", "Namespaced" 和 ""。 "Cluster" 表示只有集群范围的资源才会匹配此规则。 Namespace API 对象是集群范围的。 "Namespaced" 意味着只有命名空间作用域的资源会匹配此规则。 "" 表示没有范围限制。 子资源与其父资源的作用域相同。默认为 "*"。

    • webhooks.timeoutSeconds (int32)

      timeoutSeconds 指定此 Webhook 的超时时间。超时后,Webhook 的调用将被忽略或 API 调用将根据失败策略失败。 超时值必须在 1 到 30 秒之间。默认为 10 秒。

ValidatingWebhookConfigurationList

ValidatingWebhookConfigurationList 是 ValidatingWebhookConfiguration 的列表。


  • apiVersion: admissionregistration.k8s.io/v1

  • kind: ValidatingWebhookConfigurationList

操作


get 读取指定的 ValidatingWebhookConfiguration

HTTP 请求

GET /apis/admissionregistration.k8s.io/v1/validatingwebhookconfigurations/{name}

参数

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

    ValidatingWebhookConfiguration 的名称。

  • pretty (查询参数): string

    pretty

响应

200 (ValidatingWebhookConfiguration): OK

401: Unauthorized

list 列出或观察 ValidatingWebhookConfiguration 类型的对象

HTTP 请求

GET /apis/admissionregistration.k8s.io/v1/validatingwebhookconfigurations

参数

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

  • watch (查询参数): boolean

    watch

响应

200 (ValidatingWebhookConfigurationList): OK

401: Unauthorized

create 创建一个 ValidatingWebhookConfiguration

HTTP 请求

POST /apis/admissionregistration.k8s.io/v1/validatingwebhookconfigurations

参数

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (ValidatingWebhookConfiguration): OK

201 (ValidatingWebhookConfiguration): Created

202 (ValidatingWebhookConfiguration): Accepted

401: Unauthorized

update 替换指定的 ValidatingWebhookConfiguration

HTTP 请求

PUT /apis/admissionregistration.k8s.io/v1/validatingwebhookconfigurations/{name}

参数

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

    ValidatingWebhookConfiguration 的名称。

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (ValidatingWebhookConfiguration): OK

201 (ValidatingWebhookConfiguration): Created

401: Unauthorized

patch 部分更新指定的 ValidatingWebhookConfiguration

HTTP 请求

PATCH /apis/admissionregistration.k8s.io/v1/validatingwebhookconfigurations/{name}

参数

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

    ValidatingWebhookConfiguration 的名称。

  • dryRun (查询参数): string

    dryRun

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (ValidatingWebhookConfiguration): OK

201 (ValidatingWebhookConfiguration): Created

401: Unauthorized

delete 删除 ValidatingWebhookConfiguration

HTTP 请求

DELETE /apis/admissionregistration.k8s.io/v1/validatingwebhookconfigurations/{name}

参数

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

    ValidatingWebhookConfiguration 的名称。

  • body: DeleteOptions

  • dryRun (查询参数): string

    dryRun

  • pretty (查询参数): string

    pretty

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 ValidatingWebhookConfiguration 的集合

HTTP 请求

DELETE /apis/admissionregistration.k8s.io/v1/validatingwebhookconfigurations

参数

  • dryRun (查询参数): string

    dryRun

  • limit (查询参数): integer

    limit

  • pretty (查询参数): string

    pretty

响应

200 (Status): OK

401: Unauthorized

8 - 集群资源

8.1 - Node

Node 是 Kubernetes 中的工作节点。

apiVersion: v1

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

Node

Node 是 Kubernetes 中的工作节点。 每个节点在缓存中(即在 etcd 中)都有一个唯一的标识符。


  • apiVersion: v1

  • kind: Node

NodeSpec

NodeSpec 描述了创建节点时使用的属性。


  • configSource (NodeConfigSource)

    已弃用:以前用于为 DynamicKubeletConfig 功能指定节点配置的来源。此功能已删除。

    NodeConfigSource 指定节点配置的来源。指定一个子字段(不包括元数据)必须为非空。此 API 自 1.22的版本起已被弃用

    • configSource.configMap (ConfigMapNodeConfigSource)

      configMap 是对 Node 的 ConfigMap 的引用。

      ConfigMapNodeConfigSource 包含引用某 ConfigMap 作为节点配置源的信息。 此 API 自 1.22 版本起已被弃用: https://git.k8s.io/enhancements/keps/sig-node/281-dynamic-kubelet-configuration

      • configSource.configMap.kubeletConfigKey (string), 必需

        kubeletConfigKey 声明所引用的 ConfigMap 的哪个键对应于 KubeletConfiguration 结构体, 该字段在所有情况下都是必需的。

      • configSource.configMap.name (string), 必需

        name 是被引用的 ConfigMap 的 metadata.name。 此字段在所有情况下都是必需的。

      • configSource.configMap.namespace (string), 必需

        namespace 是所引用的 ConfigMap 的 metadata.namespace。 此字段在所有情况下都是必需的。

      • configSource.configMap.resourceVersion (string)

        resourceVersion 是所引用的 ConfigMap 的 metadata.resourceVersion。 该字段在 Node.spec 中是禁止的,在 Node.status 中是必需的。

      • configSource.configMap.uid (string)

        uid 是所引用的 ConfigMap 的 metadata.uid。 该字段在 Node.spec 中是禁止的,在 Node.status 中是必需的。

  • externalID (string)

    已弃用。并非所有 kubelet 都会设置此字段。 1.13 的版本之后会删除该字段。参见: https://issues.k8s.io/61966

  • podCIDR (string)

    podCIDR 表示分配给节点的 Pod IP 范围。

  • podCIDRs ([]string)

    podCIDRs 表示分配给节点以供该节点上的 Pod 使用的 IP 范围。 如果指定了该字段,则第 0 个条目必须与 podCIDR 字段匹配。 对于 IPv4 和 IPv6,它最多可以包含 1 个值。

  • providerID (string)

    云提供商分配的节点ID,格式为:<ProviderName>://<ProviderSpecificNodeID>

  • taints ([]Taint)

    如果设置了,则为节点的污点。

    此污点附加到的节点对任何不容忍污点的 Pod 都有 “影响”。

    • taints.effect (string), 必需

      必需的。污点对不容忍污点的 Pod 的影响。合法的 effect 值有 NoSchedule、PreferNoSchedule 和 NoExecute。

    • taints.key (string), 必需

      必需的。被应用到节点上的污点的键。

    • taints.timeAdded (Time)

      timeAdded 表示添加污点的时间。它仅适用于 NoExecute 的污点。

      Time 是 time.Time 的包装器,它支持对 YAML 和 JSON 的正确编组。 time 包的许多工厂方法提供了包装器。

    • taints.value (string)

      与污点键对应的污点值。

  • unschedulable (boolean)

    unschedulable 控制新 Pod 的节点可调度性。 默认情况下,节点是可调度的。 更多信息: https://kubernetes.io/zh-cn/docs/concepts/architecture/nodes/#manual-node-administration

NodeStatus

NodeStatus 是有关节点当前状态的信息。


  • addresses ([]NodeAddress)

    补丁策略:根据 type 键执行合并操作

    节点可到达的地址列表。从云提供商处查询(如果有)。 更多信息: https://kubernetes.io/zh-cn/docs/concepts/architecture/nodes/#addresses

    注意:该字段声明为可合并,但合并键不够唯一,合并时可能导致数据损坏。 调用者应改为使用完全替换性质的补丁操作。 有关示例,请参见 https://pr.k8s.io/79391

    消费者应假设地址可以在节点的生命期内发生变化。 然而在一些例外情况下这是不可能的,例如在自身状态中继承 Node 地址的 Pod 或 downward API (status.hostIP) 的消费者。

    NodeAddress 包含节点地址的信息。

    • addresses.address (string), 必需

      节点地址。

    • addresses.type (string), 必需

      节点地址类型,Hostname、ExternalIP 或 InternalIP 之一。

  • allocatable (map[string]Quantity)

    allocatable 表示节点的可用于调度的资源。默认为容量。

  • capacity (map[string]Quantity)

    capacity 代表一个节点的总资源。 更多信息: https://kubernetes.io/zh-cn/docs/concepts/storage/persistent-volumes/#capacity

  • conditions ([]NodeCondition)

    补丁策略:根据 type 键执行合并操作

    conditions 是当前观测到的节点状况的数组。 更多信息: https://kubernetes.io/zh-cn/docs/concepts/architecture/nodes/#condition

    NodeCondition 包含节点状况的信息。

    • conditions.status (string), 必需

      状况的状态为 True、False、Unknown 之一。

    • conditions.type (string), 必需

      节点状况的类型。

    • conditions.lastHeartbeatTime (Time)

      给定状况最近一次更新的时间。

      Time 是 time.Time 的包装器,它支持对 YAML 和 JSON 的正确编组。 time 包的许多工厂方法提供了包装器。

    • conditions.lastTransitionTime (Time)

      状况最近一次从一种状态转换到另一种状态的时间。

      Time 是 time.Time 的包装器,它支持对 YAML 和 JSON 的正确编组。 time 包的许多工厂方法提供了包装器。

    • conditions.message (string)

      指示有关上次转换详细信息的人类可读消息。

    • conditions.reason (string)

      (简要)状况最后一次转换的原因。

  • config (NodeConfigStatus)

    通过动态 Kubelet 配置功能分配给节点的配置状态。

    NodeConfigStatus 描述了由 Node.spec.configSource 分配的配置的状态。

    • config.active (NodeConfigSource)

      active 报告节点正在使用的检查点配置。 active 将代表已分配配置的当前版本或当前 LastKnownGood 配置,具体取决于尝试使用已分配配置是否会导致错误。

      NodeConfigSource 指定节点配置的来源。指定一个子字段(不包括元数据)必须为非空。此 API 自 1.22 版本起已弃用

      • config.active.configMap (ConfigMapNodeConfigSource)

        configMap 是对 Node 的 ConfigMap 的引用。

        ConfigMapNodeConfigSource 包含引用某 ConfigMap 作为节点配置源的信息。 此 API 自 1.22 版本起已被弃用: https://git.k8s.io/enhancements/keps/sig-node/281-dynamic-kubelet-configuration

        • config.active.configMap.kubeletConfigKey (string), 必需

          kubeletConfigKey 声明所引用的 ConfigMap 的哪个键对应于 KubeletConfiguration 结构体, 该字段在所有情况下都是必需的。

        • config.active.configMap.name (string), 必需

          name 是所引用的 ConfigMap 的 metadata.name。 此字段在所有情况下都是必需的。

        • config.active.configMap.namespace (string), 必需

          namespace 是所引用的 ConfigMap 的 metadata.namespace。 此字段在所有情况下都是必需的。

        • config.active.configMap.resourceVersion (string)

          resourceVersion 是所引用的 ConfigMap 的 metadata.resourceVersion。 该字段在 Node.spec 中是禁止的,在 Node.status 中是必需的。

        • config.active.configMap.uid (string)

          uid 是所引用的 ConfigMap 的 metadata.uid。 该字段在 Node.spec 中是禁止的,在 Node.status 中是必需的。

    • config.assigned (NodeConfigSource)

      assigned 字段报告节点将尝试使用的检查点配置。 当 Node.spec.configSource 被更新时,节点将所关联的配置负载及指示预期配置的记录通过检查点操作加载到本地磁盘。 节点参考这条记录来选择它的配置检查点,并在 assigned 中报告这条记录。 仅在记录被保存到磁盘后才会更新 status 中的 assigned。 当 kubelet 重新启动时,它会尝试通过加载和验证由 assigned 标识的检查点有效负载来使 assigned 配置成为 active 配置。

      NodeConfigSource 指定节点配置的来源。指定一个子字段(不包括元数据)必须为非空。此 API 自 1.22 版本起已弃用

      • config.assigned.configMap (ConfigMapNodeConfigSource)

        configMap 是对 Node 的 ConfigMap 的引用。

        ConfigMapNodeConfigSource 包含引用某 ConfigMap 为节点配置源的信息。 此 API 自 1.22 版本起已被弃用: https://git.k8s.io/enhancements/keps/sig-node/281-dynamic-kubelet-configuration

        • config.assigned.configMap.kubeletConfigKey (string), 必需

          kubeletConfigKey 声明所引用的 ConfigMap 的哪个键对应于 KubeletConfiguration 结构体, 该字段在所有情况下都是必需的。

        • config.assigned.configMap.name (string), 必需

          name 是所引用的 ConfigMap 的 metadata.name。 此字段在所有情况下都是必需的。

        • config.assigned.configMap.namespace (string), 必需

          namespace 是所引用的 ConfigMap 的 metadata.namespace。 此字段在所有情况下都是必需的。

        • config.assigned.configMap.resourceVersion (string)

          resourceVersion 是所引用的 ConfigMap 的 metadata.resourceVersion。 该字段在 Node.spec 中是禁止的,在 Node.status 中是必需的。

        • config.assigned.configMap.uid (string)

          uid 是所引用的 ConfigMap 的 metadata.uid。 该字段在 Node.spec 中是禁止的,在 Node.status 中是必需的。

    • config.error (string)

      error 描述了在 spec.configSource 与活动配置间协调时发生的所有问题。 可能会发生的情况,例如,尝试将 spec.configSource 通过检查点操作复制到到本地 assigned 记录时, 尝试对与 spec.configSource 关联的有效负载执行检查点操作,尝试加​​载或验证 assigned 的配置时。 同步配置时可能会在不同位置发生错误,较早的错误(例如下载或检查点错误)不会导致回滚到 LastKnownGood, 并且可能会在 Kubelet 重试后解决。 后期发生的错误(例如加载或验证检查点配置)将导致回滚到 LastKnownGood。 在后一种情况下,通常可以通过修复 spec.sonfigSource 中 assigned 配置来解决错误。 你可以通过在 Kubelet 日志中搜索错误消息来找到更多的调试信息。 error 是错误状态的人类可读描述;机器可以检查 error 是否为空,但不应依赖跨 Kubelet 版本的 error 文本的稳定性。

    • config.lastKnownGood (NodeConfigSource)

      lastKnownGood 报告节点在尝试使用 assigned 配置时遇到错误时将回退到的检查点配置。 当节点确定 assigned 配置稳定且正确时,assigned 配置会成为 lastKnownGood 配置。 这当前实施为从更新分配配置的本地记录开始的 10 分钟浸泡期。 如果在此期间结束时分配的配置依旧处于活动状态,则它将成为 lastKnownGood。 请注意,如果 spec.configSource 重置为 nil(使用本地默认值), LastKnownGood 也会立即重置为 nil,因为始终假定本地默认配置是好的。 你不应该对节点确定配置稳定性和正确性的方法做出假设,因为这可能会在将来发生变化或变得可配置。

      NodeConfigSource 指定节点配置的来源。指定一个子字段(不包括元数据)必须为非空。此 API 自 1.22 版本起已弃用

      • config.lastKnownGood.configMap (ConfigMapNodeConfigSource)

        configMap 是对 Node 的 ConfigMap 的引用。

        ConfigMapNodeConfigSource 包含引用某 ConfigMap 作为节点配置源的信息。 此 API 自 1.22 版本起已被弃用: https://git.k8s.io/enhancements/keps/sig-node/281-dynamic-kubelet-configuration

        • config.lastKnownGood.configMap.kubeletConfigKey (string), 必需

          kubeletConfigKey 声明所引用的 ConfigMap 的哪个键对应于 KubeletConfiguration 结构体, 该字段在所有情况下都是必需的。

        • config.lastKnownGood.configMap.name (string), 必需

          name 是所引用的 ConfigMap 的 metadata.name。 此字段在所有情况下都是必需的。

        • config.lastKnownGood.configMap.namespace (string), 必需

          namespace 是所引用的 ConfigMap 的 metadata.namespace。 此字段在所有情况下都是必需的。

        • config.lastKnownGood.configMap.resourceVersion (string)

          resourceVersion 是所引用的 ConfigMap 的 metadata.resourceVersion。 该字段在 Node.spec 中是禁止的,在 Node.status 中是必需的。

        • config.lastKnownGood.configMap.uid (string)

          uid 是所引用的 ConfigMap 的 metadata.uid。 该字段在 Node.spec 中是禁止的,在 Node.status 中是必需的。

  • daemonEndpoints (NodeDaemonEndpoints)

    在节点上运行的守护进程的端点。

    NodeDaemonEndpoints 列出了节点上运行的守护进程打开的端口。

    • daemonEndpoints.kubeletEndpoint (DaemonEndpoint)

      Kubelet 正在侦听的端点。

      DaemonEndpoint 包含有关单个 Daemon 端点的信息。

      • daemonEndpoints.kubeletEndpoint.Port (int32), 必需

        给定端点的端口号。

  • images ([]ContainerImage)

    该节点上的容器镜像列表。

    描述一个容器镜像

    • images.names ([]string)

      已知此镜像的名称。 例如 ["kubernetes.example/hyperkube:v1.0.7", "cloud-vendor.registry.example/cloud-vendor/hyperkube:v1.0.7"]

    • images.sizeBytes (int64)

      镜像的大小(以字节为单位)。

  • nodeInfo (NodeSystemInfo)

    用于唯一标识节点的 ids/uuids 集。 更多信息: https://kubernetes.io/zh-cn/docs/concepts/architecture/nodes/#info

    NodeSystemInfo 是一组用于唯一标识节点的 ids/uuids。

    • nodeInfo.architecture (string), 必需

      节点报告的 architecture。

    • nodeInfo.bootID (string), 必需

      节点报告的 bootID。

    • nodeInfo.containerRuntimeVersion (string), 必需

      节点通过运行时远程 API 报告的 ContainerRuntime 版本(例如 containerd://1.4.2)。

    • nodeInfo.kernelVersion (string), 必需

      节点来自 “uname -r” 报告的内核版本(例如 3.16.0-0.bpo.4-amd64)。

    • nodeInfo.kubeProxyVersion (string), 必需

      节点报告的 KubeProxy 版本。

    • nodeInfo.kubeletVersion (string), 必需

      节点报告的 Kubelet 版本。

    • nodeInfo.operatingSystem (string), 必需

      节点上报的操作系统。

    • nodeInfo.osImage (string), 必需

      节点从 /etc/os-release 报告的操作系统映像(例如 Debian GNU/Linux 7 (wheezy))。

  • phase (string)

    NodePhase 是最近观测到的节点的生命周期阶段。 更多信息: https://kubernetes.io/zh-cn/docs/concepts/architecture/nodes/#phase

    该字段从未填充,现在已被弃用。

  • volumesAttached ([]AttachedVolume)

    附加到节点的卷的列表。

    AttachedVolume 描述附加到节点的卷

    • volumesAttached.devicePath (string), 必需

      devicePath 表示卷应该可用的设备路径。

    • volumesAttached.name (string), 必需

      附加卷的名称。

  • volumesInUse ([]string)

    节点正在使用(安装)的可附加卷的列表。

NodeList

NodeList 是已注册到 master 的所有节点的完整列表。


  • items ([]Node), 必需

    节点的列表。

操作


get 读取指定节点

HTTP 请求

GET /api/v1/nodes/{name}

参数

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

    节点的名称。

  • pretty (路径参数): string

    pretty

响应

200 (Node): OK

401: Unauthorized

get 读取指定节点的状态

HTTP 请求

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

参数

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

    节点的名称。

  • pretty (查询参数): string

    pretty

响应

200 (Node): OK

401: Unauthorized

list 列出或监视节点类型的对象

HTTP 请求

GET /api/v1/nodes

参数

响应

200 (NodeList): OK

401: Unauthorized

create 创建一个节点

HTTP 请求

POST /api/v1/nodes

参数

响应

200 (Node): OK

201 (Node): Created

202 (Node): Accepted

401: Unauthorized

update 替换指定节点

HTTP 请求

PUT /api/v1/nodes/{name}

参数

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

    节点的名称。

  • body: Node, 必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (Node): OK

201 (Node): Created

401: Unauthorized

update 替换指定节点的状态

HTTP 请求

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

参数

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

    节点的名称。

  • body: Node, 必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (Node): OK

201 (Node): Created

401: Unauthorized

patch 部分更新指定节点

HTTP 请求

PATCH /api/v1/nodes/{name}

参数

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

    节点的名称。

  • body: Patch, 必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (Node): OK

201 (Node): Created

401: Unauthorized

patch 部分更新指定节点的状态

HTTP 请求

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

参数

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

    节点的名称。

  • body: Patch, 必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (Node): OK

201 (Node): Created

401: Unauthorized

delete 删除一个节点

HTTP 请求

DELETE /api/v1/nodes/{name}

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除节点的集合

HTTP 请求

DELETE /api/v1/nodes

响应

200 (Status): OK

401: Unauthorized

8.2 - 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/zh-cn/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.3 - Event

Event 是集群中某个事件的报告。

apiVersion: events.k8s.io/v1

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

Event

Event 是集群中某个事件的报告。它一般表示系统的某些状态变化。 Event 的保留时间有限,触发器和消息可能会随着时间的推移而演变。 事件消费者不应假定给定原因的事件的时间所反映的是一致的下层触发因素,或具有该原因的事件的持续存在。 Events 应被视为通知性质的、尽最大努力而提供的补充数据。


  • eventTime (MicroTime),必需

    evenTime 是该事件首次被观察到的时间。它是必需的。

    MicroTime 是微秒级精度的 Time 版本

  • action (string)

    action 是针对相关对象所采取的或已失败的动作。字段值是机器可读的。对于新的 Event,此字段不能为空, 且最多为 128 个字符。

  • deprecatedCount (int32)

    deprecatedCount 是确保与 core.v1 Event 类型向后兼容的已弃用字段。

  • deprecatedFirstTimestamp (Time)

    deprecatedFirstTimestamp 是确保与 core.v1 Event 类型向后兼容的已弃用字段。

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

  • deprecatedLastTimestamp (Time)

    deprecatedLastTimestamp 是确保与 core.v1 Event 类型向后兼容的已弃用字段。

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

  • deprecatedSource (EventSource)

    deprecatedSource 是确保与 core.v1 Event 类型向后兼容的已弃用字段。

    EventSource 包含事件信息。

    • deprecatedSource.component (string)

      生成事件的组件。

    • deprecatedSource.host (string)

      产生事件的节点名称。

  • note (string)

    node 是对该操作状态的可读描述。注释的最大长度是 1kB,但是库应该准备好处理最多 64kB 的值。

  • reason (string)

    reason 是采取行动的原因。它是人类可读的。对于新的 Event,此字段不能为空,且最多为128个字符。

  • regarding (ObjectReference)

    关于包含此 Event 所涉及的对象。在大多数情况下,所指的是报告事件的控制器所实现的一个 Object。 例如 ReplicaSetController 实现了 ReplicaSet,这个事件被触发是因为控制器对 ReplicaSet 对象做了一些变化。

  • related (ObjectReference)

    related 是用于更复杂操作的、可选的、从属性的对象。例如,当 regarding 对象触发 related 对象的创建或删除时。

  • reportingController (string)

    reportingController 是触发该事件的控制器的名称,例如 kubernetes.io/kubelet。对于新的 Event,此字段不能为空。

  • reportingInstance (string)

    reportingInstance 为控制器实例的 ID,例如 kubelet-xyzf。对于新的 Event,此字段不能为空,且最多为 128 个字符。

  • series (EventSeries)

    series 是该事件代表的事件系列的数据,如果是单事件,则为 nil。

    EventSeries 包含一系列事件的信息,即一段时间内持续发生的事情。 EventSeries 的更新频率由事件报告者决定。 默认事件报告程序在 "k8s.io/client-go/tools/events/event_broadcaster.go" 展示在发生心跳时该结构如何被更新,可以指导定制的报告者实现。

    • series.count (int32),必需

      count 是到最后一次心跳时间为止在该系列中出现的次数。

    • series.lastObservedTime (MicroTime),必需

      lastObservedTime 是在最后一次心跳时间之前看到最后一个 Event 的时间。

      MicroTime 是微秒级精度的 Time 版本。

  • type (string)

    type 是该事件的类型(Normal、Warning),未来可能会添加新的类型。字段值是机器可读的。 对于新的 Event,此字段不能为空。

EventList

EventList 是一个 Event 对象列表。


  • items ([]Event),必需

    items 是模式(Schema)对象的列表。

操作


get 读取特定 Event

HTTP 请求

GET /apis/events.k8s.io/v1/namespaces/{namespace}/events/{name}

参数

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

    Event 名称

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

    namespace

  • pretty (路径参数):string

    pretty

响应

200 (Event): OK

401: Unauthorized

list 列出或观察事件类型对象

HTTP 请求

GET /apis/events.k8s.io/v1/namespaces/{namespace}/events

参数

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

    namespace

  • continue (查询参数):string

    continue

  • limit (查询参数):integer

    limit

  • pretty (查询参数):string

    pretty

  • watch (查询参数):boolean

    watch

响应

200 (EventList): OK

401: Unauthorized

list 列出或观察事件类型对象

HTTP 请求

GET /apis/events.k8s.io/v1/events

参数

  • continue (查询参数):string

    continue

  • limit (查询参数):integer

    limit

  • pretty (查询参数):string

    pretty

  • watch (查询参数):boolean

    watch

响应

200 (EventList): OK

401: Unauthorized

create 创建一个 Event

HTTP 请求

POST /apis/events.k8s.io/v1/namespaces/{namespace}/events

参数

  • namespace (查询参数):string,必需

    namespace

  • dryRun (查询参数):string

    dryRun

  • pretty (查询参数):string

    pretty

响应

200 (Event): OK

201 (Event): Created

202 (Event): Accepted

401: Unauthorized

update 替换指定 Event

HTTP 请求

PUT /apis/events.k8s.io/v1/namespaces/{namespace}/events/{name}

参数

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

    Event 名称

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

    namespace

  • dryRun (查询参数):必需

    dryRun

  • pretty (查询参数):string

    pretty

响应

200 (Event): OK

201 (Event): Created

401: Unauthorized

patch 部分更新指定的 Event

HTTP 请求

PATCH /apis/events.k8s.io/v1/namespaces/{namespace}/events/{name}

参数

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

    Event 名称

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

    namespace

  • dryRun (查询参数):string

    dryRun

  • force (查询参数):boolean

    force

  • pretty (查询参数):string

    pretty

响应

200 (Event): OK

201 (Event): Created

401: Unauthorized

delete 删除 Event

HTTP 请求

DELETE /apis/events.k8s.io/v1/namespaces/{namespace}/events/{name}

参数

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

    Event 名称

  • dryRun (查询参数):string

    dryRun

  • pretty (查询参数):string

    pretty

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 Event 集合

HTTP 请求

DELETE /apis/events.k8s.io/v1/namespaces/{namespace}/events

参数

  • continue (查询参数):string

    continue

  • dryRun (查询参数):string

    dryRun

  • limit (查询参数):integer

    limit

  • pretty (查询参数):string

    pretty

响应

200 (Status): OK

401: Unauthorized

8.4 - APIService

APIService 是用来表示一个特定的 GroupVersion 的服务器

apiVersion: apiregistration.k8s.io/v1

import "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"

APIService

APIService 是用来表示一个特定的 GroupVersion 的服务器。名称必须为 "version.group"。


APIServiceSpec

APIServiceSpec 包含用于定位和与服务器通信的信息。仅支持 HTTPS 协议,但是你可以禁用证书验证。


  • groupPriorityMinimum (int32), 必需

    groupPriorityMininum 是这个组至少应该具有的优先级。优先级高表示客户端优先选择该组。 请注意,该组的其他版本可能会指定更高的 groupPriorityMininum 值,使得整个组获得更高的优先级。 主排序基于 groupPriorityMinimum 值,从高到低排序(20 在 10 之前)。 次要排序基于对象名称的字母顺序(v1.bar 在 v1.foo 之前)。 我们建议这样配置:*.k8s.io(扩展除外)值设置为 18000,PaaS(OpenShift、Deis)建议值为 2000 左右。

  • versionPriority (int32), 必需

    versionPriority 控制该 API 版本在其组中的排序,必须大于零。主排序基于 versionPriority, 从高到低排序(20 在 10 之前)。因为在同一个组里,这个数字可以很小,可能是几十。 在版本优先级相等的情况下,版本字符串将被用来计算组内的顺序。如果版本字符串是与 Kubernetes 的版本号形式类似, 则它将排序在 Kubernetes 形式版本字符串之前。Kubernetes 的版本号字符串按字典顺序排列。 Kubernetes 版本号以 “v” 字符开头,后面是一个数字(主版本),然后是可选字符串 “alpha” 或 “beta” 和另一个数字(次要版本)。 它们首先按 GA > beta > alpha 排序(其中 GA 是没有 beta 或 alpha 等后缀的版本),然后比较主要版本, 最后是比较次要版本。版本排序列表示例:v10、v2、v1、v11beta2、v10beta3、v3beta1、v12alpha1、v11alpha2、foo1、foo10。

  • caBundle ([]byte)

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

    caBundle 是一个 PEM 编码的 CA 包,用于验证 API 服务器的服务证书。如果未指定, 则使用 API 服务器上的系统根证书。

  • group (string)

    group 是此服务器主机的 API 组名称。

  • insecureSkipTLSVerify (boolean)

    insecureSkipTLSVerify 代表在与此服务器通信时禁用 TLS 证书验证。强烈建议不要这样做。你应该使用 caBundle。

  • service (ServiceReference)

    service 是对该 API 服务器的服务的引用。它只能在端口 443 上通信。如果 service 是 nil, 则意味着 API groupversion 的处理是在当前服务器上本地处理的。服务调用被直接委托给正常的处理程序链来完成。

    ServiceReference 保存对 Service.legacy.k8s.io 的一个引用。

    • service.name (string)

      name 是服务的名称
      
    • service.namespace (string)

      namespace 是服务的命名空间
      
    • service.port (int32)

      如果指定,则为托管 Webhook 的服务上的端口。为实现向后兼容,默认端口号为 443。
      

      port 应该是一个有效的端口号(1-65535,包含)。

  • version (string)

    version 是此服务器的 API 版本。例如:“v1”。

APIServiceStatus

APIServiceStatus 包含有关 API 服务器的派生信息


  • conditions ([]APIServiceCondition)

    补丁策略:基于键 type 合并

    Map:合并时将保留 type 键的唯一值

    APIService 的当前服务状态。

    APIServiceCondition 描述 APIService 在特定点的状态

    • conditions.status (string), 必需

      status 表示状况(Condition)的状态,取值为 True、False 或 Unknown 之一。
      
    • conditions.type (string), 必需

      type 是状况的类型。
      
    • conditions.lastTransitionTime (Time)

      上一次发生状况状态转换的时间。
      

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

      指示上次转换的详细可读信息。  
      
    • conditions.reason (string)

      表述状况上次转换原因的、驼峰格式命名的、唯一的一个词。
      

APIServiceList

APIServiceList 是 APIService 对象的列表。


Operations


get 读取指定的 APIService

HTTP 请求

GET /apis/apiregistration.k8s.io/v1/apiservices/{name}

参数

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

    APIService 名称

  • pretty查询参数):string

    pretty

响应

200 (APIService): OK

401: Unauthorized

get 读取指定 APIService 的状态

HTTP 请求

GET /apis/apiregistration.k8s.io/v1/apiservices/{name}/status

参数

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

    APIService 名称

  • pretty查询参数):string

    pretty

响应

200 (APIService): OK

401: Unauthorized

list 列出或观察 APIService 类的对象

HTTP 请求

GET /apis/apiregistration.k8s.io/v1/apiservices

参数

响应

200 (APIServiceList): OK

401: Unauthorized

create 创建一个 APIService

HTTP 请求

POST /apis/apiregistration.k8s.io/v1/apiservices

参数

响应

200 (APIService): OK

201 (APIService): Created

202 (APIService): Accepted

401: Unauthorized

update 替换指定的 APIService

HTTP 请求

PUT /apis/apiregistration.k8s.io/v1/apiservices/{name}

参数

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

    APIService 名称

  • bodyAPIService, 必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • pretty查询参数):string

    pretty

响应

200 (APIService): OK

201 (APIService): Created

401: Unauthorized

update 替换指定 APIService 的 status

HTTP 请求

PUT /apis/apiregistration.k8s.io/v1/apiservices/{name}/status

参数

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

    APIService 名称

  • bodyAPIService, 必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • pretty查询参数):string

    pretty

响应

200 (APIService): OK

201 (APIService): Created

401: Unauthorized

patch 部分更新指定的 APIService

HTTP 请求

PATCH /apis/apiregistration.k8s.io/v1/apiservices/{name}

参数

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

    APIService 名称

  • bodyPatch, 必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (APIService): OK

201 (APIService): Created

401: Unauthorized

patch 部分更新指定 APIService 的 status

HTTP 请求

PATCH /apis/apiregistration.k8s.io/v1/apiservices/{name}/status

参数

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

    APIService 名称

  • bodyPatch, 必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (APIService): OK

201 (APIService): Created

401: Unauthorized

delete 删除一个 APIService

HTTP 请求

DELETE /apis/apiregistration.k8s.io/v1/apiservices/{name}

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 APIService 集合

HTTP 请求

DELETE /apis/apiregistration.k8s.io/v1/apiservices

参数

响应

200 (Status): OK

401: Unauthorized

8.5 - Lease

Lease 定义了租约的概念。

apiVersion: coordination.k8s.io/v1

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

Lease

Lease 定义了租约的概念。


LeaseSpec

LeaseSpec 是一个 Lease 的规约。


  • acquireTime (MicroTime)

    acquireTime 是当前租约被获取的时间。

    MicroTime 是微秒级精确时间的版本。

  • holderIdentity (string)

    holderIdentity 包含当前租约持有人的身份。

  • leaseDurationSeconds (int32)

    leaseDurationSeconds 是租约候选人需要等待强制获取租约的持续时间。这是相对于上次观察到的 renewTime 的度量。

  • leaseTransitions (int32)

    leaseTransitions 是租约持有人之间的转换次数。

  • renewTime (MicroTime)

    renewTime 是当前租约持有人上次更新租约的时间。

    MicroTime 是具有微秒级精度的时间版本。

LeaseList

LeaseList 是 Lease 对象的列表。


操作


get 读取指定的 Lease

HTTP 请求

GET /apis/coordination.k8s.io/v1/namespaces/{namespace}/leases/{name}

参数

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

    Lease 名称。

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

    namespace

  • pretty (查询参数): string

    pretty

响应

200 (Lease): OK

401: Unauthorized

list 列出或监视 Lease 类对象

HTTP 请求

GET /apis/coordination.k8s.io/v1/namespaces/{namespace}/leases

参数

响应

200 (LeaseList): OK

401: Unauthorized

list 列出或监视 Lease 类对象

HTTP 请求

GET /apis/coordination.k8s.io/v1/leases

参数

响应

200 (LeaseList): OK

401: Unauthorized

create 创建 Lease

HTTP 请求

POST /apis/coordination.k8s.io/v1/namespaces/{namespace}/leases

参数

响应

200 (Lease): OK

201 (Lease): Created

202 (Lease): Accepted

401: Unauthorized

update 替换指定的 Lease

HTTP 请求

PUT /apis/coordination.k8s.io/v1/namespaces/{namespace}/leases/{name}

参数

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

    Lease 的名称。

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

    namespace

  • body: Lease, 必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (Lease): OK

201 (Lease): Created

401: Unauthorized

patch 部分更新指定的 Lease

HTTP 请求

PATCH /apis/coordination.k8s.io/v1/namespaces/{namespace}/leases/{name}

参数

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

    Lease 的名称。

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

    namespace

  • body: Patch, 必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (Lease): OK

201 (Lease): Created

401: Unauthorized

delete 删除一个 Lease

HTTP 请求

DELETE /apis/coordination.k8s.io/v1/namespaces/{namespace}/leases/{name}

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 Lease 收款

HTTP 请求

DELETE /apis/coordination.k8s.io/v1/namespaces/{namespace}/leases

参数

响应

200 (Status): OK

401: Unauthorized

8.6 - RuntimeClass

RuntimeClass 定义集群中支持的容器运行时类。

apiVersion: node.k8s.io/v1

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

RuntimeClass

RuntimeClass 定义集群中支持的容器运行时类。 RuntimeClass 用于确定哪个容器运行时用于运行某 Pod 中的所有容器。 RuntimeClass 由用户或集群制备程序手动定义,并在 PodSpec 中引用。 Kubelet 负责在运行 Pod 之前解析 RuntimeClassName 引用。 有关更多详细信息,请参阅 https://kubernetes.io/zh-cn/docs/concepts/containers/runtime-class/


  • apiVersion: node.k8s.io/v1

  • kind: RuntimeClass

  • metadata (ObjectMeta)

    更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

  • handler (string),必需

    handler 指定底层运行时和配置,在 CRI 实现过程中将使用这些运行时和配置来处理这个类的 Pod。 可能的值特定于节点和 CRI 配置。 假定所有 handler 可用于每个节点上,且同一名称的 handler 在所有节点上是等效的。 例如,一个名为 “runc” 的 handler 可能指定 runc OCI 运行时将(使用原生 Linux 容器) 用于运行 Pod 中的容器。该 handler 必须采用小写,遵从 DNS Label (RFC 1123) 要求,且是不可变更的。

  • scheduling (Scheduling)

    scheduling 包含调度约束,这些约束用来确保以这个 RuntimeClass 运行的 Pod 被调度到支持此运行时类的节点。 如果 scheduling 设为空,则假定所有节点支持此 RuntimeClass。

    Scheduling 指定支持 RuntimeClass 的节点的调度约束。

    • scheduling.nodeSelector (map[string]string)

      nodeSelector 列出支持此 RuntimeClass 的节点上必须存在的标签。 使用此 RuntimeClass 的 Pod 只能调度到与这个选择算符匹配的节点上。 RuntimeClass nodeSelector 与 Pod 现有的 nodeSelector 合并。 任何冲突均会使得该 Pod 在准入时被拒绝。

    • scheduling.tolerations ([]Toleration)

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

      tolerations 在准入期间追加到以此 RuntimeClass 运行的 Pod(不包括重复项)上, 本质上是求取 Pod 和 RuntimeClass 所容忍的节点并集。

      附加此容忍度的 Pod 将容忍用匹配运算符 operator 运算后与三元组 <key,value,effect> 匹配的任何污点。

      • scheduling.tolerations.key (string)

        key 是容忍度所应用到的污点键。空意味着匹配所有污点键。 如果键为空,则运算符必须为 Exists;这个组合意味着匹配所有值和所有键。

      • scheduling.tolerations.operator (string)

        operator 表示一个键与值的关系。有效的运算符为 Exists 和 Equal。默认为 Equal。 Exists 等价于将值设置为通配符的情况,因此一个 Pod 可以容忍特定类别的所有污点。

      • scheduling.tolerations.value (string)

        value 是容忍度匹配到的污点值。如果运算符为 Exists,则值应为空,否则就是一个普通字符串。

      • scheduling.tolerations.effect (string)

        effect 表示匹配度污点效果。空意味着匹配所有污点效果。 当指定值时,允许的值为 NoSchedule、PreferNoSchedule 或 NoExecute。

      • scheduling.tolerations.tolerationSeconds (int64)

        tolerationSeconds 表示容忍度容忍污点的时间段(必须是 NoExecute 的效果,否则忽略此字段)。 默认情况下,不设置此字段,这意味着永远容忍污点(不驱逐)。零和负值将被系统视为 0(立即驱逐)。

RuntimeClassList

RuntimeClassList 是 RuntimeClass 对象的列表。


  • apiVersion: node.k8s.io/v1

  • kind: RuntimeClassList

操作


get 读取指定的 RuntimeClass

HTTP 请求

GET /apis/node.k8s.io/v1/runtimeclasses/{name}

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

    RuntimeClass 的名称

  • pretty (查询参数): string

    pretty

响应

200 (RuntimeClass): OK

401: Unauthorized

list 列出或监视 RuntimeClass 类别的对象

HTTP 请求

GET /apis/node.k8s.io/v1/runtimeclasses

参数

响应

200 (RuntimeClassList): OK

401: Unauthorized

create 创建 RuntimeClass

HTTP 请求

POST /apis/node.k8s.io/v1/runtimeclasses

参数

响应

200 (RuntimeClass): OK

201 (RuntimeClass): Created

202 (RuntimeClass): Accepted

401: Unauthorized

update 替换指定的 RuntimeClass

HTTP 请求

PUT /apis/node.k8s.io/v1/runtimeclasses/{name}

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

    RuntimeClass 的名称

  • body: RuntimeClass,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (RuntimeClass): OK

201 (RuntimeClass): Created

401: Unauthorized

patch 部分更新指定的 RuntimeClass

HTTP 请求

PATCH /apis/node.k8s.io/v1/runtimeclasses/{name}

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

    RuntimeClass 的名称

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (RuntimeClass): OK

201 (RuntimeClass): Created

401: Unauthorized

delete 删除 RuntimeClass

HTTP 请求

DELETE /apis/node.k8s.io/v1/runtimeclasses/{name}

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 RuntimeClass 的集合

HTTP 请求

DELETE /apis/node.k8s.io/v1/runtimeclasses

参数

响应

200 (Status): OK

401: Unauthorized

8.7 - FlowSchema v1beta3

FlowSchema 定义一组流的模式。

apiVersion: flowcontrol.apiserver.k8s.io/v1beta3

import "k8s.io/api/flowcontrol/v1beta3"

FlowSchema

FlowSchema 定义一组流的模式。请注意,一个流由属性类似的一组入站 API 请求组成, 用一对字符串进行标识:FlowSchema 的名称和一个 “流区分项”。


  • apiVersion: flowcontrol.apiserver.k8s.io/v1beta3

  • kind: FlowSchema

FlowSchemaSpec

FlowSchemaSpec 描述 FlowSchema 的规约看起来是怎样的。


  • priorityLevelConfiguration (PriorityLevelConfigurationReference),必需

    priorityLevelConfiguration 应引用集群中的 PriorityLevelConfiguration。 如果此应用无法被解析,则忽略此 FlowSchema,并在其状态中将其标记为无效。必需。

    PriorityLevelConfigurationReference 包含指向正被使用的 “request-priority” 的信息。

    • priorityLevelConfiguration.name (string),必需

      name 是正被引用的优先级配置的名称。必需。

  • distinguisherMethod (FlowDistinguisherMethod)

    distinguisherMethod 定义如何为匹配此模式的请求来计算流区分项。 nil 表示该区分项被禁用,且因此将始终为空字符串。

    FlowDistinguisherMethod 指定流区分项的方法。

    • distinguisherMethod.type (string),必需

      type 是流区分项的类型。支持的类型为 “ByUser” 和 “ByNamespace”。必需。

  • matchingPrecedence (int32)

    matchingPrecedence 用于选择与给定请求匹配的一个 FlowSchema。 选中的 FlowSchema 是某个 MatchingPrecedence 数值最小(我们视其为逻辑上最大)的 FlowSchema。 每个 MatchingPrecedence 值必须在 [1,10000] 的范围内。 请注意,如果未指定优先顺序,则其默认设为 1000。

  • rules ([]PolicyRulesWithSubjects)

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

    rules 描述哪些请求将与这个流模式匹配。只有当至少一条规则与请求匹配时, 才视为此 FlowSchema 与该请求匹配。如果字段值为空表,则 FlowSchema 不会与任何请求匹配。

    PolicyRulesWithSubjects 给出针对 API 服务器请求的一个测试。 该测试将检查发出请求的主体、所请求的动作和要操作的资源。 只有同时满足以下两个条件时,才表示此 PolicyRulesWithSubjects 与请求匹配: (a) 至少一个主体成员与请求匹配且 (b) 至少 resourceRules 或 nonResourceRules 的一个成员与请求匹配。

    • rules.subjects ([]Subject),必需

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

      subjects 是此规则相关的普通用户、服务账号或组的列表。在这个列表中必须至少有一个成员。 同时包含 system:authenticated 和 system:unauthenticated 用户组的列表会与每个请求匹配。 此字段为必需。

      Subject 用来与匹配请求的发起方,请求的发起方由请求身份认证系统识别出来。 有三种方式来匹配一个发起方:按用户、按组或按服务账号。

      • rules.subjects.kind (string),必需

        kind 标示其他字段中的哪个字段必须非空。必需。

      • rules.subjects.group (GroupSubject)

        group 根据用户组名称进行匹配。

        GroupSubject 保存组类别主体的详细信息。

      • rules.subjects.serviceAccount (ServiceAccountSubject)

        serviceAccount 与 ServiceAccount 对象进行匹配。

        ServiceAccountSubject 保存服务账号类别主体的详细信息。

        • rules.subjects.serviceAccount.name (string),必需

          name 是要匹配的 ServiceAccount 对象的名称,可使用 * 匹配所有名称。必需。

        • rules.subjects.serviceAccount.namespace (string),必需

          namespace 是要匹配的 ServiceAccount 对象的名字空间。必需。

      • rules.subjects.user (UserSubject)

        user 根据用户名进行匹配。

        UserSubject 保存用户类别主体的详细信息。

        • rules.subjects.user.name (string),必需

          name 是要匹配的用户名,可使用 * 匹配所有用户名。必需。

    • rules.nonResourceRules ([]NonResourcePolicyRule)

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

      nonResourceRules 是由 NonResourcePolicyRule 对象构成的列表, 根据请求的动作和目标非资源 URL 来识别匹配的请求。

      NonResourcePolicyRule 是根据请求的动作和目标非资源 URL 来匹配非资源请求的一种规则。 只有满足以下两个条件时,NonResourcePolicyRule 才会匹配一个请求: (a) 至少 verbs 的一个成员与请求匹配且 (b) 至少 nonResourceURLs 的一个成员与请求匹配。

      • rules.nonResourceRules.nonResourceURLs ([]string),必需

        集合:合并期间保留唯一值

        nonResourceURLs 是用户有权访问的一组 URL 前缀,不可以为空。 此字段为必需设置的字段。例如:

        • "/healthz" 是合法的
        • "/hea*" 是不合法的
        • "/hea" 是合法的但不会与任何项匹配
        • "/hea/*" 也不会与任何项匹配
        • "/healthz/*" 与所有组件自身的的健康检查路径匹配。 * 与所有非资源 URL 匹配。如果存在此字符,则必须是唯一的输入项。 必需。
      • rules.nonResourceRules.verbs ([]string),必需

        集合:在合并期间保留唯一值

        verbs 是与动作匹配的列表,不可以为空。* 与所有动作匹配。 如果存在此字符,则必须是唯一的输入项。必需。

    • rules.resourceRules ([]ResourcePolicyRule)

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

      resourceRules 是 ResourcePolicyRule 对象的列表,根据请求的动作和目标资源识别匹配的请求。 resourceRulesnonResourceRules 两者必须至少有一个非空。

      ResourcePolicyRule 是用来匹配资源请求的规则,对请求的动作和目标资源进行测试。 只有满足以下条件时,ResourcePolicyRule 才会与某个资源请求匹配: (a) 至少 verbs 的一个成员与请求的动作匹配, (b) 至少 apiGroups 的一个成员与请求的 API 组匹配, (c) 至少 resources 的一个成员与请求的资源匹配, (d) 要么 (d1) 请求未指定一个名字空间(即,namespace=="")且 clusterScope 为 true, 要么 (d2) 请求指定了一个名字空间,且至少 namespaces 的一个成员与请求的名字空间匹配。

      • rules.resourceRules.apiGroups ([]string),必需

        集合:合并期间保留唯一值

        apiGroups 是与 API 组匹配的列表,不可以为空。* 表示与所有 API 组匹配。 如果存在此字符,则其必须是唯一的条目。必需。

      • rules.resourceRules.resources ([]string),必需

        集合:合并期间保留唯一值

        resources 是匹配的资源(即小写和复数)的列表,如果需要的话,还可以包括子资源。 例如 [ "services", "nodes/status" ]。此列表不可以为空。 * 表示与所有资源匹配。如果存在此字符,则必须是唯一的条目。必需。

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

        集合:合并期间保留唯一值

        verbs 是匹配的动作的列表,不可以为空。* 表示与所有动作匹配。 如果存在此字符,则必须是唯一的条目。必需。

      • rules.resourceRules.clusterScope (boolean)

        clusterScope 表示是否与未指定名字空间 (出现这种情况的原因是该资源没有名字空间或请求目标面向所有名字空间)的请求匹配。 如果此字段被省略或为 false,则 namespaces 字段必须包含一个非空的列表。

      • rules.resourceRules.namespaces ([]string)

        集合:合并期间保留唯一值

        namespaces 是限制匹配的目标的名字空间的列表。 指定一个目标名字空间的请求只会在以下某一个情况满足时进行匹配: (a) 此列表包含该目标名字空间或 (b) 此列表包含 *。 请注意,* 与所指定的任何名字空间匹配,但不会与未指定 名字空间的请求匹配 (请参阅 clusterScope 字段)。此列表可以为空,但前提是 clusterScope 为 true。

FlowSchemaStatus

FlowSchemaStatus 表示 FlowSchema 的当前状态。


  • conditions ([]FlowSchemaCondition)

    补丁策略:根据键 type 合并

    Map:合并期间保留根据键 type 保留其唯一值

    conditions 是 FlowSchema 当前状况的列表。

    FlowSchemaCondition 描述 FlowSchema 的状况。

    • conditions.lastTransitionTime (Time)

      lastTransitionTime 是状况上一次从一个状态转换为另一个状态的时间。

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

    • conditions.message (string)

      message 是一条人类可读的消息,表示上一次转换有关的详细信息。

    • conditions.reason (string)

      reason 是状况上次转换原因的、驼峰格式命名的、唯一的一个词。

    • conditions.status (string)

      status 是状况的状态。可以是 True、False、Unknown。必需。

    • conditions.type (string)

      type 是状况的类型。必需。

FlowSchemaList

FlowSchemaList 是 FlowSchema 对象的列表。


  • apiVersion: flowcontrol.apiserver.k8s.io/v1beta3

  • kind: FlowSchemaList

操作


get 读取指定的 FlowSchema

HTTP 请求

GET /apis/flowcontrol.apiserver.k8s.io/v1beta3/flowschemas/{name}

参数

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

    FlowSchema 的名称

  • pretty (查询参数): string

    pretty

响应

200 (FlowSchema): OK

401: Unauthorized

get 读取指定 FlowSchema 的状态

HTTP 请求

GET /apis/flowcontrol.apiserver.k8s.io/v1beta3/flowschemas/{name}/status

参数

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

    FlowSchema 的名称

  • pretty (查询参数): string

    pretty

响应

200 (FlowSchema): OK

401: Unauthorized

list 列出或监视 FlowSchema 类别的对象

HTTP 请求

GET /apis/flowcontrol.apiserver.k8s.io/v1beta3/flowschemas

参数

响应

200 (FlowSchemaList): OK

401: Unauthorized

create 创建 FlowSchema

HTTP 请求

POST /apis/flowcontrol.apiserver.k8s.io/v1beta3/flowschemas

参数

响应

200 (FlowSchema): OK

201 (FlowSchema): Created

202 (FlowSchema): Accepted

401: Unauthorized

update 替换指定的 FlowSchema

HTTP 请求

PUT /apis/flowcontrol.apiserver.k8s.io/v1beta3/flowschemas/{name}

参数

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

    FlowSchema 的名称

  • body: FlowSchema,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (FlowSchema): OK

201 (FlowSchema): Created

401: Unauthorized

update 替换指定的 FlowSchema 的状态

HTTP 请求

PUT /apis/flowcontrol.apiserver.k8s.io/v1beta3/flowschemas/{name}/status

参数

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

    FlowSchema 的名称

  • body: FlowSchema,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • pretty (查询参数): string

    pretty

响应

200 (FlowSchema): OK

201 (FlowSchema): Created

401: Unauthorized

patch 部分更新指定的 FlowSchema

HTTP 请求

PATCH /apis/flowcontrol.apiserver.k8s.io/v1beta3/flowschemas/{name}

参数

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

    FlowSchema 的名称

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (FlowSchema): OK

201 (FlowSchema): Created

401: Unauthorized

patch 部分更新指定的 FlowSchema 的状态

HTTP 请求

PATCH /apis/flowcontrol.apiserver.k8s.io/v1beta3/flowschemas/{name}/status

参数

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

    FlowSchema 的名称

  • body: Patch,必需

  • dryRun (查询参数): string

    dryRun

  • fieldManager (查询参数): string

    fieldManager

  • fieldValidation (查询参数): string

    fieldValidation

  • force (查询参数): boolean

    force

  • pretty (查询参数): string

    pretty

响应

200 (FlowSchema): OK

201 (FlowSchema): Created

401: Unauthorized

delete 删除 FlowSchema

HTTP 请求

DELETE /apis/flowcontrol.apiserver.k8s.io/v1beta3/flowschemas/{name}

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 FlowSchema 的集合

HTTP 请求

DELETE /apis/flowcontrol.apiserver.k8s.io/v1beta3/flowschemas

参数

响应

200 (Status): OK

401: Unauthorized

8.8 - PriorityLevelConfiguration v1beta3

PriorityLevelConfiguration 表示一个优先级的配置。

apiVersion: flowcontrol.apiserver.k8s.io/v1beta3

import "k8s.io/api/flowcontrol/v1beta3"

PriorityLevelConfiguration

PriorityLevelConfiguration 表示一个优先级的配置。


  • apiVersion: flowcontrol.apiserver.k8s.io/v1beta3

  • kind: PriorityLevelConfiguration

PriorityLevelConfigurationSpec

PriorityLevelConfigurationSpec 指定一个优先级的配置。


  • type (string),必需

    type 指示此优先级是否遵从有关请求执行的限制。 取值为 "Exempt" 意味着此优先级的请求不遵从某个限制(且因此从不排队)且不会减损其他优先级可用的容量。 取值为 "Limited" 意味着 (a) 此优先级的请求遵从这些限制且 (b) 服务器某些受限的容量仅可用于此优先级。必需。

  • exempt (ExemptPriorityLevelConfiguration)

    exempt 指定了对于豁免优先级的请求如何处理。 如果 type 取值为 "Limited",则此字段必须为空。 如果 type 取值为 "Exempt",则此字段可以非空。 如果为空且 type 取值为 "Exempt",则应用 ExemptPriorityLevelConfiguration 的默认值。

    ExemptPriorityLevelConfiguration 描述豁免请求处理的可配置方面。 在强制豁免配置对象中,与 spec 中的其余部分不同,此处字段的取值可以被授权用户修改。

    • exempt.lendablePercent (int32)

      lendablePercent 规定该级别的 NominalCL 可被其他优先级租借的百分比。 此字段的值必须在 0 到 100 之间,包括 0 和 100,默认为 0。 其他级别可以从该级别借用的席位数被称为此级别的 LendableConcurrencyLimit(LendableCL),定义如下。

      LendableCL(i) = round( NominalCL(i) * lendablePercent(i)/100.0 )

    • exempt.nominalConcurrencyShares (int32)

      nominalConcurrencyShares(NCS)也被用来计算该级别的 NominalConcurrencyLimit(NominalCL)。 字段值是为该优先级保留的执行席位的数量。这一设置不限制此优先级别的调度行为, 但会通过借用机制影响其他优先级。服务器的并发限制(ServerCL)会按照各个优先级的 NCS 值按比例分配:

      NominalCL(i) = ceil( ServerCL * NCS(i) / sum_ncs ) sum_ncs = sum[priority level k] NCS(k)

      较大的数字意味着更大的标称并发限制,且将影响其他优先级。此字段的默认值为零。

  • limited (LimitedPriorityLevelConfiguration)

    limited 指定如何为某个受限的优先级处理请求。 当且仅当 type"Limited" 时,此字段必须为非空。

    LimitedPriorityLevelConfiguration 指定如何处理需要被限制的请求。它解决两个问题:

    • 如何限制此优先级的请求?
    • 应如何处理超出此限制的请求?
    • limited.borrowingLimitPercent (int32)

      borrowingLimitPercent 配置如果存在,则可用来限制此优先级可以从其他优先级中租借多少资源。 该限制被称为该级别的 BorrowingConcurrencyLimit(BorrowingCL),它限制了该级别可以同时租借的资源总数。 该字段保存了该限制与该级别标称并发限制之比。当此字段非空时,必须为正整数,并按以下方式计算限制值:

      BorrowingCL(i) = round(NominalCL(i) * borrowingLimitPercent(i) / 100.0)

      该字段值可以大于100,表示该优先级可以大于自己标称并发限制(NominalCL)。当此字段为 nil 时,表示无限制。

    • limited.lendablePercent (int32)

      lendablePercent 规定了 NominalCL 可被其他优先级租借资源数百分比。 此字段的值必须在 0 到 100 之间,包括 0 和 100,默认为 0。 其他级别可以从该级别借用的资源数被称为此级别的 LendableConcurrencyLimit(LendableCL),定义如下。

      LendableCL(i) = round( NominalCL(i) * lendablePercent(i)/100.0 )

    • limited.limitResponse (LimitResponse)

      limitResponse 指示如何处理当前无法立即执行的请求。

      LimitResponse 定义如何处理当前无法立即执行的请求。

      • limited.limitResponse.type (string),必需

        type 是 “Queue” 或 “Reject”。此字段必须设置。 “Queue” 意味着在到达时无法被执行的请求可以被放到队列中,直到它们被执行或者队列长度超出限制为止。 “Reject” 意味着到达时无法执行的请求将被拒绝。

      • limited.limitResponse.queuing (QueuingConfiguration)

        queuing 包含排队所用的配置参数。只有 type"Queue" 时,此字段才可以为非空。

        QueuingConfiguration 保存排队所用的配置参数。

        • limited.limitResponse.queuing.handSize (int32)

          handSize 是一个小的正数,用于配置如何将请求随机分片到队列中。 当以该优先级将请求排队时,将对请求的流标识符(字符串对)进行哈希计算, 该哈希值用于打乱队列队列的列表,并处理此处指定的一批请求。 请求被放入这一批次中最短的队列中。 handSize 不得大于 queues,并且应该明显更小(以便几个大的流量不会使大多数队列饱和)。 有关设置此字段的更多详细指导,请参阅面向用户的文档。此字段的默认值为 8。

        • limited.limitResponse.queuing.queueLengthLimit (int32)

          queueLengthLimit 是任意时刻允许在此优先级的给定队列中等待的请求数上限; 额外的请求将被拒绝。 此值必须是正数。如果未指定,则默认为 50。

        • limited.limitResponse.queuing.queues (int32)

          queues 是这个优先级的队列数。此队列在每个 API 服务器上独立存在。此值必须是正数。 将其设置为 1 相当于禁止了混洗分片操作,进而使得对相关流模式的区分方法不再有意义。 此字段的默认值为 64。

    • limited.nominalConcurrencyShares (int32)

      nominalConcurrencyShares(NCS)用于计算该优先级的标称并发限制(NominalCL)。 NCS 表示可以在此优先级同时运行的席位数量上限,包括来自本优先级的请求, 以及从此优先级租借席位的其他级别的请求。 服务器的并发度限制(ServerCL)根据 NCS 值按比例分别给各 Limited 优先级:

      NominalCL(i) = ceil( ServerCL * NCS(i) / sum_ncs ) sum_ncs = sum[priority level k] NCS(k)

      较大的数字意味着更大的标称并发限制,但是这将牺牲其他优先级的资源。该字段的默认值为 30。

PriorityLevelConfigurationStatus

PriorityLevelConfigurationStatus 表示 “请求优先级” 的当前状况。


  • conditions ([]PriorityLevelConfigurationCondition)

    Map:合并期间保留根据键 type 保留其唯一值

    conditions 是 “请求优先级” 的当前状况。

    PriorityLevelConfigurationCondition 定义优先级的状况。

    • conditions.lastTransitionTime (Time)

      lastTransitionTime 是状况上次从一个状态转换为另一个状态的时间。

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

    • conditions.message (string)

      message 是人类可读的消息,指示有关上次转换的详细信息。

    • conditions.reason (string)

      reason 是状况上次转换原因的、驼峰格式命名的、唯一的一个词。

    • conditions.status (string)

      status 表示状况的状态,取值为 True、False 或 Unknown 之一。必需。

    • conditions.type (string)

      type 表示状况的类型,必需。

PriorityLevelConfigurationList

PriorityLevelConfigurationList 是 PriorityLevelConfiguration 对象的列表。


  • apiVersion: flowcontrol.apiserver.k8s.io/v1beta3

  • kind: PriorityLevelConfigurationList

操作


get 读取指定的 PriorityLevelConfiguration

HTTP 请求

GET /apis/flowcontrol.apiserver.k8s.io/v1beta3/prioritylevelconfigurations/{name}

参数

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

    PriorityLevelConfiguration 的名称。

  • pretty查询参数):string

    pretty

响应

200 (PriorityLevelConfiguration): OK

401: Unauthorized

get 读取指定的 PriorityLevelConfiguration 的状态

HTTP 请求

GET /apis/flowcontrol.apiserver.k8s.io/v1beta3/prioritylevelconfigurations/{name}/status

参数

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

    PriorityLevelConfiguration 的名称。

  • pretty查询参数):string

    pretty

响应

200 (PriorityLevelConfiguration): OK

401: Unauthorized

list 列出或监视 PriorityLevelConfiguration 类别的对象

HTTP 请求

GET /apis/flowcontrol.apiserver.k8s.io/v1beta3/prioritylevelconfigurations

参数

响应

200 (PriorityLevelConfigurationList): OK

401: Unauthorized

create 创建 PriorityLevelConfiguration

HTTP 请求

POST /apis/flowcontrol.apiserver.k8s.io/v1beta3/prioritylevelconfigurations

参数

响应

200 (PriorityLevelConfiguration): OK

201 (PriorityLevelConfiguration): Created

202 (PriorityLevelConfiguration): Accepted

401: Unauthorized

update 替换指定的 PriorityLevelConfiguration

HTTP 请求

PUT /apis/flowcontrol.apiserver.k8s.io/v1beta3/prioritylevelconfigurations/{name}

参数

响应

200 (PriorityLevelConfiguration): OK

201 (PriorityLevelConfiguration): Created

401: Unauthorized

update 替换指定的 PriorityLevelConfiguration 的状态

HTTP 请求

PUT /apis/flowcontrol.apiserver.k8s.io/v1beta3/prioritylevelconfigurations/{name}/status

参数

响应

200 (PriorityLevelConfiguration): OK

201 (PriorityLevelConfiguration): Created

401: Unauthorized

patch 部分更新指定的 PriorityLevelConfiguration

HTTP 请求

PATCH /apis/flowcontrol.apiserver.k8s.io/v1beta3/prioritylevelconfigurations/{name}

参数

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

    PriorityLevelConfiguration 的名称。

  • body: Patch,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (PriorityLevelConfiguration): OK

201 (PriorityLevelConfiguration): Created

401: Unauthorized

patch 部分更新指定的 PriorityLevelConfiguration 的状态

HTTP 请求

PATCH /apis/flowcontrol.apiserver.k8s.io/v1beta3/prioritylevelconfigurations/{name}/status

参数

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

    PriorityLevelConfiguration 的名称。

  • body: Patch,必需

  • dryRun查询参数):string

    dryRun

  • fieldManager查询参数):string

    fieldManager

  • fieldValidation查询参数):string

    fieldValidation

  • force查询参数):boolean

    force

  • pretty查询参数):string

    pretty

响应

200 (PriorityLevelConfiguration): OK

201 (PriorityLevelConfiguration): Created

401: Unauthorized

delete 删除 PriorityLevelConfiguration

HTTP 请求

DELETE /apis/flowcontrol.apiserver.k8s.io/v1beta3/prioritylevelconfigurations/{name}

参数

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

    PriorityLevelConfiguration 的名称。

  • body: DeleteOptions

  • dryRun查询参数):string

    dryRun

  • gracePeriodSeconds查询参数):integer

    gracePeriodSeconds

  • pretty查询参数):string

    pretty

  • propagationPolicy查询参数):string

    propagationPolicy

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 PriorityLevelConfiguration 的集合

HTTP 请求

DELETE /apis/flowcontrol.apiserver.k8s.io/v1beta3/prioritylevelconfigurations

参数

响应

200 (Status): OK

401: Unauthorized

8.9 - Binding

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

apiVersion: v1

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

Binding

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


标准对象的元数据, 更多信息: 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

8.10 - ComponentStatus

ComponentStatus(和 ComponentStatusList)保存集群检验信息。

apiVersion: v1

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

ComponentStatus

ComponentStatus(和 ComponentStatusList)保存集群检验信息。 已废弃:该 API 在 v1.19 及更高版本中废弃。


  • apiVersion: v1

  • kind: ComponentStatus

  • metadata (ObjectMeta)

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

  • conditions ([]ComponentCondition)

    补丁策略:基于键 type 合并

    观测到的组件状况的列表。

    组件状况相关信息。

    • conditions.status (string),必需

      组件状况的状态。“Healthy” 的有效值为:“True”、“False” 或 “Unknown”。

    • conditions.type (string),必需

    组件状况的类型。有效值:“Healthy”

    • conditions.error (string)

      组件状况的错误码。例如,一个健康检查错误码。

    • conditions.message (string)

      组件状况相关消息。例如,有关健康检查的信息。

ComponentStatusList

作为 ComponentStatus 对象列表,所有组件状况的状态。 已废弃:该 API 在 v1.19 及更高版本中废弃。


  • apiVersion: v1

  • kind: ComponentStatusList

操作


get 读取指定的 ComponentStatus

HTTP 请求

GET /api/v1/componentstatuses/{name}

参数

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

    ComponentStatus 的名称

  • pretty (查询参数): string

    pretty

响应

200 (ComponentStatus): OK

401: Unauthorized

list 列出 ComponentStatus 类别的对象

HTTP 请求

GET /api/v1/componentstatuses

参数

响应

200 (ComponentStatusList): OK

401: Unauthorized

8.11 - ClusterCIDR v1alpha1

ClusterCIDR 表示启用 MultiCIDRRangeAllocator 时针对每个节点 Pod CIDR 分配进行的单个配置(参阅针对 kube-controller-manager 的配置)。

apiVersion: networking.k8s.io/v1alpha1

import "k8s.io/api/networking/v1alpha1"

ClusterCIDR

ClusterCIDR 表示启用 MultiCIDRRangeAllocator 时针对每个节点 Pod CIDR 分配进行的单个配置 (参阅针对 kube-controller-manager 的配置)。 一个集群可能有任意数量的 ClusterCIDR 资源,在为节点分配 CIDR 时将考虑所有这些资源。 当节点选择算符与相关节点匹配并且有空闲 CIDR 可供分配时,ClusterCIDR 才能有资格用于给定的节点。 在存在多个匹配的 ClusterCIDR 资源的情况下,分配器将尝试使用内部启发式算法来解决这一问题, 但可以使用节点选择算符与该节点匹配的任何 ClusterCIDR。


ClusterCIDRSpec

ClusterCIDRSpec 定义 ClusterCIDR 的预期状态。


  • perNodeHostBits (int32),必需

    perNodeHostBits 定义每个节点要配置的主机位数。 子网掩码决定有多少地址用于网络位和主机位。 例如 IPv4 地址 192.168.0.0/24 将该地址拆分为 24 位用于网络部分和 8 位用于主机部分。 要分配 256 个 IP,需将此字段设置为 8(针对 IPv4 的掩码为 /24,针对 IPv6 的掩码为 /120)。 最小值为 4(16 个 IP)。此字段是不可变的。

  • ipv4 (string)

    ipv4 以 CIDR 表示法定义 IPv4 IP 块(例如 “10.0.0.0/8”)。 必须至少指定 ipv4 和 ipv6 之一。该字段是不可变的。

  • ipv6 (string)

    ipv6 以 CIDR 表示法定义 IPv6 IP 块(例如 “2001:db8::/64”)。 必须至少指定 ipv4 和 ipv6 之一。 该字段是不可变的。

  • nodeSelector (NodeSelector)

    nodeSelector 定义该配置适用于哪些节点。 空白或值为 nil 的 nodeSelector 选择所有节点。该字段是不可变的。

    节点选择算符表示在一组节点上一个或多个标签查询结果的并集; 也就是说,它表示由节点选择算符条件表示的选择算符的逻辑或计算结果。

    • nodeSelector.nodeSelectorTerms ([]NodeSelectorTerm),必需

      必需。节点选择算符条件的列表。这些条件以逻辑与进行计算。

      一个 null 或空的节点选择算符条件不会与任何对象匹配。这些要求会按逻辑与的关系来计算。 TopologySelectorTerm 类别实现了 NodeSelectorTerm 的子集。

      • nodeSelector.nodeSelectorTerms.matchExpressions ([]NodeSelectorRequirement)

        基于节点标签所设置的节点选择算符要求的列表。

      • nodeSelector.nodeSelectorTerms.matchFields ([]NodeSelectorRequirement)

        基于节点字段所设置的节点选择算符要求的列表。

ClusterCIDRList

ClusterCIDRList 包含 ClusterCIDR 的列表。


  • items ([]ClusterCIDR),必需

    items 是 ClusterCIDRs 的列表。

操作


get 读取指定的 ClusterCIDR

HTTP 请求

GET /apis/networking.k8s.io/v1alpha1/clustercidrs/{name}

参数

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

    ClusterCIDR 的名称

  • pretty (查询参数):string

    pretty

响应

200 (ClusterCIDR): OK

401: Unauthorized

list 列出或监视 ClusterCIDR 类别的对象

HTTP 请求

GET /apis/networking.k8s.io/v1alpha1/clustercidrs

参数

响应

200 (ClusterCIDRList): OK

401: Unauthorized

create 创建 ClusterCIDR

HTTP 请求

POST /apis/networking.k8s.io/v1alpha1/clustercidrs

参数

响应

200 (ClusterCIDR): OK

201 (ClusterCIDR): Created

202 (ClusterCIDR): Accepted

401: Unauthorized

update 替换指定的 ClusterCIDR

HTTP 请求

PUT /apis/networking.k8s.io/v1alpha1/clustercidrs/{name}

参数

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

    ClusterCIDR 的名称

  • body: ClusterCIDR,必需

  • dryRun (查询参数):string

    dryRun

  • fieldManager (查询参数):string

    fieldManager

  • fieldValidation (查询参数):string

    fieldValidation

  • pretty (查询参数):string

    pretty

响应

200 (ClusterCIDR): OK

201 (ClusterCIDR): Created

401: Unauthorized

patch 部分更新指定的 ClusterCIDR

HTTP 请求

PATCH /apis/networking.k8s.io/v1alpha1/clustercidrs/{name}

参数

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

    ClusterCIDR 的名称

  • body: Patch,必需

  • dryRun (查询参数):string

    dryRun

  • fieldManager (查询参数):string

    fieldManager

  • fieldValidation (查询参数):string

    fieldValidation

  • force (查询参数):boolean

    force

  • pretty (查询参数):string

    pretty

响应

200 (ClusterCIDR): OK

201 (ClusterCIDR): Created

401: Unauthorized

delete 删除 ClusterCIDR

HTTP 请求

DELETE /apis/networking.k8s.io/v1alpha1/clustercidrs/{name}

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 ClusterCIDR 的集合

HTTP 请求

DELETE /apis/networking.k8s.io/v1alpha1/clustercidrs

参数

响应

200 (Status): OK

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 是选择器应用的标签键。

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

    代表主键与值集之间的关系。合法的 operator 值包括 InNotInExistsDoesNotExistGtLt

  • values ([]string)

    一个由字符串值组成的数组。如果 operator 是 InNotIn,则 values 数组不能为空。 如果 operator 为 ExistsDoesNotExist,则 values 数组只能为空。 如果 operator 为 GtLt,则 values 数组只能包含一个元素,并且该元素会被解释为整数。 在执行策略性合并补丁操作时,此数组会被整体替换。

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 在命名空间内必须是唯一的。创建资源时需要,尽管某些资源可能允许客户端请求自动地生成适当的名称。 名称主要用于创建幂等性和配置定义。无法更新。更多信息: https://kubernetes.io/zh-cn/docs/concepts/overview/working-with-objects/names#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。无法更新。更多信息: https://kubernetes.io/zh-cn/docs/concepts/overview/working-with-objects/namespaces

  • labels (map[string]string)

    可用于组织和分类(确定范围和选择)对象的字符串键和值的映射。 可以匹配 ReplicationController 和 Service 的选择算符。更多信息: https://kubernetes.io/zh-cn/docs/concepts/overview/working-with-objects/labels

  • annotations (map[string]string)

    annotations 是一个非结构化的键值映射,存储在资源中,可以由外部工具设置以存储和检索任意元数据。 它们不可查询,在修改对象时应保留。更多信息: https://kubernetes.io/zh-cn/docs/concepts/overview/working-with-objects/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 是添加 managedFields 条目时的时间戳。 如果一个字段被添加、管理器更新任一所属字段值或移除一个字段,该时间戳也会更新。 从此条目中移除一个字段时该时间戳不会更新,因为另一个管理器将它接管了。

      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 操作更改。

    由系统填充。只读。更多信息: https://kubernetes.io/zh-cn/docs/concepts/overview/working-with-objects/names#uids

9.8 - ObjectReference

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

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

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


  • apiVersion (string)

    被引用者的 API 版本。

  • fieldPath (string)

    如果引用的是对象的某个对象是整个对象,则该字符串而不是应包含的 JSON/Go 字段有效访问语句, 例如 desiredState.manifest.containers[ 2 ]。例如,如果对象引用针对的是 Pod 中的一个容器, 此字段取值类似于:spec.containers{name}name 指触发的容器的名称), 或者如果没有指定容器名称,spec.containers[ 2 ](此 Pod 中索引为 2 的容器)。 选择这种只是为了有一些定义好的语法来引用对象的部分。

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.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(当有单个可以描述的资源时)。更多信息: https://kubernetes.io/zh-cn/docs/concepts/overview/working-with-objects/names#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 - 其他资源

10.1 - ValidatingAdmissionPolicyBindingList v1beta1

apiVersion: admissionregistration.k8s.io/v1beta1

import "k8s.io/api/admissionregistration/v1beta1"

11 - 常用参数

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://pkg.go.dev/unicode#IsPrint 所定义。


fieldSelector

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


fieldValidation

fieldValidation 指示服务器如何处理请求(POST/PUT/PATCH)中包含未知或重复字段的对象。 有效值为:

  • Ignore:这将忽略从对象中默默删除的所有未知字段,并将忽略除解码器遇到的最后一个重复字段之外的所有字段。 这是在 v1.23 之前的默认行为。
  • Warn:这将针对从对象中删除的各个未知字段以及所遇到的各个重复字段,分别通过标准警告响应头发出警告。 如果没有其他错误,请求仍然会成功,并且只会保留所有重复字段中的最后一个。 这是 v1.23+ 版本中的默认设置。
  • 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/zh-cn/docs/reference/using-api/api-concepts/#resource-versions

默认不设置。


resourceVersionMatch

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

默认不设置。


sendInitialEvents

sendInitialEvents=true 可以和 watch=true 一起设置。 在这种情况下,监视通知流将从合成事件开始,以生成集合中对象的当前状态。 一旦发送了所有此类事件,将发送合成的 "Bookmark" 事件。"bookmark" 将报告对象集合对应的 ResourceVersion(RV),并标有 "k8s.io/initial-events-end": "true" 注解。 之后,监视通知流将照常进行,发送与所监视的对象的变更(在 RV 之后)对应的监视事件。

当设置了 sendInitialEvents 选项时,我们还需要设置 resourceVersionMatch 选项。watch 请求的语义如下:

  • resourceVersionMatch = NotOlderThan 被解释为"数据至少与提供的 resourceVersion 一样新", 最迟当状态同步到与 ListOptions 提供的版本一样新的 resourceVersion 时, 发送 bookmark 事件。如果 resourceVersion 未设置,这将被解释为"一致读取", 最迟当状态同步到开始处理请求的那一刻时,发送 bookmark 事件。
  • resourceVersionMatch 设置为任何其他值或返回 unsetInvalid 错误。

如果 resourceVersion=""resourceVersion="0"(出于向后兼容性原因),默认为 true,否则默认为 false。


timeoutSeconds

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


watch

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