Document how to quote numbers and booleans for varsub

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
Stefan Prodan 2024-04-06 14:14:55 +03:00
parent 45c50c7894
commit eaaa5113ef
No known key found for this signature in database
GPG Key ID: 3299AEB0E4085BAF
1 changed files with 36 additions and 1 deletions

View File

@ -624,12 +624,15 @@ kind: Kustomization
metadata:
name: apps
spec:
...
postBuild:
substitute:
var_substitution_enabled: "true"
```
**Note:** When using numbers or booleans as values for variables, they must be
enclosed in double quotes vars to be treated as strings, for more information see
[substitution of numbers and booleans](#post-build-substitution-of-numbers-and-booleans).
You can replicate the controller post-build substitutions locally using
[kustomize](https://github.com/kubernetes-sigs/kustomize)
and Drone's [envsubst](https://github.com/drone/envsubst):
@ -1554,6 +1557,38 @@ secretGenerator:
- .dockerconfigjson=ghcr.dockerconfigjson.encrypted
```
### Post build substitution of numbers and booleans
When using [variable substitution](#post-build-variable-substitution) with values
that are numbers or booleans, the reconciliation may fail if the substitution
is for a field that must be of type string. To convert the number or boolean
to a string, you can wrap the variable with a double quotes var:
```yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: app
annotations:
id: ${quote}${id}${quote}
enabled: ${quote}${enabled}${quote}
```
Then in the Flux Kustomization, define the variables as:
```yaml
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: app
spec:
postBuild:
substitute:
quote: '"' # double quote var
id: "123"
enabled: "true"
```
### Triggering a reconcile
To manually tell the kustomize-controller to reconcile a Kustomization outside