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