Help Center> Cloud Container Engine> API Reference> Appendix> Patch Request Method Operation Description

Patch Request Method Operation Description

Kubernetes APIs use the HTTP header "Content-Type" to distinguish between patch operations.

Operation

Currently, three types of patch request method operations are supported:

  1. JSON Patch, Content-Type: application/json-patch+json

    According to RFC 6902, JSON patch operations indicate a series of operations performed on resource objects. The following provides an example of the JSON patch operation:

    {
        "op": "add",
        "path": "/spec/containers/0/image",
        "value": "busybox:latest"
    }

    In this example:

    • op indicates a series of operations performed on resource objects. These operations are mainly as follows:
      • add
      • replace
      • remove (not supported)
      • move (not supported)
      • copy (not supported)
      • test (not supported)
    • path indicates the path to the to-be-operated resource object.

      For example, /spec/containers/0/image indicates that the object to be operated is spec.containers[0].image.

    • value indicates the to-be-modified value.
  2. Merge Patch, Content-Type: application/merge-patch+json

    According to RFC 7386, merge patch contains some description of a resource object (namely, JSON object). The JSON object is submitted to the server end, and merges with the current object of the server end (namely, replaces the list field of the current resource object) to form a new object.

  3. Strategic Merge Patch, Content-Type: application/strategic-merge-patch+json

    Strategic Merge Patch is used to add legal metadata to API objects, and uses new metadata to determine which lists should be merged and which ones should not. The current metadata is used as the structure labels.

For more information about the difference between Merge Patch and Strategic Merge Patch, see Patch Request Examples.