1.replace是全局更新,对deployment的yaml文件进行整体更新的功能:

2.patch是局部更新,增删改某一个属性,deployment回滚功能:

将想回滚的replicaset的spec.template 拷贝到 deployment的/spec/template :

template:
    metadata:
      creationTimestamp: null
      labels:
        app: web
        pod-template-hash: 855f84555f
    spec:
      containers:
      - image: nginx:1.9.1
        imagePullPolicy: Always
        name: nginx
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30

并修改deployment的/metadata/annotations中deployment.kubernetes.io/revision属性的值为需要回滚replicaset对应的revision号。

底层就是这样实现!

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐