Skip to content

Commit aefe715

Browse files
authored
Docs: Rationalize and document local-config annotation in the book (#4679)
Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
1 parent 9f0ac2b commit aefe715

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]({{% relref "/book/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]({{% relref "/book/04-using-functions" %}}) for how function configs use
208+
this annotation, and the
209+
[`local-config` annotation reference]({{% relref "/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
@@ -305,10 +305,16 @@ apiVersion: v1
305305
kind: ConfigMap
306306
metadata:
307307
name: labels
308+
annotations:
309+
config.kubernetes.io/local-config: "true"
308310
data:
309311
tier: mysql
310312
```
311313

314+
Note the `local-config` annotation: it ensures this resource is not applied to
315+
the cluster when you run `kpt live apply`. See
316+
[Marking function configs as local](#marking-function-configs-as-local) below.
317+
312318
#### `configMap`
313319

314320
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`.
@@ -368,6 +374,42 @@ The `configRef` fields are as follows:
368374

369375
The reference must match exactly one resource in the package. An error is raised if zero or multiple resources match.
370376

377+
### Marking function configs as local
378+
379+
When you use `configPath` to reference a function config file, that resource is
380+
automatically excluded from the pipeline input (it is not passed to functions as
381+
a regular resource). However, the resource still exists in the package and will
382+
be sent to the cluster when you run `kpt live apply`, unless you mark it as
383+
local configuration.
384+
385+
To prevent a function config from being applied to the cluster, add the
386+
`config.kubernetes.io/local-config` annotation:
387+
388+
```yaml
389+
# wordpress/mysql/labels.yaml
390+
apiVersion: v1
391+
kind: ConfigMap
392+
metadata:
393+
name: labels
394+
annotations:
395+
config.kubernetes.io/local-config: "true"
396+
data:
397+
tier: mysql
398+
```
399+
400+
Resources with this annotation set to any value other than `"false"` are filtered
401+
out during `kpt live apply`. They remain in the package for use by the pipeline
402+
but are never sent to the cluster.
403+
404+
This annotation is useful for:
405+
406+
- Function configs referenced by `configPath`
407+
- Template or helper resources used only during rendering
408+
- Any resource that should exist in the package but not on the cluster
409+
410+
For full details on the annotation schema and behavior, see the
411+
[`local-config` annotation reference]({{% relref "/reference/annotations/local-config" %}}).
412+
371413
### Specifying function `name`
372414

373415
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]({{% relref "/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)