[Metricbeat][Kubernetes] Remove mandatory permissions for namespace and node#38762
[Metricbeat][Kubernetes] Remove mandatory permissions for namespace and node#38762constanca-m merged 10 commits intoelastic:mainfrom
Conversation
Signed-off-by: constanca <constanca.manteigas@elastic.co>
|
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
Signed-off-by: constanca <constanca.manteigas@elastic.co>
|
This pull request is now in conflicts. Could you fix it? 🙏 |
Signed-off-by: constanca <constanca.manteigas@elastic.co>
…space-permissions
| log := logp.NewLogger("test") | ||
|
|
||
| namespaceConfig, err := conf.NewConfigFrom(map[string]interface{}{ | ||
| "enabled": true, |
There was a problem hiding this comment.
is it needed to set explicitly? by default it is already true, no?
There was a problem hiding this comment.
By default is true, yes, but in this case we need to at it explicitly because the config is not unpacking the default one, like we now are doing for pod_test and service_test.
Signed-off-by: constanca <constanca.manteigas@elastic.co>
| if addResourceMetadata.Node.Enabled() { | ||
| extra = append(extra, NodeResource) | ||
| } | ||
| if addResourceMetadata.Namespace.Enabled() { |
There was a problem hiding this comment.
This made think of the scenario:
a) kubernetes.provider has add_resource.metadata.namespace.enabled: false and the module add_resource.metadata.namespace.enabled: true --> This means that the watcher will start. Always the module config is more specific correct?
There was a problem hiding this comment.
Yes, I believe the flow is provider > module > metricset.
There was a problem hiding this comment.
If you are talking about kubernetes module, it does not use the kubernetes provider. The kubernetes autodiscover provider can be used to start different modules (like nginx based on hints or templates) and also is used in log collection.
| if err != nil { | ||
| logger.Errorf("couldn't create watcher for %T due to error %+v", &kubernetes.Namespace{}, err) | ||
|
|
||
| if metaConf.Namespace.Enabled() || config.Hints.Enabled() { |
There was a problem hiding this comment.
Do we actually need config.Hints.Enabled()?
Especially that now metaConf.Namespace has default value true?
There was a problem hiding this comment.
Maybe not, but we had this before and I think changing it could be a breaking change, correct?
|
After today's meeting, we decided the following:
|
|
@constanca-m The add_kubernetes_metadata processor also includes the |
Signed-off-by: constanca <constanca.manteigas@elastic.co>
|
Thank you @MichaelKatsoulis. I added the condition for both namespace and node watchers in the latest commit. |
Co-authored-by: Michael Katsoulis <michaelkatsoulis88@gmail.com>
MichaelKatsoulis
left a comment
There was a problem hiding this comment.
Good to go. Just a small change in the changelog description.
blakerouse
left a comment
There was a problem hiding this comment.
Overall change is mechanical. Looks good to me!
Proposed commit message
Issue of the PR is #37179.
Currently, we need to have permissions for namespace and nodes, because we create watchers for these resources.
This makes the option
add_resource_metadata.*.enableduseless in this case.To fix this issue, we need to prevent the creation of watchers in two places:
hints.enabledis set to false. Otherwise, the watchers will be created.add_resource_metadata.namespace.enabledis set to truestate_namespaceis enabled, then we create the watcher for that resource, regardless of the blockadd_resource_metadata. Same for node metricsets.This means having this in the configuration of the kubernetes provider:
And making sure:
Checklist
CHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.How to test this PR locally
Configure the provider as:
Results
We no longer have logs with:
Related issues