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!
According to the source code, statsd-exporter uses kingpin for command line and flag parser. If I am not mistaken, kingpin doesn't require values to be surrounded by double quotes.
I would suggest to try:
- name: statsd-exporter
image: prom/statsd-exporter:v0.12.2
...
command: ["/bin/statsd_exporter"]
args:
- --log.level=debug
- --statsd.listen-tcp=:9999
Reason being is that according to the source code here, the input value for statsd.listen-tcp
is split into host and port and it seems the the host per the error message gets the value of a double quote character "
.