有状态集
apiVersion: apps/v1
import "k8s.io/api/apps/v1"
有状态集
StatefulSet 代表一组具有稳定身份的 Pod。身份定义为
- 网络: 单个稳定的 DNS 和主机名。
- 存储: 按照请求提供尽可能多的 VolumeClaim。
StatefulSet 保证给定的网络身份始终映射到相同的存储身份。
apiVersion: apps/v1
kind: StatefulSet
metadata (ObjectMeta)
标准对象的元数据。更多信息: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
spec (StatefulSetSpec)
Spec 定义了此集合中 Pod 的期望身份。
status (StatefulSetStatus)
Status 是此 StatefulSet 中 Pod 的当前状态。此数据可能在一段时间内过时。
StatefulSetSpec
StatefulSetSpec 是 StatefulSet 的规范。
serviceName (string), 必需
serviceName 是管理此 StatefulSet 的服务的名称。此服务必须在 StatefulSet 之前存在,并负责该集合的网络身份。Pod 获取遵循以下模式的 DNS/主机名: pod-specific-string.serviceName.default.svc.cluster.local,其中 "pod-specific-string" 由 StatefulSet 控制器管理。
selector (LabelSelector), 必需
selector 是对应该匹配副本数的 Pod 的标签查询。它必须与 Pod 模板的标签匹配。更多信息: https://kubernetes.ac.cn/docs/concepts/overview/working-with-objects/labels/#label-selectors
template (PodTemplateSpec), 必需
template 是描述在检测到不足的副本时将创建的 Pod 的对象。StatefulSet 打出的每个 Pod 都将满足此模板,但与 StatefulSet 的其余部分具有唯一的身份。每个 Pod 都将使用格式 <statefulsetname>-<podindex> 命名。例如,一个名为 "web" 且索引号为 "3" 的 StatefulSet 中的 Pod 将被命名为 "web-3"。唯一允许的 template.spec.restartPolicy 值是 "Always"。
replicas (int32)
replicas 是给定模板的期望副本数。这些是副本,因为它们是相同模板的实例化,但单个副本也具有稳定的身份。如果未指定,则默认为 1。
updateStrategy (StatefulSetUpdateStrategy)
updateStrategy 指示当对模板进行修订时,StatefulSet 控制器将用来更新 StatefulSet 中 Pod 的 StatefulSetUpdateStrategy。
StatefulSetUpdateStrategy 指示 StatefulSet 控制器将用来执行更新的策略。它包括执行指示策略的更新所需的任何其他参数。
updateStrategy.type (string)
Type 指示 StatefulSetUpdateStrategy 的类型。默认值为 RollingUpdate。
updateStrategy.rollingUpdate (RollingUpdateStatefulSetStrategy)
RollingUpdate 用于在 Type 为 RollingUpdateStatefulSetStrategyType 时传达参数。
RollingUpdateStatefulSetStrategy 用于传达 RollingUpdateStatefulSetStrategyType 的参数。
updateStrategy.rollingUpdate.maxUnavailable (IntOrString)
更新期间可以不可用的 Pod 的最大数量。值可以是绝对数(例如: 5)或期望 Pod 的百分比(例如: 10%)。绝对数是通过四舍五入从百分比计算出来的。它不能为 0。默认为 1。此字段为 alpha 级,仅由启用 MaxUnavailableStatefulSet 特性开关的服务器处理。该字段适用于范围 0 到 Replicas-1 中的所有 Pod。这意味着如果范围 0 到 Replicas-1 中有任何不可用 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 控制器负责以维护 Pod 身份的方式将网络身份映射到声明。此列表中的每个声明都必须在模板中的一个容器中至少有一个匹配(按名称)的 volumeMount。此列表中的声明优先于模板中的任何卷,名称相同。
minReadySeconds (int32)
新创建的 Pod 在其任何容器崩溃之前应准备好的最短秒数,以便将其视为可用。默认为 0(Pod 准备好后将立即被视为可用)
persistentVolumeClaimRetentionPolicy (StatefulSetPersistentVolumeClaimRetentionPolicy)
persistentVolumeClaimRetentionPolicy 描述了从 volumeClaimTemplates 创建的持久卷声明的生命周期。默认情况下,所有持久卷声明都是按需创建的,并保留到手动删除为止。此策略允许更改生命周期,例如通过在删除其 StatefulSet 时或在其 Pod 缩减规模时删除持久卷声明。这需要启用 StatefulSetAutoDeletePVC 特性开关,该开关处于 alpha 状态。 +optional
StatefulSetPersistentVolumeClaimRetentionPolicy 描述了用于从 StatefulSet VolumeClaimTemplates 创建的 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 中副本索引的编号。默认的 ordinals 行为将 "0" 索引分配给第一个副本,并为每个请求的额外副本增加索引 1。使用 ordinals 字段需要启用 StatefulSetStartOrdinal 特性开关,该开关处于 beta 状态。
StatefulSetOrdinals 描述了用于在此 StatefulSet 中分配副本序数的策略。
ordinals.start (int32)
start 是代表第一个副本索引的数字。它可用于从默认的 0 索引名称以外的备用索引(例如: 1 索引)对副本进行编号,或用于编排从一个 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 创建的具有就绪条件的 Pod 数。
currentReplicas (int32)
currentReplicas 是 StatefulSet 控制器从 currentRevision 指示的 StatefulSet 版本创建的 Pod 数。
updatedReplicas (int32)
updatedReplicas 是 StatefulSet 控制器从 updateRevision 指示的 StatefulSet 版本创建的 Pod 数。
availableReplicas (int32)
此 StatefulSet 目标的可用 Pod(至少准备了 minReadySeconds 秒)的总数。
collisionCount (int32)
collisionCount 是 StatefulSet 的哈希冲突计数。StatefulSet 控制器使用此字段作为冲突避免机制,当它需要为最新的 ControllerRevision 创建名称时。
conditions ([]StatefulSetCondition)
补丁策略:按键
type
合并表示 StatefulSet 当前状态的最新可用观察结果。
StatefulSetCondition 描述了 StatefulSet 在某一时刻的状态。
conditions.status (string), required
条件的状态,True、False、Unknown 之一。
conditions.type (string), required
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 的集合。
apiVersion: apps/v1
kind: StatefulSetList
metadata (ListMeta)
标准列表的元数据。更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
items ([]StatefulSet), required
Items 是 StatefulSet 的列表。
操作
get
读取指定的 StatefulSet
HTTP 请求
GET /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}
参数
name (在路径中): string, required
StatefulSet 的名称
namespace (在路径中): string, required
pretty (在查询中): string
响应
200 (StatefulSet): OK
401: Unauthorized
get
读取指定 StatefulSet 的状态
HTTP 请求
GET /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/status
参数
name (在路径中): string, required
StatefulSet 的名称
namespace (在路径中): string, required
pretty (在查询中): string
响应
200 (StatefulSet): OK
401: Unauthorized
list
列出或观察 StatefulSet 类型的对象
HTTP 请求
GET /apis/apps/v1/namespaces/{namespace}/statefulsets
参数
namespace (在路径中): string, required
allowWatchBookmarks (在查询中): boolean
continue (在查询中): string
fieldSelector (在查询中): string
labelSelector (在查询中): string
limit (在查询中): integer
pretty (在查询中): string
resourceVersion (在查询中): string
resourceVersionMatch (在查询中): string
sendInitialEvents (在查询中): boolean
timeoutSeconds (在查询中): integer
watch (在查询中): boolean
响应
200 (StatefulSetList): OK
401: Unauthorized
list
列出或观察 StatefulSet 类型的对象
HTTP 请求
GET /apis/apps/v1/statefulsets
参数
allowWatchBookmarks (在查询中): boolean
continue (在查询中): string
fieldSelector (在查询中): string
labelSelector (在查询中): string
limit (在查询中): integer
pretty (在查询中): string
resourceVersion (在查询中): string
resourceVersionMatch (在查询中): string
sendInitialEvents (在查询中): boolean
timeoutSeconds (在查询中): integer
watch (在查询中): boolean
响应
200 (StatefulSetList): OK
401: Unauthorized
create
创建一个 StatefulSet
HTTP 请求
POST /apis/apps/v1/namespaces/{namespace}/statefulsets
参数
namespace (在路径中): string, required
body: StatefulSet, required
dryRun (在查询中): string
fieldManager (在查询中): string
fieldValidation (在查询中): string
pretty (在查询中): string
响应
200 (StatefulSet): OK
201 (StatefulSet): Created
202 (StatefulSet): Accepted
401: Unauthorized
update
替换指定的 StatefulSet
HTTP 请求
PUT /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}
参数
name (在路径中): string, required
StatefulSet 的名称
namespace (在路径中): string, required
body: StatefulSet, required
dryRun (在查询中): string
fieldManager (在查询中): string
fieldValidation (在查询中): string
pretty (在查询中): string
响应
200 (StatefulSet): OK
201 (StatefulSet): Created
401: Unauthorized
update
替换指定 StatefulSet 的状态
HTTP 请求
PUT /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/status
参数
name (在路径中): string, required
StatefulSet 的名称
namespace (在路径中): string, required
body: StatefulSet, required
dryRun (在查询中): string
fieldManager (在查询中): string
fieldValidation (在查询中): string
pretty (在查询中): string
响应
200 (StatefulSet): OK
201 (StatefulSet): Created
401: Unauthorized
patch
部分更新指定的 StatefulSet
HTTP 请求
PATCH /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}
参数
name (在路径中): string, required
StatefulSet 的名称
namespace (在路径中): string, required
body: Patch, required
dryRun (在查询中): string
fieldManager (在查询中): string
fieldValidation (在查询中): string
force (在查询中): boolean
pretty (在查询中): string
响应
200 (StatefulSet): OK
201 (StatefulSet): Created
401: Unauthorized
patch
部分更新指定 StatefulSet 的状态
HTTP 请求
PATCH /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/status
参数
name (在路径中): string, required
StatefulSet 的名称
namespace (在路径中): string, required
body: Patch, required
dryRun (在查询中): string
fieldManager (在查询中): string
fieldValidation (在查询中): string
force (在查询中): boolean
pretty (在查询中): string
响应
200 (StatefulSet): OK
201 (StatefulSet): Created
401: Unauthorized
delete
删除一个 StatefulSet
HTTP 请求
DELETE /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}
参数
name (在路径中): string, required
StatefulSet 的名称
namespace (在路径中): string, required
body: DeleteOptions
dryRun (在查询中): string
gracePeriodSeconds (在查询中): integer
pretty (在查询中): string
propagationPolicy (在查询中): string
响应
200 (Status): OK
202 (Status): Accepted
401: Unauthorized
deletecollection
删除 StatefulSet 的集合
HTTP 请求
DELETE /apis/apps/v1/namespaces/{namespace}/statefulsets
参数
namespace (在路径中): string, required
body: DeleteOptions
continue (在查询中): string
dryRun (在查询中): string
fieldSelector (在查询中): string
gracePeriodSeconds (在查询中): integer
labelSelector (在查询中): string
limit (在查询中): integer
pretty (在查询中): string
propagationPolicy (在查询中): string
resourceVersion (在查询中): string
resourceVersionMatch (在查询中): string
sendInitialEvents (在查询中): boolean
timeoutSeconds (在查询中): integer
响应
200 (Status): OK
401: Unauthorized
此页面是自动生成的。
如果您打算报告此页面存在问题,请在您的问题描述中提及该页面是自动生成的。修复可能需要在 Kubernetes 项目的其他地方进行。