vectordotdev / helm-charts

Helm charts for Vector.
https://vector.dev
Mozilla Public License 2.0
113 stars 90 forks source link

Helm template error with nested label values in customConfig #416

Closed gabe-sorensen closed 2 months ago

gabe-sorensen commented 2 months ago

I am using the vector helm chart with the values file shown below, which works as expected.

role: "Agent"
customConfig:
  data_dir: /vector-data-dir
  api:
    enabled: false
  sources:
    kubernetes_logs:
      type: kubernetes_logs
  sinks:
    loki:
      type: loki
      inputs: [kubernetes_logs]
      encoding:
        codec: json
      endpoint: http://loki-gateway
      labels:
        forwarder: "vector"
        cluster: "development"
        stream: "{{ .stream }}"
        source_type: "{{ .source_type }}"
        #k8s_pod_namespace: "{{ .kubernetes.pod_namespace }}"

However, when I un-comment k8s_pod_namespace: "{{ .kubernetes.pod_namespace }}" right below source_type: "{{ .source_type }}" I get the following error during a helm install:

Error: template: vector/templates/daemonset.yaml:30:28: executing "vector/templates/daemonset.yaml" at <include (print $.Template.BasePath "/configmap.yaml") .>: error calling include: template: vector/templates/configmap.yaml:11:3: executing "vector/templates/configmap.yaml" at <tpl (toYaml .Values.customConfig) .>: error calling tpl: error during tpl function execution for "api:\n enabled: false\ndata_dir: /vector-data-dir\nsinks:\n loki:\n encoding:\n codec: json\n endpoint: http://loki-gateway\n inputs:\n - kubernetes_logs\n labels:\n cluster: development\n forwarder: vector\n k8s_pod_namespace: '{{ .kubernetes.pod_namespace }}'\n source_type: '{{ .source_type }}'\n stream: '{{ .stream }}'\n type: loki\nsources:\n kubernetes_logs:\n type: kubernetes_logs": template: vector/templates/daemonset.yaml:14:40: executing "vector/templates/daemonset.yaml" at <.kubernetes.pod_namespace>: nil pointer evaluating interface {}.pod_namespace

I'm not sure why .source_type is working to extract the label, but .kubernetes.pod_namespace is complaining. Thanks!