Deployment
apiVersion: apps/v1
import "k8s.io/api/apps/v1"
Deployment
Deployment 支持对 Pod 和 ReplicaSet 进行声明式更新。
apiVersion: apps/v1
kind: Deployment
metadata (对象元数据)
标准对象的元数据。更多信息请参阅:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
spec (DeploymentSpec)
Deployment 期望行为的规约。
status (DeploymentStatus)
Deployment 最近观测到的状态。
DeploymentSpec
DeploymentSpec 是 Deployment 期望行为的规约。
selector (标签选择器),必需
Pod 的标签选择器。其 Pod 被此选择器选中的现有 ReplicaSet 将会受到此 Deployment 的影响。它必须匹配 Pod 模板的标签。
template (PodTemplateSpec),必需
模板描述了将创建的 Pod。template.spec.restartPolicy 唯一允许的值是 "Always"。
replicas (int32)
期望的 Pod 数量。这是一个指针,用于区分显式指定为零和未指定。默认为 1。
minReadySeconds (int32)
新创建的 Pod 在其容器未崩溃的情况下应该处于就绪状态的最小秒数,以便被视为可用。默认为 0(Pod 一就绪即被视为可用)
strategy (DeploymentStrategy)
Patch 策略:保留键
用于将现有 Pod 替换为新 Pod 的 Deployment 策略。
DeploymentStrategy 描述了如何将现有 Pod 替换为新 Pod。
strategy.type (string)
Deployment 类型。可以是 "Recreate" 或 "RollingUpdate"。默认为 RollingUpdate。
strategy.rollingUpdate (RollingUpdateDeployment)
滚动更新配置参数。仅当 DeploymentStrategyType = 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 或 string 的类型。在 JSON 或 YAML 编组(marshalling)和解组(unmarshalling)时,它生成或消费内部类型。这使得你可以拥有一个例如可以接受名称或数字的 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 或 string 的类型。在 JSON 或 YAML 编组(marshalling)和解组(unmarshalling)时,它生成或消费内部类型。这使得你可以拥有一个例如可以接受名称或数字的 JSON 字段。
revisionHistoryLimit (int32)
保留旧 ReplicaSet 的数量以支持回滚。这是一个指针,用于区分显式指定为零和未指定。默认为 10。
progressDeadlineSeconds (int32)
Deployment 在被认为失败之前可以取得进展的最长时间(以秒为单位)。Deployment 控制器将继续处理失败的 Deployment,并且在 Deployment 状态中将出现一个带有 ProgressDeadlineExceeded 原因的 condition。请注意,在 Deployment 暂停期间不会估计进度。默认为 600 秒。
paused (boolean)
表示 Deployment 已暂停。
DeploymentStatus
DeploymentStatus 是 Deployment 最近观测到的状态。
replicas (int32)
此 Deployment 所定位的非终止状态 Pod 总数(其标签与选择器匹配)。
availableReplicas (int32)
此 Deployment 所定位的可用非终止状态 Pod 总数(至少准备好 minReadySeconds)。
readyReplicas (int32)
此 Deployment 所定位的处于 Ready Condition 的非终止状态 Pod 总数。
unavailableReplicas (int32)
此 Deployment 所定位的不可用 Pod 总数。这是 Deployment 达到 100% 可用容量仍需要的 Pod 总数。它们可能是正在运行但尚未可用的 Pod,或者尚未创建的 Pod。
updatedReplicas (int32)
此 Deployment 所定位的、拥有期望模板规约的非终止状态 Pod 总数。
terminatingReplicas (int32)
此 Deployment 所定位的终止状态 Pod 总数。终止状态 Pod 具有非空的 .metadata.deletionTimestamp,并且尚未达到 Failed 或 Succeeded 的 .status.phase。
这是一个 alpha 字段。启用 DeploymentReplicaSetTerminatingReplicas 功能才能使用此字段。
collisionCount (int32)
Deployment 的哈希冲突计数。当 Deployment 控制器需要为最新的 ReplicaSet 创建名称时,使用此字段作为冲突避免机制。
conditions ([]DeploymentCondition)
Patch 策略:按键
type
合并Map:合并期间将保留键类型上的唯一值
表示 Deployment 当前状态的最新可用观测值。
DeploymentCondition 描述了 Deployment 在某一时刻的状态。
conditions.status (string),必需
Condition 的状态,可以是 True、False、Unknown 之一。
conditions.type (string),必需
Deployment Condition 的类型。
conditions.lastTransitionTime (Time)
Condition 最后一次从一个状态转换到另一个状态的时间。
Time 是 time.Time 的一个包装器,支持正确地编组到 YAML 和 JSON。提供了许多 time 包提供的工厂方法的包装器。
conditions.lastUpdateTime (Time)
此 condition 最后一次更新的时间。
Time 是 time.Time 的一个包装器,支持正确地编组到 YAML 和 JSON。提供了许多 time 包提供的工厂方法的包装器。
conditions.message (string)
人类可读的消息,指示有关状态转换的详细信息。
conditions.reason (string)
Condition 最后一次状态转换的原因。
observedGeneration (int64)
Deployment 控制器观测到的 generation。
DeploymentList
DeploymentList 是 Deployment 的列表。
apiVersion: apps/v1
kind: DeploymentList
metadata (列表元数据)
标准列表元数据。
items ([]Deployment),必需
Items 是 Deployment 的列表。
操作
get
读取指定的 Deployment
HTTP 请求
GET /apis/apps/v1/namespaces/{namespace}/deployments/{name}
参数
响应
200 (Deployment): 成功
401: 未授权
get
读取指定的 Deployment 的状态
HTTP 请求
GET /apis/apps/v1/namespaces/{namespace}/deployments/{name}/status
参数
响应
200 (Deployment): 成功
401: 未授权
list
列出或监视 Deployment 类型的对象
HTTP 请求
GET /apis/apps/v1/namespaces/{namespace}/deployments
参数
namespace (在路径中): string, 必需
allowWatchBookmarks (在查询参数中): boolean
continue (在查询参数中): string
fieldSelector (在查询参数中): string
labelSelector (在查询参数中): string
limit (在查询参数中): integer
pretty (在查询参数中): string
resourceVersion (在查询参数中): string
resourceVersionMatch (在查询参数中): string
sendInitialEvents (在查询参数中): boolean
timeoutSeconds (在查询参数中): integer
watch (在查询参数中): boolean
响应
200 (DeploymentList): 成功
401: 未授权
list
列出或监视 Deployment 类型的对象
HTTP 请求
GET /apis/apps/v1/deployments
参数
allowWatchBookmarks (在查询参数中): boolean
continue (在查询参数中): string
fieldSelector (在查询参数中): string
labelSelector (在查询参数中): string
limit (在查询参数中): integer
pretty (在查询参数中): string
resourceVersion (在查询参数中): string
resourceVersionMatch (在查询参数中): string
sendInitialEvents (在查询参数中): boolean
timeoutSeconds (在查询参数中): integer
watch (在查询参数中): boolean
响应
200 (DeploymentList): 成功
401: 未授权
create
创建一个 Deployment
HTTP 请求
POST /apis/apps/v1/namespaces/{namespace}/deployments
参数
namespace (在路径中): string, 必需
body: Deployment, 必需
dryRun (在查询参数中): string
fieldManager (在查询参数中): string
fieldValidation (在查询参数中): string
pretty (在查询参数中): string
响应
200 (Deployment): 成功
201 (Deployment): 已创建
202 (Deployment): 已接受
401: 未授权
update
替换指定的 Deployment
HTTP 请求
PUT /apis/apps/v1/namespaces/{namespace}/deployments/{name}
参数
name (在路径中): string, 必需
Deployment 的名称
namespace (在路径中): string, 必需
body: Deployment, 必需
dryRun (在查询参数中): string
fieldManager (在查询参数中): string
fieldValidation (在查询参数中): string
pretty (在查询参数中): string
响应
200 (Deployment): 成功
201 (Deployment): 已创建
401: 未授权
update
替换指定的 Deployment 的状态
HTTP 请求
PUT /apis/apps/v1/namespaces/{namespace}/deployments/{name}/status
参数
name (在路径中): string, 必需
Deployment 的名称
namespace (在路径中): string, 必需
body: Deployment, 必需
dryRun (在查询参数中): string
fieldManager (在查询参数中): string
fieldValidation (在查询参数中): string
pretty (在查询参数中): string
响应
200 (Deployment): 成功
201 (Deployment): 已创建
401: 未授权
patch
部分更新指定的 Deployment
HTTP 请求
PATCH /apis/apps/v1/namespaces/{namespace}/deployments/{name}
参数
name (在路径中): string, 必需
Deployment 的名称
namespace (在路径中): string, 必需
body: 补丁,必需
dryRun (在查询参数中): string
fieldManager (在查询参数中): string
fieldValidation (在查询参数中): string
force (在查询参数中): boolean
pretty (在查询参数中): string
响应
200 (Deployment): 成功
201 (Deployment): 已创建
401: 未授权
patch
部分更新指定的 Deployment 的状态
HTTP 请求
PATCH /apis/apps/v1/namespaces/{namespace}/deployments/{name}/status
参数
name (在路径中): string, 必需
Deployment 的名称
namespace (在路径中): string, 必需
body: 补丁,必需
dryRun (在查询参数中): string
fieldManager (在查询参数中): string
fieldValidation (在查询参数中): string
force (在查询参数中): boolean
pretty (在查询参数中): string
响应
200 (Deployment): 成功
201 (Deployment): 已创建
401: 未授权
delete
删除一个 Deployment
HTTP 请求
DELETE /apis/apps/v1/namespaces/{namespace}/deployments/{name}
参数
name (在路径中): string, 必需
Deployment 的名称
namespace (在路径中): string, 必需
body: 删除选项
dryRun (在查询参数中): string
gracePeriodSeconds (在查询参数中): integer
ignoreStoreReadErrorWithClusterBreakingPotential (在查询参数中): boolean
pretty (在查询参数中): string
propagationPolicy (在查询参数中): string
响应
200 (状态): 成功
202 (状态): 已接受
401: 未授权
deletecollection
删除 Deployment 集合
HTTP 请求
DELETE /apis/apps/v1/namespaces/{namespace}/deployments
参数
namespace (在路径中): string, 必需
body: 删除选项
continue (在查询参数中): string
dryRun (在查询参数中): string
fieldSelector (在查询参数中): string
gracePeriodSeconds (在查询参数中): integer
ignoreStoreReadErrorWithClusterBreakingPotential (在查询参数中): boolean
labelSelector (在查询参数中): string
limit (在查询参数中): integer
pretty (在查询参数中): string
propagationPolicy (在查询参数中): string
resourceVersion (在查询参数中): string
resourceVersionMatch (在查询参数中): string
sendInitialEvents (在查询参数中): boolean
timeoutSeconds (在查询参数中): integer
响应
200 (状态): 成功
401: 未授权
本页面是自动生成的。
如果您打算报告此页面的问题,请在问题描述中说明该页面是自动生成的。修复可能需要在 Kubernetes 项目的其他地方进行。