I am trying to deploy the statsd exporter (https://github.com/prometheus/statsd_exporter) software as a docker container in a K8s cluster. However, I want some parameters to be configurable. In order to do that, I am passing some arguments to the container via K8s deployment in a yaml format. When these arguments do not contain the double quotes character ("), everything works fine. However, if the desired value of the introduced variables contains double quotes, K8s interprets them in a wrong way (something similar is described in Pass json string to environment variable in a k8s deployment for Envoy). What I want to set is the --statsd.listen-tcp=":<port>"
argument, and I am using command
and args
in K8s deployment:
- name: statsd-exporter
image: prom/statsd-exporter:v0.12.2
...
command: ["/bin/statsd_exporter"]
args: ['--log.level="debug"', '--statsd.listen-tcp=":9999"']
When I deploy it in K8s and check the content of the "running" deployment, everything seems to be right:
command:
- /bin/statsd_exporter
args:
- --log.level="debug"
- --statsd.listen-tcp=":9999"
However, the container never starts, giving the following error:
time="..." level=fatal msg="Unable to resolve \": lookup \": no such host" source="main.go:64"
I think that K8s is trying to "scape" the double quotes and it is passing them adding the backslash to the container, so the latter cannot understand them. I have also tried to write the args
as
args: ["--log.level=\"debug\"", "--statsd.listen-tcp=\":9999\""]
and the same happens. I have also tried to pass them as env variables, and all the times the same problem is happening: the double quotes are not parsed in the right way.
Any idea regarding some possible solution?
Thanks!
"
is passed as a string\"
(escaped"
) and application tries to resolve this string as a hostname. "When these arguments do not contain the double quotes character ("), everything works fine." Is there any particular reason you need to use double quotes ? Did you try using--statsd.listen-tcp=
flag by providing full hostname with port without using any quotes ? – Arita