mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34: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"
|
label: "foo=bar"
|
||||||
field: "metadata.status=Running"
|
field: "metadata.status=Running"
|
||||||
- role: pod
|
- role: pod
|
||||||
|
attach_metadata:
|
||||||
|
node: true
|
||||||
selectors:
|
selectors:
|
||||||
- role: "pod"
|
- role: "node"
|
||||||
label: "foo in (bar,baz)"
|
label: "foo=bar"
|
||||||
field: "metadata.status=Running"
|
field: "metadata.status=Running"
|
||||||
|
|
|
@ -222,6 +222,10 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
break
|
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 {
|
if !allowed {
|
||||||
return fmt.Errorf("%s role supports only %s selectors", c.Role, strings.Join(allowedSelectors[c.Role], ", "))
|
return fmt.Errorf("%s role supports only %s selectors", c.Role, strings.Join(allowedSelectors[c.Role], ", "))
|
||||||
|
|
Loading…
Reference in a new issue