|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

 

 

posted on   yanqi_vip  阅读(41)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 上周热点回顾(2.17-2.23)
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

导航

统计

点击右上角即可分享
微信分享提示