The NATS Helm chart allows you to override NATS configurations and Kubernetes resources using two mechanisms: merge and patch. This prevents you from having to redefine the entire configuration block when you only want to add or change specific fields.
Merge
Merging uses the Helm merge function. It is used to inject new keys or values into existing configuration blocks. For example, you can use merge to add NATS accounts or update natsBox contexts.
Patch
Patching uses JSON Patch. This is useful for precise operations like adding an item to the end of an array (e.g., adding a new route to a cluster) without overwriting the entire list.
# Example: Using merge to add accounts
config:
merge:
accounts:
A:
users:
- {user: a, password: a}
# Example: Using patch to add a route to the end of a list
config:
cluster:
enabled: true
patch:
- op: add
path: /routes/-
value: nats://demo.nats.io:6222