Skip to content

[autodiscover] - Providing config option to disable Kubeadm config api requests#98

Merged
gizas merged 6 commits intomainfrom
kubeadm
Aug 12, 2024
Merged

[autodiscover] - Providing config option to disable Kubeadm config api requests#98
gizas merged 6 commits intomainfrom
kubeadm

Conversation

@gizas
Copy link
Copy Markdown
Contributor

@gizas gizas commented Jul 3, 2024

Related changes needed for elastic/beats#40086

@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Jul 3, 2024
@gizas gizas added the Team:Cloudnative-Monitoring Label for the Cloud Native Monitoring team label Jul 3, 2024
Comment on lines +150 to +152
if kubeadm {
return clusterInfo, fmt.Errorf("unable to get cluster identifiers from kubeadm-config because conf_kubeadm access has been disabled")
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question, will this be reported as an error in the logs? It seems to me if the user disabled that, it should not be reported as an error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I will change it to Debug

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted to nil

KubeConfig string `config:"kube_config"`

KubeConfig string `config:"kube_config"`
KubeAdm bool `config:"disable_kubeadm"`
Copy link
Copy Markdown
Contributor

@tetianakravchenko tetianakravchenko Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
KubeAdm bool `config:"disable_kubeadm"`
UseKubeAdm bool `config:"use_kubeadm"`

I would use affirmative name instead, so true means enabled, false - disabled, not vice versa
imagine checking in code c.KubeAdm = false would give an impression that it is disabled, it introduce obscurity. WDYT?
default value should be changed in this case

Copy link
Copy Markdown
Contributor Author

@gizas gizas Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I was actually thinking about that. Reason that I chose not to is that the absence of setting the variable evaluates to false and it was quicker like that to implement the code. For eg. https://github.com/elastic/beats/blob/feef1138f809281ac0a70ec97be6ed782901c2ab/metricbeat/module/kubernetes/util/kubernetes.go#L1231 the absence here would mean that this will evaluate to false and all will work and wont have to initialise anything in beats

This would mean that in beats we will need to revert the logic.
In a nutshell,
So not setting use_kubeadm -> use_kubeadm: false in beats module but in here KubeAdm should be true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tetianakravchenko I repeated the tests with use_kubeadm

Final PR has the logic reverted , I mean that use_kubeadm is true by default
Users need to disable (use_kubeadm: false) to see no api calls

I have run tests with metricbeat:

Initial run is with metricbeat-8.15.0-SNAPSHOT: 170 api calls
Second run is with new build of metricbeat and not setting the use_kubeadm variable (so is true): 170 api calls
3rd run is with new build of metricbeat and setting use_kubeadm variable=false: 0 api calls

Screenshot 2024-07-19 at 1 00 22 PM

Reverting back returns the calls

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for reverting the logic and tests!

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

History

@ycombinator
Copy link
Copy Markdown
Contributor

(Note to self and anyone else watching this PR) @gizas is on PTO until the last week of August.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Team:Cloudnative-Monitoring Label for the Cloud Native Monitoring team Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants