Merge pull request #10250 from prometheus/beorn7/cleaning-up-cherrypicking-fallout
Merge release-2.33 forward into main
This commit is contained in:
commit
5851557a28
|
@ -1,3 +1,7 @@
|
||||||
|
## 2.33.1 / 2022-02-02
|
||||||
|
|
||||||
|
* [BUGFIX] SD: Fix _no such file or directory_ in K8s SD when not running inside K8s. #10235
|
||||||
|
|
||||||
## 2.33.0 / 2022-01-29
|
## 2.33.0 / 2022-01-29
|
||||||
|
|
||||||
* [CHANGE] PromQL: Promote negative offset and `@` modifer to stable features. #10121
|
* [CHANGE] PromQL: Promote negative offset and `@` modifer to stable features. #10121
|
||||||
|
|
|
@ -1186,6 +1186,14 @@ var expectedErrors = []struct {
|
||||||
filename: "kubernetes_http_config_without_api_server.bad.yml",
|
filename: "kubernetes_http_config_without_api_server.bad.yml",
|
||||||
errMsg: "to use custom HTTP client configuration please provide the 'api_server' URL explicitly",
|
errMsg: "to use custom HTTP client configuration please provide the 'api_server' URL explicitly",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
filename: "kubernetes_kubeconfig_with_own_namespace.bad.yml",
|
||||||
|
errMsg: "cannot use 'kubeconfig_file' and 'namespaces.own_namespace' simultaneously",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
filename: "kubernetes_api_server_with_own_namespace.bad.yml",
|
||||||
|
errMsg: "cannot use 'api_server' and 'namespaces.own_namespace' simultaneously",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
filename: "kubernetes_kubeconfig_with_apiserver.bad.yml",
|
filename: "kubernetes_kubeconfig_with_apiserver.bad.yml",
|
||||||
errMsg: "cannot use 'kubeconfig_file' and 'api_server' simultaneously",
|
errMsg: "cannot use 'kubeconfig_file' and 'api_server' simultaneously",
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
scrape_configs:
|
||||||
|
- job_name: prometheus
|
||||||
|
kubernetes_sd_configs:
|
||||||
|
- role: endpoints
|
||||||
|
api_server: 'https://localhost:1234'
|
||||||
|
namespaces:
|
||||||
|
own_namespace: true
|
|
@ -0,0 +1,7 @@
|
||||||
|
scrape_configs:
|
||||||
|
- job_name: prometheus
|
||||||
|
kubernetes_sd_configs:
|
||||||
|
- role: endpoints
|
||||||
|
kubeconfig_file: /home/User1/.kubeconfig
|
||||||
|
namespaces:
|
||||||
|
own_namespace: true
|
|
@ -184,6 +184,12 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
if c.APIServer.URL == nil && !reflect.DeepEqual(c.HTTPClientConfig, config.DefaultHTTPClientConfig) {
|
if c.APIServer.URL == nil && !reflect.DeepEqual(c.HTTPClientConfig, config.DefaultHTTPClientConfig) {
|
||||||
return errors.Errorf("to use custom HTTP client configuration please provide the 'api_server' URL explicitly")
|
return errors.Errorf("to use custom HTTP client configuration please provide the 'api_server' URL explicitly")
|
||||||
}
|
}
|
||||||
|
if c.APIServer.URL != nil && c.NamespaceDiscovery.IncludeOwnNamespace {
|
||||||
|
return errors.Errorf("cannot use 'api_server' and 'namespaces.own_namespace' simultaneously")
|
||||||
|
}
|
||||||
|
if c.KubeConfig != "" && c.NamespaceDiscovery.IncludeOwnNamespace {
|
||||||
|
return errors.Errorf("cannot use 'kubeconfig_file' and 'namespaces.own_namespace' simultaneously")
|
||||||
|
}
|
||||||
|
|
||||||
foundSelectorRoles := make(map[Role]struct{})
|
foundSelectorRoles := make(map[Role]struct{})
|
||||||
allowedSelectors := map[Role][]string{
|
allowedSelectors := map[Role][]string{
|
||||||
|
@ -293,11 +299,16 @@ func New(l log.Logger, conf *SDConfig) (*Discovery, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ownNamespaceContents, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
|
if conf.NamespaceDiscovery.IncludeOwnNamespace {
|
||||||
if err != nil {
|
ownNamespaceContents, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
|
||||||
return nil, fmt.Errorf("could not determine the pod's namespace: %w", err)
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("could not determine the pod's namespace: %w", err)
|
||||||
|
}
|
||||||
|
if len(ownNamespaceContents) == 0 {
|
||||||
|
return nil, errors.New("could not read own namespace name (empty file)")
|
||||||
|
}
|
||||||
|
ownNamespace = string(ownNamespaceContents)
|
||||||
}
|
}
|
||||||
ownNamespace = string(ownNamespaceContents)
|
|
||||||
|
|
||||||
level.Info(l).Log("msg", "Using pod service account via in-cluster config")
|
level.Info(l).Log("msg", "Using pod service account via in-cluster config")
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue