Sidecar to merge Yaml snippets from multiple ConfigMaps and save it to file.
Exposes metrics on (configurable) port http://0.0.0.0:9980/
.
Originally conceived as a sidecar for Prometheus, it can be used with anything consuming a yaml configuration file.
- Watch the changes to configmaps with specific label.
- On any change get the contents from all watched ConfigMaps.
- Merge the content together as yaml.
- Write the yaml content to file.
- Hit Prometheus reload API to reload the file.
Setup Python environment the standard way:
poetry install
Run the program:
poetry run python -m merger \
--prometheus-config-file-path 'my-test-config.yaml' \
--label-selector='prom-rules.yaml' \
--namespace 'monitoring' \
--reload-url 'http://localhost:9090/-/reload'
If you want to use this sidecar with prometheus-community helm chart, you need to add this container as a sidecar, create common volume and mount it.
Here is example:
server:
sidecarContainers:
prometheus-config-merger:
image: mindw/yaml-config-merger:0.2.0
imagePullPolicy: IfNotPresent
args:
- --prometheus-config-file-path=/etc/config-prometheus/prometheus.yml
- --label-selector='prom-rules' \
- --namespace 'monitoring' \
- --reload-url 'http://localhost:9090/-/reload'
volumeMounts:
- name: prometheus-merged-config
mountPath: /etc/config-prometheus/
extraVolumeMounts:
- name: prometheus-merged-config
mountPath: /etc/config-prometheus/
extraVolumes:
- name: prometheus-merged-config
emptyDir: {}
configPath: /etc/config-prometheus/prometheus.yml