Add a readme for k8s autodiscover provider#28213
Add a readme for k8s autodiscover provider#28213MichaelKatsoulis merged 9 commits intoelastic:masterfrom
Conversation
|
Pinging @elastic/integrations (Team:Integrations) |
|
This pull request does not have a backport label. Could you fix it @MichaelKatsoulis? 🙏
NOTE: |
💚 Build Succeeded
Expand to view the summary
Build stats
❕ Flaky test reportNo test was executed to be analysed. 🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
ChrsMark
left a comment
There was a problem hiding this comment.
Very nice that we finally have tech documentation for this codebase!
I left some suggestions about wording. Also moving Agent's part to the respective codebase directory is something that seems more suitable.
Also some comments:
- leader_election is described as part of libbeat's provider but we have also a dedicated provider for Agent. Maybe it is worth documenting it to since you are on it.
- In addition to this, there is also the
kubernetes_secretsprovider for Agent andkubernetes_secrtesbackend for Beats, which is something we could document too as part of this effort.
libbeat/autodiscover/README.md
Outdated
| ### Template based autodiscover | ||
|
|
||
| Example: | ||
| As en example we will use gain redis module. |
There was a problem hiding this comment.
| As en example we will use gain redis module. | |
| As en example we will use again redis module. |
libbeat/autodiscover/README.md
Outdated
| ### Template based autodiscover | ||
|
|
||
| Example: | ||
| As en example we will use gain redis module. |
There was a problem hiding this comment.
| As en example we will use gain redis module. | |
| As en example we will use gain the `redis` module. |
libbeat/autodiscover/README.md
Outdated
| As en example we will use gain redis module. | ||
| In agent.yml(configmap) an extra input block needs to be added. | ||
| ``` | ||
| # Add extra input blocks here, based on conditions |
|
|
||
|
|
||
|
|
||
| ## Autodiscover provider in Elastic Agent |
There was a problem hiding this comment.
I would suggest moving this part under elastic-agent codebase so as to be close to the provider's code. Then you can cross-link it from libbeat's docs.
There was a problem hiding this comment.
yes I should add a readme there too
Co-authored-by: Chris Mark <chrismarkou92@gmail.com>
libbeat/autodiscover/README.md
Outdated
| Step-by-step walkthrough | ||
| 1. Kubernetes provider `init` function [adds](https://github.com/elastic/beats/blob/master/libbeat/autodiscover/providers/kubernetes/kubernetes.go#L46) the provider in the autodiscover providers registry at startup. For Kubernetes provider an `AutodiscoverBuilder` func is passed as an argument. | ||
| 2. Metricbeat calls `NewAutodiscover` [function](https://github.com/elastic/beats/blob/master/metricbeat/beater/metricbeat.go#L183) which checks in the config for enabled providers and [builds](https://github.com/elastic/beats/blob/master/libbeat/autodiscover/provider.go#L90) them one by one, calling the `AutodiscoverBuilder` func. | ||
| 3. Kubernetes `AutodiscoverBuilder` creates and returns a [Kubernetes Provider struct](https://github.com/elastic/beats/blob/master/libbeat/autodiscover/providers/kubernetes/kubernetes.go#L131) which is then added to an Autodiscover manager struct. |
There was a problem hiding this comment.
https://github.com/elastic/beats/blob/master/libbeat/autodiscover/providers/kubernetes/kubernetes.go#L131 points to the empty string now
libbeat/autodiscover/README.md
Outdated
| 3. Kubernetes `AutodiscoverBuilder` creates and returns a [Kubernetes Provider struct](https://github.com/elastic/beats/blob/master/libbeat/autodiscover/providers/kubernetes/kubernetes.go#L131) which is then added to an Autodiscover manager struct. | ||
| 4. When unique is set to true [NewLeaderElectionManager](https://github.com/elastic/beats/blob/master/libbeat/autodiscover/providers/kubernetes/kubernetes.go#L141) is set as the eventManager of Kubernetes Provider. | ||
| 4. Metricbeat [starts](https://github.com/elastic/beats/blob/master/metricbeat/beater/metricbeat.go#L249) the Autodiscover manager which starts for Kubernets provider the [leaderElectionManager](https://github.com/elastic/beats/blob/master/libbeat/autodiscover/providers/kubernetes/kubernetes.go#L326). Before starting the providers it also starts a worker for listening of events that will be published by the eventers of each provider. | ||
| 5. `OnStartedLeading` is executed when the specific metricbeat instance gains the leader election lock. [StartLeading](startLeading) cretaes a bus event with `"start": true,` and publishes it. The template configurations is also added in this event. |
There was a problem hiding this comment.
should this link to startLeading work?
shouldn't it be https://github.com/elastic/beats/blob/master/libbeat/autodiscover/providers/kubernetes/kubernetes.go#L205 ?
There was a problem hiding this comment.
yeah! I don't know what happened there
Co-authored-by: Tetiana Kravchenko <tanya.kravchenko.v@gmail.com>
|
Hi! We're labeling this issue as |
|
Hi! |
|
@ChrsMark @tetianakravchenko I updated all links of code in the READMEs with permalinks. I think it is safe, as at least the text will always correspond to the code. |
…b-for-macos * upstream/master: (172 commits) [Elastic Agent] Fix issue with ensureServiceToken. (elastic#29800) [Winlogbeat] Add provider name to Security routing pipeline check (elastic#29781) Add summary to journeys which don't emit journey:end (early node subprocess exits) (elastic#29606) Prepare 8.0.0-rc1 changelog (elastic#29795) (elastic#29806) Change docker image from CentOS 7 to Ubuntu 20.04 (elastic#29681) libbeat/processors/add_process_metadata: implement a process cache eviction policy (elastic#29717) [Automation] Update elastic stack version to 8.1.0-7004acda for testing (elastic#29783) Missing changelog entry for elastic#29773 (elastic#29791) Add a readme for k8s autodiscover provider (elastic#28213) Remove overriding of index pattern on the Kubernetes overview dashboard (elastic#29676) jjbb: remove obsoleted branches (<7.16) (elastic#29707) Add k8s metadata in state_cronjob metricset (elastic#29572) ibmmq: Fix timestamp parsing (elastic#29773) Do not add date to index if `@meta.index` is set (elastic#29775) ci: uses aliases for the branches (elastic#29706) Filebeat tests: Restore `@timestamp` field validation (elastic#29772) Forward port 7.16.3 changelog to master (elastic#29777) auditd: Store program arguments in process.args array (elastic#29601) System/socket: Support kernel_clone() replacement for _do_fork() (elastic#29744) Do not mention removal if version is not specified in `cfgwarn` messages (elastic#29727) ...
What does this PR do?
This PR creates a markdown file explaining the high and low level functionality of Kubernetes autodiscover provider.
It consists of three major segments.
Why is it important?
The intention is to have a technical document which will help everyone who wants to understand how Kubernetes autodiscover works.
Checklist
CHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.