KIND: Deployment
VERSION: apps/v1
DESCRIPTION:
Deployment enables declarative updates for Pods and ReplicaSets.
FIELDS:
apiVersion <string> 该资源使用的api版本
kind <string> 创建的资源是什么
metadata <Object> 元数据,包括资源的名字和名称空间
spec <Object> 定义容器的
status <Object> 状态,不可以修改
kubectl explain deployment.spec
KIND: Deployment
VERSION: apps/v1
RESOURCE: spec <Object>
DESCRIPTION:
Specification of the desired behavior of the Deployment.
DeploymentSpec is the specification of the desired behavior of the Deployment.
FIELDS:
minReadySeconds <integer> #kubernetes在等待设置的时间后才进行升级,如果没有设置该值,kubernetes会假设该容器启动起来后就提供服务了
paused <boolean> 暂停,当我们更新的时候创建pod先暂停,不是立即更新
progressDeadlineSeconds <integer> # k8s在升级过程中有可能由于各种原因升级卡住(这个时候还没有明确的升级失败),比如在拉取被墙的镜像,权限不够等错误。那么这个时候就需要有个deadline,在deadline之内如果还卡着,那么就上报这个情况,这个时候这个Deployment状态就被标记为False,并且注明原因。但是它并不会阻止Deployment继续进行卡住后面的操作。完全由用户进行控制
replicas <integer> 副本数
revisionHistoryLimit <integer> 保留的历史版本,默认是10
selector <Object> -required- 标签选择器,选择它关联的pod
strategy <Object> 更新策略
template <Object> -required- 定义的pod模板
kubectl explain deploy.spec.strategy
KIND: Deployment
VERSION: apps/v1
RESOURCE: strategy <Object>
DESCRIPTION:
The deployment strategy to use to replace existing pods with new ones.
DeploymentStrategy describes how to replace existing pods with new ones.
FIELDS:
rollingUpdate <Object>
Rolling update config params. Present only if DeploymentStrategyType =RollingUpdate.
type <string>
Type of deployment. Can be "Recreate" or "RollingUpdate". Default is RollingUpdate.
# 支持两种更新,Recreate和RollingUpdate
# Recreate是重建式更新,删除一个更新一个
KIND: Deployment
VERSION: apps/v1
RESOURCE: rollingUpdate <Object>
DESCRIPTION:
Rolling update config params. Present only if DeploymentStrategyType =
RollingUpdate.
Spec to control the desired behavior of rolling update.
FIELDS:
maxSurge <string> 我们更新过程中最多允许超过的指定的目标副本数有几个,他有两种取值方式,第一种直接给定数量,第二种根据百分比,百分比表示远不是5个,最多可以超过20%,那就允许多一个,最多可以超过40%,那就允许多两个
maxUnavailable <string> 最多允许几个不可用,假设有5个副本,最多一个不可用,就表示最多有4个可用
KIND: Deployment
VERSION: apps/v1
RESOURCE: template <Object>
DESCRIPTION:
Template describes the pods that will be created.
PodTemplateSpec describes the data a pod should have when created from a
template
FIELDS:
metadata <Object> 定义模板的名字
spec <Object> deployment.spec.template为pod定义的模板,和pod定义不太一样,template中不包含apiVersion和Kind属性,要求必须有metadata。 deployment.spec.template.spec 为容器属性信息,其他定义内容和pod一直。