部署
apiVersion: apps/v1
import "k8s.io/api/apps/v1"
部署
Deployment 实现了 Pods 和 ReplicaSets 的声明式更新。
apiVersion: apps/v1
kind: Deployment
metadata (ObjectMeta)
标准对象的元数据。更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
spec (DeploymentSpec)
部署期望行为的规范。
status (DeploymentStatus)
最近观察到的部署状态。
DeploymentSpec
DeploymentSpec 是 Deployment 期望行为的规范。
selector (LabelSelector),必需
Pod 的标签选择器。其 Pod 被此部署选择的现有 ReplicaSet 将受到此部署的影响。它必须与 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 (字符串)
部署类型。可以是“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 的总数不超过所需 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)
部署在被视为失败之前取得进展的最大时间(以秒为单位)。部署控制器将继续处理失败的部署,并在部署状态中显示带有 ProgressDeadlineExceeded 原因的条件。请注意,在部署暂停期间不会估计进度。默认为 600 秒。
paused (布尔值)
指示部署已暂停。
DeploymentStatus
DeploymentStatus 是最近观察到的部署状态。
replicas (int32)
此部署目标(其标签与选择器匹配)的非终止 Pod 的总数。
availableReplicas (int32)
此部署目标(至少 minReadySeconds 准备就绪)的可用非终止 Pod 的总数。
readyReplicas (int32)
此部署目标且处于 Ready 状态的非终止 Pod 的总数。
unavailableReplicas (int32)
此部署目标中不可用 Pod 的总数。这是部署实现 100% 可用容量仍所需的 Pod 总数。它们可能是正在运行但尚未可用的 Pod,也可能是尚未创建的 Pod。
updatedReplicas (int32)
此部署目标且具有所需模板规范的非终止 Pod 的总数。
terminatingReplicas (int32)
此部署目标中正在终止的 Pod 的总数。终止中的 Pod 具有非空 .metadata.deletionTimestamp 并且尚未达到 Failed 或 Succeeded .status.phase。
这是一个 Alpha 字段。启用 DeploymentReplicaSetTerminatingReplicas 才能使用此字段。
collisionCount (int32)
部署的哈希冲突计数。部署控制器在需要为最新 ReplicaSet 创建名称时,使用此字段作为避免冲突的机制。
conditions ([]DeploymentCondition)
补丁策略:按键
type
合并映射:合并时将保留键类型上的唯一值
表示部署当前状态的最新可用观察结果。
DeploymentCondition 描述了部署在某个时间点的状态。
conditions.status (string),必需
条件的 status,可以是 True、False、Unknown 之一。
conditions.type (string),必需
部署条件的类型。
conditions.lastTransitionTime (Time)
条件上次从一种状态转换到另一种状态的时间。
Time 是 time.Time 的一个包装器,支持正确地编组到 YAML 和 JSON。提供了 time 包提供的许多工厂方法的包装器。
conditions.lastUpdateTime (Time)
此条件上次更新的时间。
Time 是 time.Time 的一个包装器,支持正确地编组到 YAML 和 JSON。提供了 time 包提供的许多工厂方法的包装器。
conditions.message (string)
一个人类可读的消息,指示有关转换的详细信息。
conditions.reason (string)
条件上次转换的原因。
observedGeneration (int64)
部署控制器观察到的代数。
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}
参数
响应
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: Patch,必需
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: Patch,必需
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: DeleteOptions
dryRun (在查询中): string
gracePeriodSeconds (在查询中): integer
ignoreStoreReadErrorWithClusterBreakingPotential (在查询中): boolean
pretty (在查询中): string
propagationPolicy (在查询中): string
响应
200 (Status): OK
202 (Status): 已接受
401: 未授权
deletecollection
删除 Deployment 集合
HTTP 请求
DELETE /apis/apps/v1/namespaces/{namespace}/deployments
参数
namespace (在路径中): string,必填
body: DeleteOptions
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 (Status): OK
401: 未授权
本页面是自动生成的。
如果你打算报告此页面存在的问题,请在问题描述中提及此页面是自动生成的。修复可能需要在 Kubernetes 项目的其他地方进行。