Description
Is your feature request related to a problem? Please describe.
I feel difficult to Overlay when structured data is in k8s YAML's value. (ex. Structured data(yaml or json) format value in configMap data And structured data(almost json) format value in annotations(this way is used in many projects, I think)).
Therefore I propose to add options for replacing the value in structured data to replacements function.
I think this function can be an alternative vars function on almost use cases.
Example (json format value in configMap data)
apiVersion: v1
kind: ConfigMap
metadata:
name: jsoned-configmap
data:
config.json: |-
{"config": {
"id": "42",
"hostname": "REPLACE_TARGET"
}}
Example (json format value in annotations)
- https://cloud.google.com/kubernetes-engine/docs/how-to/ingress-features#unique_backendconfig_per_service_port
- https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.2/guide/ingress/annotations/#listen-ports
Describe the solution you'd like
FIrst, set format
and formatPath
parameters to replacements option.
And interpretation in k8s YAML value using formatPath
with format
.
Finally, execute replacements which place set by formatPath
.
(Please watch Proposal config
on the "Additional context" section.)
Describe alternatives you've considered
I tried to use delimiter: '"'
options on replacement to parse json.
I think I will be able to resolve my problem with this solution, but It is very hard.
Additional context
Proposal config
source
apiVersion: v1
kind: ConfigMap
metadata:
name: source-configmap
data:
HOSTNAME: www.example.com
---
apiVersion: v1
kind: ConfigMap
metadata:
name: target-configmap
data:
config.json: |-
{"config": {
"id": "42",
"hostname": "REPLACE_TARGET_HOSTNAME"
}}
replacement
replacements:
- source:
kind: ConfigMap
name: source-configmap
fieldPath: data.HOSTNAME
targets:
- select:
kind: ConfigMap
name: target-configmap
fieldPaths:
- data.config\.json
options:
format: 'json'
formatPath: '/config/hostname'
expected
apiVersion: v1
kind: ConfigMap
metadata:
name: source-configmap
data:
HOSTNAME: www.example.com
---
apiVersion: v1
kind: ConfigMap
metadata:
name: target-configmap
data:
config.json: '{"config":{"hostname":"www.example.com","id":"42"}}'
Metadata
Metadata
Assignees
Labels
Type
Projects
Status