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

[Elastic Agent] Add support for Fleet Server inside Docker #24220

Merged
merged 6 commits into from
Mar 1, 2021

Conversation

blakerouse
Copy link
Contributor

@blakerouse blakerouse commented Feb 24, 2021

What does this PR do?

First it refactors the entrypoint for the Elastic Agent docker container to use a new subcommand container. This subcommand is designed specifically to be executed by the container runtime. Based on the defined environment variables it prepares the Elastic Agent to run in that environment. Due to the large number of environment variables that Elastic Agent needed and the complexity of the order of operations based it was best to move this from a bash script to golang.

With the refactor comes the ability to bootstrap the Elastic Agent inside of a docker container. Using the FLEET_SERVER_ENABLE flag the docker container will bootstrap the Fleet Server and enroll the Elastic Agent all inside the container on startup.

Why is it important?

To allow Fleet Server to be spawned under Elastic Agent while being executed under Docker.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

@blakerouse blakerouse added the Team:Fleet Label for the Fleet team label Feb 24, 2021
@blakerouse blakerouse self-assigned this Feb 24, 2021
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Feb 24, 2021
@blakerouse blakerouse marked this pull request as ready for review February 24, 2021 20:10
@elasticmachine
Copy link
Collaborator

Pinging @elastic/fleet (Team:Fleet)

@elasticmachine
Copy link
Collaborator

elasticmachine commented Feb 24, 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: blakerouse commented: /test

  • Start Time: 2021-03-01T19:44:44.250+0000

  • Duration: 113 min 39 sec

  • Commit: 896efa2

Test stats 🧪

Test Results
Failed 0
Passed 46636
Skipped 4939
Total 51575

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 46636
Skipped 4939
Total 51575

@blakerouse
Copy link
Contributor Author

/package

@blakerouse
Copy link
Contributor Author

/test

}
c.log.Info("Successfully triggered restart on running Elastic Agent.")
c.stopAgent()
Copy link
Contributor

Choose a reason for hiding this comment

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

not necessary; based on defer c.stopAgent() in L169

This prepares the Fleet plugin that exists inside of Kibana. This must either be enabled here or done externally
before Fleet Server will actually successfully start.

KIBANA_FLEET_SETUP - set to 1 enables this setup
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a (silent) breaking change, that will break setups working with FLEET_SETUP, without any error message. The Elastic Agent starts, but does not perform the fleet set up. I am wondering if we should be backwards compatible here and also support FLEET_SETUP (until 8.0) although not GA yet.
Otherwise, could you create a docs follow up issue to ensure this is captured somwhere, otherwise people probably have a hard time figuring this out.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/ingest-management (Team:Ingest Management)

Copy link
Contributor

@simitt simitt left a comment

Choose a reason for hiding this comment

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

Changes LGTM

@blakerouse
Copy link
Contributor Author

/test

@blakerouse blakerouse merged commit a84508c into elastic:master Mar 1, 2021
@blakerouse blakerouse deleted the agent-fleet-server-docker branch March 1, 2021 22:20
axw added a commit to axw/apm-server that referenced this pull request Mar 2, 2021
axw added a commit to elastic/apm-server that referenced this pull request Mar 2, 2021
blakerouse added a commit to blakerouse/beats that referenced this pull request Mar 2, 2021
…4220)

* Add new container subcommand.

* Fix vet.

* Fix path with just enroll.

* Add changelog.

* Add FLEET_SETUP fallback. Make GET, POST to kibana for resilient.

* Add FLEET_FORCE. Don't update Kibana config when Fleet Server running locally.

(cherry picked from commit a84508c)
blakerouse added a commit that referenced this pull request Mar 2, 2021
…24291)

* Add new container subcommand.

* Fix vet.

* Fix path with just enroll.

* Add changelog.

* Add FLEET_SETUP fallback. Make GET, POST to kibana for resilient.

* Add FLEET_FORCE. Don't update Kibana config when Fleet Server running locally.

(cherry picked from commit a84508c)
simitt added a commit to simitt/apm-integration-testing that referenced this pull request Mar 8, 2021
simitt added a commit to simitt/apm-integration-testing that referenced this pull request Mar 8, 2021
axw added a commit to axw/apm-server that referenced this pull request Mar 25, 2021
axw added a commit to elastic/apm-server that referenced this pull request Apr 1, 2021
Fix enrollment due to elastic/beats#24220

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Fleet Label for the Fleet team v7.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants