|NO.Z.00138|——————————|CloudNative|——|KuberNetes&资源调度.V08|——|deployment.v06|更新注意事项|
一、Deployment注意事项
### --- 查看deployment.yaml配置文件
[root@k8s-master01 ~]# kubectl get deploy nginx -oyaml
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "12"
kubernetes.io/change-cause: kubectl set image deploy nginx nginx=nginx:1.15.3
--record=true
creationTimestamp: "2021-04-18T05:20:10Z"
generation: 21
labels:
app: nginx
managedFields:
- apiVersion: apps/v1
fieldsType: FieldsV1
fieldsV1:
name: nginx
namespace: default
resourceVersion: "920360"
uid: 201bba44-1244-4f12-8920-59f3bba18e79
spec:
progressDeadlineSeconds: 600
replicas: 2
revisionHistoryLimit: 10 //它会给我们保留多个历史的副本。设置保留RS旧的revision的个数,设置为0的话,不保留历史数据。
selector:
matchLabels:
app: nginx
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: nginx
spec:
containers:
- image: nginx:1.15.3
imagePullPolicy: IfNotPresent
name: nginx
resources:
limits:
cpu: 200m
memory: 128Mi
requests:
cpu: 10m
memory: 16Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
status:
availableReplicas: 2
conditions:
- lastTransitionTime: "2021-04-18T10:16:07Z"
lastUpdateTime: "2021-04-18T10:16:07Z"
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: "True"
type: Available
- lastTransitionTime: "2021-04-18T10:34:21Z"
lastUpdateTime: "2021-04-18T10:34:53Z"
message: ReplicaSet "nginx-68db656dd8" has successfully progressed.
reason: NewReplicaSetAvailable
status: "True"
type: Progressing
observedGeneration: 21
readyReplicas: 2
replicas: 2
updatedReplicas: 2
二、deployment注意事项
### --- deployment注意事项
~~~ # .spec.revisionHistoryLimit:
~~~ 设置保留RS旧的revision的个数,设置为0的话,不保留历史数据
~~~ # .spec.minReadySeconds:
~~~ 可选参数,指定新创建的Pod在没有任何容器崩溃的情况下视为Ready最小的秒数,
~~~ 默认为0,即一旦被创建就视为可用。
### --- 滚动更新的策略:
~~~ # .spec.strategy.type:
~~~ 更新deployment的方式,默认是RollingUpdate
~~~ # RollingUpdate:
~~~ 滚动更新,可以指定maxSurge和maxUnavailable
~~~ # maxUnavailable:
~~~ 指定在回滚或更新时最大不可用的Pod的数量,可选字段,默认25%,
~~~ 可以设置成数字或百分比,如果该值为0,那么maxSurge就不能0
~~~ # maxSurge:
~~~ 可以超过期望值的最大Pod数,可选字段,默认为25%,
~~~ 可以设置成数字或百分比,如果该值为0,那么maxUnavailable不能为0
~~~ # Recreate:
~~~ 重建,先删除旧的Pod,在创建新的Pod
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
——W.S.Landor
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 上周热点回顾(2.17-2.23)