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:
- 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.
- op indicates a series of operations performed on resource objects. These operations are mainly as follows:
- 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.
- 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.
Last Article: Appendix
Next Article: Patch Request Examples
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.