2

Kustomize supports two ways to modify live kubernetes manifests:

Patches (also called overlays) add or override fields on resources. They are provided using the patches Kustomization field.

Replacements are used to copy fields from one source into any number of specified targets.

They seemingly serve the same purpose.

What are the differences between them? In which situations one is recommended over the other?

thiagowfx
  • 145
  • 1
  • 6

1 Answers1

6

They do two completely different and distinct things.

"Replacements" are used to "copy fields from one source into any number of specified targets". You can't do that with a patch (a patch cannot copy data from an existing resource).

A patch is used to apply arbitrary transformations to a YAML document. You can use patches to do things like add, replace, or delete attributes in your resources. You can merge new entries into a list. You can't do that with replacements.

larsks
  • 823
  • 5
  • 8