-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Metricbeat][Kubernetes] Remove mandatory permissions for namespace and node #38762
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
@@ -265,13 +265,20 @@ func TestCreateMetaGenSpecific(t *testing.T) { | |||
require.NoError(t, err) | |||
|
|||
log := logp.NewLogger("test") | |||
|
|||
namespaceConfig, err := conf.NewConfigFrom(map[string]interface{}{ | |||
"enabled": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it needed to set explicitly? by default it is already true
, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I believe the flow is provider > module > metricset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need config.Hints.Enabled()?
Especially that now metaConf.Namespace has default value true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to go. Just a small change in the changelog description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.*.enabled
useless in this case.To fix this issue, we need to prevent the creation of watchers in two places:
hints.enabled
is set to false. Otherwise, the watchers will be created.add_resource_metadata.namespace.enabled
is set to truestate_namespace
is 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.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Configure the provider as:
Results
We no longer have logs with:
Related issues