github.com/oam-dev/kubevela@v1.9.11/references/docgen/def-doc/policy/resource-update.eg.md (about)

     1  `resource-update` policy can allow users to customize the update behavior for selected resources.
     2  
     3  
     4  ```yaml
     5  apiVersion: core.oam.dev/v1beta1
     6  kind: Application
     7  metadata:
     8    name: recreate
     9  spec:
    10    components:
    11      - type: k8s-objects
    12        name: recreate
    13        properties:
    14          objects:
    15            - apiVersion: v1
    16              kind: Secret
    17              metadata:
    18                name: recreate
    19              data:
    20                key: dgo=
    21              immutable: true
    22    policies:
    23      - type: resource-update
    24        name: resource-update
    25        properties:
    26          rules:
    27            - selector:
    28                resourceTypes: ["Secret"]
    29              strategy:
    30                recreateFields: ["data.key"]
    31  ```
    32  By specifying `recreateFields`, the application will recreate the target resource (**Secret** here) when the field changes (`data.key` here). If the field is not changed, the application will use the normal update (**patch** here).
    33  
    34  ```yaml
    35  apiVersion: core.oam.dev/v1beta1
    36  kind: Application
    37  metadata:
    38    name: recreate
    39  spec:
    40    components:
    41      - type: k8s-objects
    42        name: recreate
    43        properties:
    44          objects:
    45            - apiVersion: v1
    46              kind: ConfigMap
    47              metadata:
    48                name: recreate
    49              data:
    50                key: val
    51    policies:
    52      - type: resource-update
    53        name: resource-update
    54        properties:
    55          rules:
    56            - selector:
    57                resourceTypes: ["ConfigMap"]
    58              strategy:
    59                op: replace
    60  ```
    61  By specifying `op` to `replace`, the application will update the given resource (ConfigMap here) by replace. Compared to **patch**, which leverages three-way merge patch to only modify the fields managed by KubeVela application, "replace" will update the object as a whole and wipe out other fields even if it is not managed by the KubeVela application. It can be seen as an "application-level" *ApplyResourceByReplace*.