Skip to content
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

Cherry-pick #24913 to 7.x: Add kubernetes_leaderelection provider #24984

Merged
merged 2 commits into from
Apr 8, 2021

Conversation

ChrsMark
Copy link
Member

@ChrsMark ChrsMark commented Apr 8, 2021

Cherry-pick of PR #24913 to 7.x branch. Original message:

What does this PR do?

Adds support for leaderelection provider in Agent based on #24267.

After this one is merged I plan to tune standalone manifest in follow-up PR so as to remove deployment section and only deploy as Deamonset with leaderelection "on".

Why is it important?

To support cluster wide metrics collection by only one Agent at a time between a group of multiple Agents (ie Deamonset).

On a second step we can change the standalone manifest, completely remove the Deployment of Agent and go on with only the Daemonset leveraging the leaderelection feature.

How to test this PR locally

  1. Enable the provider and an input based on the leader condition:
providers:
  kubernetes_leaderelection:
    kube_config: /Users/chrismark/.kube/config
    leader_lease: elastic-agent
  
inputs:
  - type: logfile
    condition: ${kubernetes_leaderelection.leader} == true
    streams:
      - paths: /var/log/leaderlog/another.log
  1. run inspect command to verify the output: ./elastic-agent -e -d "*" -c /elastic-agent.yml inspect output -o default
  2. Verify the conditional input is enabled:
filebeat:
  inputs:
  - index: logs-generic-default
    paths: /var/log/leaderlog/another.log
    processors:
    - add_fields:
        fields:
          dataset: generic
          namespace: default
          type: logs
        target: data_stream
    - add_fields:
        fields:
          dataset: generic
        target: event
    - add_fields:
        fields:
          id: 32806c0a-4f04-499c-9427-e6e24e5f6035
          snapshot: false
          version: 8.0.0
        target: elastic_agent
    type: log
  1. (Optional:) Perform same test from different Agents and on a running mode so as to verify that only one of them picks the lock and becomes the leader

Related issues

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Apr 8, 2021
@ChrsMark ChrsMark added [zube]: In Review backport Team:Elastic-Agent Label for the Agent team Team:Integrations Label for the Integrations team labels Apr 8, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/agent (Team:Agent)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations (Team:Integrations)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Apr 8, 2021
@botelastic
Copy link

botelastic bot commented Apr 8, 2021

This pull request doesn't have a Team:<team> label.

Signed-off-by: chrismark <[email protected]>
@elasticmachine
Copy link
Collaborator

elasticmachine commented Apr 8, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Started by user Chris Mark

  • Start Time: 2021-04-08T11:45:55.942+0000

  • Duration: 57 min 10 sec

  • Commit: f467459

Test stats 🧪

Test Results
Failed 0
Passed 6564
Skipped 24
Total 6588

Trends 🧪

Image of Build Times

Image of Tests

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 6564
Skipped 24
Total 6588

@ChrsMark ChrsMark merged commit dcd6b22 into elastic:7.x Apr 8, 2021
@zube zube bot added [zube]: Done and removed [zube]: Inbox labels Apr 8, 2021
@zube zube bot removed the [zube]: Done label Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:Elastic-Agent Label for the Agent team Team:Integrations Label for the Integrations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants