kubernetesvariablesfluxkustomizegitops

Leave a Variable in a string using Kustomize


I am having a tricky issue. Working with kibana, I have a UI element, that, within said field for path is the literal value: /var/log/containers/*${kubernetes.container.id}.log

this is the end result that I want to paste into the field. IE in pseudo code: endresult='/var/log/containers/*${kubernetes.container.id}.log'

echo $endresult

Now, when defining this in my kibana yaml for "eck-operator-kibana", I pulled an example yaml generated from the UI, and it shows it's as simple as

paths:
  - '/var/log/containers/*${kubernetes.container.id}.log'

However, when adding this to my kibana.yaml, that errors out and says "YAMLToJSON: variable substitution failed"

I have tried to ensure it doesn't read it as a variable in these ways which all failed:

paths:
  - "'/var/log/containers/*${kubernetes.container.id}.log'" #double quotes around single
paths:
  - "/var/log/containers/*${kubernetes.container.id}.log" #double quotes
paths:
  - '/var/log/containers/*\\${kubernetes.container.id}.log' # using \\ to not pay attention to the $
paths:
  - '/var/log/containers/*"${kubernetes.container.id}".log' #double quotes around the variable
#at this point im losing my mind and questioning my sanity

so, how do I make it so that the end result populated in the field is simply /var/log/containers/*${kubernetes.container.id}.log

using flux with kustomizations, and under kustomizations in k9s, it fails with that error. What gives? any insight is appreciated!


Solution

  • Just an update to this, someone mentioned in a different forum to use

    paths:
      - >
      '/var/log/containers/*${kubernetes.container.id}.log'
    

    When that didnt work, it confirmed there was an external "force" acting upon it, which was a shell lint attempting to fill vars as well. That worked was two $ signs as such:

    paths:
      - '/var/log/containers/*$${kubernetes.container.id}.log'