k8s creationTimestamp 参数

sed -i "s/Timestamp/`date +%s`/g" nginx-app.yaml'

每次更新的时候修改Timestamp 标签参数,那么每次发布都会都是自动更新删除老的pod

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: nginx-app
  name: nginx-app
spec:
  replicas: 1
  minReadySeconds: 15     #滚动升级15s后标志pod准备就绪
  strategy:
    rollingUpdate:        #replicas为2, 升级过程中pod个数在1-3个之间
      maxSurge: 1         #滚动升级时会先启动1个pod
      maxUnavailable: 1   #滚动升级时允许pod处于Unavailable的最大个数
  selector:
    matchLabels:
      app: nginx-app
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: nginx-app
        timestamp: "Timestamp"
    spec:
      containers:
      - image: nginx:1.11.9
        name: nginx
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-app
  labels:
    app: nginx-app
spec:
  ports:
  - name: nginx-app
    port: 80
    targetPort: 80
  selector:
    app: nginx-app

  

posted @ 2022-03-17 17:00  执酒  阅读(1325)  评论(0编辑  收藏  举报