1. ---
    2. apiVersion: apps/v1 #版本
    3. kind: Deployment #类型
    4. metadata: #元数据
    5. annotations: {} #注释
    6. labels: #标签
    7. k8s.kuboard.cn/layer: web
    8. k8s.kuboard.cn/name: nginx
    9. name: nginx #名称,nginx
    10. namespace: learn #所在的名称空间
    11. resourceVersion: '46722922'
    12. spec:
    13. progressDeadlineSeconds: 600 #deploy 升级过程的最大时间,如果升级过程被暂停了,该时间也会同步暂停,时间不会一直增长
    14. replicas: 3 #副本数量,
    15. revisionHistoryLimit: 10 #deploy 升级最大记录数,10
    16. selector: #选择器
    17. matchLabels:
    18. k8s.kuboard.cn/layer: web
    19. k8s.kuboard.cn/name: nginx
    20. strategy: #策略
    21. rollingUpdate: #滚动更新
    22. maxSurge: 25% #滚动更新时最大启动pod数为副本数量*25%
    23. maxUnavailable: 25% #滚动升级时允许最大的不可用pod数
    24. type: RollingUpdate #类型,滚动更新
    25. template:
    26. metadata:
    27. creationTimestamp: null #创建时间戳
    28. labels:
    29. k8s.kuboard.cn/layer: web
    30. k8s.kuboard.cn/name: nginx
    31. spec:
    32. containers: #容器列表
    33. - image: 'nginx:1.20.2-alpine' #镜像版本
    34. imagePullPolicy: IfNotPresent #定义镜像拉取策略,有Always、Never、IfNotPresent三个值。
    35. name: nginx
    36. ports:
    37. - containerPort: 80 #对service暴露端口 80
    38. protocol: TCP
    39. resources: {}
    40. terminationMessagePath: /dev/termination-log #表示容器异常终止的消息路径
    41. terminationMessagePolicy: File
    42. dnsPolicy: ClusterFirst
    43. imagePullSecrets:
    44. - name: local-registry
    45. restartPolicy: Always #定义重启策略,总是重启
    46. schedulerName: default-scheduler
    47. securityContext: {}
    48. terminationGracePeriodSeconds: 30 #可以定义优雅关闭的宽限期,即在收到停止请求后,有多少时间来进行资源释放或者做其他操作,如果到了最大时间还没有停止,会被强制结束。默认值:30
    49. status:
    50. availableReplicas: 3
    51. conditions:
    52. - lastTransitionTime: '2022-03-24T08:47:50Z'
    53. lastUpdateTime: '2022-03-24T08:47:50Z'
    54. message: Deployment has minimum availability.
    55. reason: MinimumReplicasAvailable
    56. status: 'True'
    57. type: Available
    58. - lastTransitionTime: '2022-03-24T05:57:56Z'
    59. lastUpdateTime: '2022-03-24T09:04:50Z'
    60. message: ReplicaSet "nginx-c5b885d45" has successfully progressed.
    61. reason: NewReplicaSetAvailable
    62. status: 'True'
    63. type: Progressing
    64. observedGeneration: 13
    65. readyReplicas: 3
    66. replicas: 3
    67. updatedReplicas: 3