I have one yaml file that contains the following:
...
volumeMounts:
- mountPath: /var/lib/grafana
name: grafana-storage
- mountPath: /etc/grafana/provisioning/datasources
name: grafana-datasources
readOnly: false
...
and another file in witch the grafana-datasource volume is specified:
apiVersion: v1
kind: ConfigMap
metadata:
name: grafana-datasources
namespace: ccx-data-pipeline
labels:
grafana_datasource: '1'
data:
prometheus.yaml: |-
{
"apiVersion": 1,
"datasources": [
{
"access":"proxy",
"editable": true,
"name": "prometheus-ccx-service",
"orgId": 1,
"type": "prometheus",
"url": "http://prometheus-service:9090",
"version": 1
}
]
}
the point is that
"url": "http://prometheus-service:9090"
can't be hard coded but must be parametrized (ideally with an environment variable). It would be great to do like so:
"url": "${ENDPOINT}"
but it doesn't work, probably due to the |- syntax. Is there an elegant way to achieve this?
It's not possible directly in kubernetes. ConfigMap treats underlying file as generic data
type and can't template it, since it doesn't recognize its type (.yaml, .conf etc)
What you can do: