llhuii / dive-into-k8s

Apache License 2.0
0 stars 0 forks source link

kubectl apply VS replace #4

Open llhuii opened 3 years ago

llhuii commented 3 years ago
  1. apply 使用patch 方法
  2. replace 使用update方法
  3. replace --force 使用了先delete再create方法

patch有以下策略https://kubernetes.io/zh/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/:

  1. json: json patch
    [
    {
        "op" : "replace" ,
        "path" : "/users/0/email" ,
        "value" : "alice@wonderland.org"
    },
    ]
  2. merge: json merge patch
    {
    "a":"z",
    "c": {
        "f": null
    }
    }
  3. strategic: strategic merge patch

    前两者参考https://erosb.github.io/post/json-patch-vs-merge-patch/

// 待更新

llhuii commented 3 years ago

参考链接https://blog.atomist.com/kubernetes-apply-replace-patch/