|
When trying to configure dynamic Kafka topics based on Kubernetes metadata (kubernetes_logs source) while deploying Vector via the official Helm chart, there is a syntax collision between Helm (Go templates) and Vector's native templating syntax ({{ ... }}).To ReproduceConfiguring the topic field inside values.yaml under customConfig like this:yamltopic: '{{ kubernetes.node.labels.kubcluster_name }}-{{ kubernetes.namespace }}' |
Replies: 1 comment 1 reply
|
There are two separate issues here:
Escape the complete Vector expression through Helm's customConfig:
sinks:
kafka:
# ...the rest of the Kafka sink config...
topic: |-
{{ print "{{ .kubernetes.node_labels.kubcluster_name }}-{{ .kubernetes.pod_namespace }}" }}Then render the chart before deploying: helm template my-vector vector/vector -f values.yaml > rendered.yamlThe generated ConfigMap should still contain the Vector template, not a Helm expression: topic: |-
{{ .kubernetes.node_labels.kubcluster_name }}-{{ .kubernetes.pod_namespace }}The leading dots are intentional: the contents of a Vector template are VRL path expressions. If the Kubernetes label itself contains dots or {{ print "{{ .kubernetes.node_labels.\"label.example.com/name\" }}-{{ .kubernetes.pod_namespace }}" }}This assumes the One last operational detail: when a field used by a topic template is absent, Vector logs a template error and drops that event ( References: chart escaping example · Vector template syntax · |
There are two separate issues here:
customConfigthrough Helm'stpl, so Helm tries to evaluate Vector's{{ ... }}expression first..kubernetes.node_labelsand.kubernetes.pod_namespace.Escape the complete Vector expression through Helm's
printfunction, while leaving the inner braces for Vector:Then render the chart before deploying: