UNCLASSIFIED - NO CUI

Skip to content

Rendering configmap.yaml template causes error with custom Elasticsearch settings

Bug

Chart version 0.39.0-bb.5 starting throwing a can't evaluate field tls in type interface {} with a custom elasticsearch configuration.

Description

This error started occuring when rendering the fluentbit chart on an AKS cluster with a custom Elasticsearch configuration.

kubectl -n bigbang get hr fluentbit
NAME        AGE   READY   STATUS
fluentbit   9h    False   Helm install failed for release fluentbit/fluentbit with chart fluentbit@0.42.0-bb.0: template: fluentbit/templates/daemonset.yaml:37:28: executing "fluentbit/templates/daemonset.yaml" at <include (print $.Template.BasePath "/configmap.yaml") .>: error calling include: template: fluentbit/templates/configmap.yaml:34:18: executing "fluentbit/templates/configmap.yaml" at <.tls>: can't evaluate field tls in type interface {}

The error started occurring in the Fluent Bit 0.39.0-bb.5 chart when the match range function was added to the chart.

Steps to reproduce:

  1. Create a values-custom.yaml containing:
additionalOutputs:
  disableDefault: false
  elasticsearch:
    host: logging-ek-es-http.logging.svc.cluster.local
    user: fluentbit
    password: A_Password_Goes_Here
    port: 9200
    tls: true
    tlsVerify: true
    caCert: |-
      -----BEGIN CERTIFICATE-----
      Cert stuff goes here
      -----END CERTIFICATE-----
elasticsearchKibana:
  enabled: true
loki:
  enabled: false
  1. Check out tag 0.39.0-bb.5
  2. Run command helm template ./chart -f values-custom.yaml
  3. Get message:
Error: template: fluentbit/templates/daemonset.yaml:37:28: executing "fluentbit/templates/daemonset.yaml" at <include (print $.Template.BasePath "/configmap.yaml") .>: error calling include: template: fluentbit/templates/configmap.yaml:34:18: executing "fluentbit/templates/configmap.yaml" at <.tls>: can't evaluate field tls in type interface {}
  1. Check out tag 0.39.0-bb.4
  2. Run command helm template ./chart -f values-custom.yaml
  3. Chart renders correctly.

It appears that the scope of the .tls* variables are lost due to the {{- range $match := .match}} that was added. This patch seems to correct the issue, but I believe that each output would need a similar patch.

diff --git a/chart/templates/configmap.yaml b/chart/templates/configmap.yaml
index c600771..eaa9ec2 100644
--- a/chart/templates/configmap.yaml
+++ b/chart/templates/configmap.yaml
@@ -17,6 +17,7 @@ data:

     {{- with .Values.additionalOutputs.elasticsearch }}
     {{- if and .host .user .password .port }}
+    {{- $es := . }}
     {{- $additionalConfig := .additionalConfig }}
     {{- range $match := .match}}
     [OUTPUT]
@@ -31,9 +32,9 @@ data:
         Retry_Limit False
         Replace_Dots On
         storage.total_limit_size {{ $.Values.storage.total_limit_size }}
-        tls {{ if .tls }}On{{ else }}Off{{ end }}
-        tls.verify {{ if and .tlsVerify .caCert }}On{{ else }}Off{{ end }}
-        {{- if and .tlsVerify .caCert }}
+        tls {{ if $es.tls }}On{{ else }}Off{{ end }}
+        tls.verify {{ if and $es.tlsVerify $es.caCert }}On{{ else }}Off{{ end }}
+        {{- if and $es.tlsVerify $es.caCert }}
         tls.ca_file /etc/external-es/certs/ca.crt
         {{- end }}
         {{- if $additionalConfig }}

BigBang Version

2.19.0