Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upNo way to use anchors in YAML config file #1884
Comments
This comment has been minimized.
This comment has been minimized.
|
I never used it myself but could writing it out in the first occurence work and then referencing it in subsequent ones? Personally, I'd strongly recommend letting configuration management handle that though. |
fabxc
added
the
kind/question
label
Aug 10, 2016
This comment has been minimized.
This comment has been minimized.
|
Maybe I can define the name in the first job and then refer to the anchor in subsequent jobs (is that what you meant?). Didn't occur to me because I — probably wrongly! — assumed anchors were scoped by nesting level. I'm using Kubernetes configmaps, which don't have any templating support, and it's nice to be able to write YAML without templating, given that it actually has this kind of macro support. |
This comment has been minimized.
This comment has been minimized.
|
So that seemed to work: - job_name: 'kubernetes-cluster'
tls_config: &k8s_tls_config
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
insecure_skip_verify: true
- job_name: 'kubernetes-apiserver'
tls_config: *k8s_tls_configThat doesn't let me use the _:
kubernetes_target: &kubernetes_target
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
insecure_skip_verify: true
# ...
scrape_configs:
- <<: *kubernetes_target
job_name: 'kubernetes-cluster'As you probably know, |
brian-brazil
closed this
Oct 26, 2016
This comment has been minimized.
This comment has been minimized.
benkeil
commented
Jun 27, 2018
|
Was there any result? |
atombender commentedAug 10, 2016
It's desirable to reuse configuration to avoid duplication (which can lead to drift or copy/paste mistakes). For example, this ought to be possible:
However, this will cause Prometheus to reject the config file:
I don't see any non-schema-validated key where I can attach dummy anchors. In the absence of this, I propose that it ignore keys starting with
_, for example.(Is there a hacky workaround I use in the meantime, however?)