Kubernetes Strategic Merge Patch: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 14: Line 14:


A strategic merge patch is a customized version of [[JSON Patch|JSON patch]] and it looks like an incomplete YAML specification of a k8s resource.
A strategic merge patch is a customized version of [[JSON Patch|JSON patch]] and it looks like an incomplete YAML specification of a k8s resource.
The SMP includes <tt>TypeMeta<tt> fields to establish the group/version/kind/name of the resource to patch, then just enough remaining fields to step into a nested structure to specify a new field value, e.g. an image tag. By default, an SMP replaces values. This is usually the desired behavior when the target value is a simple string, but may not be desired when the target value is a list. To change this default behavior, add a directive. Recognized directives in YAML patches are:
* replace (the default)
* delete

Revision as of 18:29, 23 August 2019

External

Internal

Overview

A strategic merge patch is a customized version of JSON patch and it looks like an incomplete YAML specification of a k8s resource.

The SMP includes TypeMeta fields to establish the group/version/kind/name of the resource to patch, then just enough remaining fields to step into a nested structure to specify a new field value, e.g. an image tag. By default, an SMP replaces values. This is usually the desired behavior when the target value is a simple string, but may not be desired when the target value is a list. To change this default behavior, add a directive. Recognized directives in YAML patches are:

  • replace (the default)
  • delete