mrlhansen / idrac_exporter

Simple Redfish (iDRAC, iLO, XClarity) exporter for Prometheus
MIT License
131 stars 40 forks source link

Add support for passing environment to container #67

Closed Jonher937 closed 6 months ago

Jonher937 commented 6 months ago

https://github.com/mrlhansen/idrac_exporter/pull/30 added code without adding support to be compatible with the chart.

# Starting with IDRAC_USERNAME and IDRAC_PASSWORD defined:
➜  ~ docker run -it --rm -e IDRAC_USERNAME=test -e IDRAC_PASSWORD=test2 docker.io/library/idrac_exporter
2024-04-25T14:31:07.342 INFO  Build information: version=unknown revision=cc4a45ac19bf09cc21bf8f6f5e0dd86559458ba6
2024-04-25T14:31:07.342 INFO  Server listening on 0.0.0.0:9348

# Starting without env-vars defined just like today:
➜  ~ docker run -it --rm docker.io/library/idrac_exporter
/etc/prometheus/idrac.yml not found _and_ /authconfig/ not found.
2024-04-25T14:31:15.275 FATAL Error opening configuration file /etc/prometheus/idrac.yml: open /etc/prometheus/idrac.yml: no such file or directory

As mentioned above /etc/prometheus is mounted readOnly and so is root filesystem, so to support the templating generating a config I opted for a Kubernetes emptyDir to hold the generated runtime config and included commented snippets for that in the values file.

The idea with the added support is both to add the necessary customization (passing envvars) to the container for the existing entrypoint. My/our usecase is to sync the default credentials from Hashicorp Vault to a secret in the kubernetes cluster, then reference that secret -> env var -> idrac_exporter. These changes makes that possible.

mrlhansen commented 6 months ago

Hi @Jonher937

Looks good to me. I will merge later this week.