Skip to content

Commit aa3e46d

Browse files
committed
Docs: Rationalize and document local-config annotation in the book
Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
1 parent 4b88f62 commit aa3e46d

3 files changed

Lines changed: 71 additions & 0 deletions

File tree

documentation/content/en/book/02-concepts/_index.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,29 @@ kpt pkg get https://github.com/kubernetes/examples/tree/master/_archived/spark
186186

187187
We will go into details of how to work with packages in [Chapter 3](../03-packages).
188188

189+
### Local Configuration
190+
191+
A package can contain resources that are used only during rendering and should not
192+
be applied to the cluster. These are called local configuration resources.
193+
Common examples include function configs (referenced via `configPath`) and helper
194+
resources used as input to pipeline functions.
195+
196+
You mark a resource as local by adding the `config.kubernetes.io/local-config`
197+
annotation:
198+
199+
```yaml
200+
metadata:
201+
annotations:
202+
config.kubernetes.io/local-config: "true"
203+
```
204+
205+
When you deploy the package with `kpt live apply`, local configuration resources
206+
are automatically filtered out. They exist in the package solely to support the
207+
pipeline. See [Chapter 4](../04-using-functions/) for how function configs use
208+
this annotation, and the
209+
[`local-config` annotation reference](/reference/annotations/local-config/) for
210+
full details.
211+
189212
## Workflows
190213

191214
In this section, we'll describe the typical workflows in kpt. We say "typical", because there is no single right way of

documentation/content/en/book/04-using-functions/_index.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,16 @@ apiVersion: v1
301301
kind: ConfigMap
302302
metadata:
303303
name: labels
304+
annotations:
305+
config.kubernetes.io/local-config: "true"
304306
data:
305307
tier: mysql
306308
```
307309

310+
Note the `local-config` annotation: it ensures this resource is not applied to
311+
the cluster when you run `kpt live apply`. See
312+
[Marking function configs as local](#marking-function-configs-as-local) below.
313+
308314
#### `configMap`
309315

310316
Many functions take a `functionConfig` of kind `ConfigMap`, since they only need simple key/value pairs as an argument. For convenience, there is a way to inline the key/value pairs in the `Kptfile`.
@@ -324,6 +330,42 @@ pipeline:
324330
tier: mysql
325331
```
326332

333+
### Marking function configs as local
334+
335+
When you use `configPath` to reference a function config file, that resource is
336+
automatically excluded from the pipeline input (it is not passed to functions as
337+
a regular resource). However, the resource still exists in the package and will
338+
be sent to the cluster when you run `kpt live apply`, unless you mark it as
339+
local configuration.
340+
341+
To prevent a function config from being applied to the cluster, add the
342+
`config.kubernetes.io/local-config` annotation:
343+
344+
```yaml
345+
# wordpress/mysql/labels.yaml
346+
apiVersion: v1
347+
kind: ConfigMap
348+
metadata:
349+
name: labels
350+
annotations:
351+
config.kubernetes.io/local-config: "true"
352+
data:
353+
tier: mysql
354+
```
355+
356+
Resources with this annotation set to any value other than `"false"` are filtered
357+
out during `kpt live apply`. They remain in the package for use by the pipeline
358+
but are never sent to the cluster.
359+
360+
This annotation is useful for:
361+
362+
- Function configs referenced by `configPath`
363+
- Template or helper resources used only during rendering
364+
- Any resource that should exist in the package but not on the cluster
365+
366+
For full details on the annotation schema and behavior, see the
367+
[`local-config` annotation reference](/reference/annotations/local-config/).
368+
327369
### Specifying function `name`
328370

329371
The functions can optionally be named using the `pipeline.mutators.name` field or the `pipeline.validators.name` field to identify a function.

documentation/content/en/book/06-deploying-packages/_index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ Once a package is applied to the cluster, do not change the `ResourceGroup` CR.
129129

130130
Once you have initialized the package, you can deploy it using `kpt live apply`.
131131

132+
Note that not all resources in the package are applied to the cluster. Resources
133+
annotated with `config.kubernetes.io/local-config: "true"` are automatically
134+
filtered out. These are typically function configs or helper resources used only
135+
during rendering. The `Kptfile` itself is also excluded. For more details, see
136+
the [`local-config` annotation reference](/reference/annotations/local-config/).
137+
132138
The `wordpress` package requires a `Secret` containing the mysql password.
133139
Let's create that first:
134140

0 commit comments

Comments
 (0)