mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 05:04:05 -08:00
discovery/kubernetes: fix selectors validation for role pod
Signed-off-by: Haley Wang <haley@victoriametrics.com>
This commit is contained in:
parent
0524b880e7
commit
086fcef42b
|
@ -7,7 +7,9 @@ scrape_configs:
|
|||
label: "foo=bar"
|
||||
field: "metadata.status=Running"
|
||||
- role: pod
|
||||
attach_metadata:
|
||||
node: true
|
||||
selectors:
|
||||
- role: "pod"
|
||||
label: "foo in (bar,baz)"
|
||||
- role: "node"
|
||||
label: "foo=bar"
|
||||
field: "metadata.status=Running"
|
||||
|
|
|
@ -222,6 +222,10 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||
break
|
||||
}
|
||||
}
|
||||
// The pod role supports node selectors when configured with `attach_metadata: {node: true}`.
|
||||
if !allowed && selector.Role == RoleNode && c.Role == RolePod && c.AttachMetadata.Node {
|
||||
allowed = true
|
||||
}
|
||||
|
||||
if !allowed {
|
||||
return fmt.Errorf("%s role supports only %s selectors", c.Role, strings.Join(allowedSelectors[c.Role], ", "))
|
||||
|
|
Loading…
Reference in a new issue