我有一个包含以下内容的yaml文件:
...
volumeMounts:
- mountPath: /var/lib/grafana
name: grafana-storage
- mountPath: /etc/grafana/provisioning/datasources
name: grafana-datasources
readOnly: false
...和另一个文件,其中指定了grafana-datasource卷:
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
}
]
}重点是
"url": "http://prometheus-service:9090" 不能硬编码,但必须参数化(理想情况下使用环境变量)。这样做会很棒:
"url": "${ENDPOINT}"但是它不工作,可能是由于|-语法的原因。有没有一种优雅的方法来实现这一点?
发布于 2020-04-03 20:56:22
这在kubernetes中是不可能直接实现的。ConfigMap将底层文件视为泛型data类型,无法将其模板化,因为它无法识别其类型(.yaml、.conf等)
您可以执行的操作:
动态生成
https://stackoverflow.com/questions/61011911
复制相似问题