Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

[elastic-agent]: Support running APM Server managed #1016

Merged
merged 6 commits into from
Jan 18, 2021

Conversation

simitt
Copy link
Contributor

@simitt simitt commented Dec 31, 2020

What does this PR do?

Supports running APM Server managed by Elastic Agent by running --apm-server-managed --with-elastic-agent

  • remove existing APM packages and install apm-integration-testing policy to default policy

  • expose APM Server port in Elastic Agent

  • run a reverse proxy for apm-server:8200 to not require changes in existing Opbeans services

  • only uses config options that are supported by managed APM Server: apm-server.secret_token
    (RUM is always enabled, host is set to listen on all interfaces anyways)

The APM Server container runs the install script and provides the healthcheck for APM. This way the Elastic Agent (for now) doesn't have to bother about which integrations should be running for providing an overall healthcheck.

Why is it important?

To test APM Server managed by Elastic Agent

Related issues

related #1004

cc @graphaelli I see this as a short-to-midterm solution until we have a more general solution on how managed policies should be created on Elastic Agent startup. There is also going to be a couple of changes when the Fleet Server gets integrated into the Agent, as there probably won't be a direct Kibana connection anymore .

* add --apm-server-managed flag to use in combination with --elastic-agent

* install apm-integration-testing policy and remove old ones

* expose APM Server port in Elastic Agent
@apmmachine
Copy link
Collaborator

apmmachine commented Dec 31, 2020

💚 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 timer

    • Start Time: 2021-01-18T04:39:00.226+0000
  • Duration: 34 min 26 sec

  • Commit: 9040570

Test stats 🧪

Test Results
Failed 0
Passed 448
Skipped 11
Total 459

@graphaelli
Copy link
Member

short-to-midterm solution until we have a more general solution on how managed policies should be created on Elastic Agent startup. There is also going to be a couple of changes when the Fleet Server gets integrated into the Agent, as there probably won't be a direct Kibana connection anymore .

Given this caveat I'm comfortable with approach.

docker/apm-server/managed/docker-entrypoint.sh Outdated Show resolved Hide resolved
docker/apm-server/managed/docker-entrypoint.sh Outdated Show resolved Hide resolved
scripts/modules/elastic_stack.py Outdated Show resolved Hide resolved
@simitt simitt marked this pull request as ready for review January 14, 2021 20:55
Copy link
Member

@graphaelli graphaelli left a comment

Choose a reason for hiding this comment

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

I really like the installer written in go, particularly for the error handling. I'm having trouble getting this stack to come up cleanly, consistently. I believe there is a race between the apm-server-managed container looking for default policy that the elastic-agent container is creating. A simple depends_on doesn't exactly fix it since a really slow starting elastic-agent will still pass this trivial health check before apm-server-managed tries to find the policy. I've proposed a retry in the installer to address this.

docker/apm-server/managed/main.go Outdated Show resolved Hide resolved
docker/apm-server/managed/main.go Outdated Show resolved Hide resolved
docker/apm-server/managed/main.go Outdated Show resolved Hide resolved
}
return &kibanaClient{
fleetURL: fmt.Sprintf("%s/api/fleet", host),
pkgURL: "https://epr-snapshot.elastic.co",
Copy link
Member

Choose a reason for hiding this comment

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

with #1010 should the package registry support configuration?

Copy link
Contributor

Choose a reason for hiding this comment

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

It should also account for the production (and maybe staging) registry, eg. when running a release branch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, so in which cases should we use the release URL - only for apm-server-release or als for apm-server-bc? (I believe only for release).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

went with release only for now

docker/apm-server/managed/main.go Outdated Show resolved Hide resolved
@simitt simitt merged commit 82fac4b into elastic:master Jan 18, 2021
@kuisathaverat
Copy link
Contributor

@graphaelli @simitt Do we want to enable APM Server managed on the daily ITs?

@simitt
Copy link
Contributor Author

simitt commented Jan 18, 2021

@kuisathaverat the APM Server managed only supports a handful of config options so far. Are there any configurations needed for the daily ITs (except for apm-server.host and apm-server.secret_token)?

@kuisathaverat
Copy link
Contributor

I do not see any other parameter, we can do a try on a PR and see

@simitt
Copy link
Contributor Author

simitt commented Jan 18, 2021

That would be great, thanks @kuisathaverat

kuisathaverat pushed a commit to kuisathaverat/apm-integration-testing that referenced this pull request Jan 20, 2021
* add --apm-server-managed flag to use in combination with --elastic-agent

* install apm-integration-testing policy and remove old ones if needed

* expose APM Server port in Elastic Agent only when it manages APM Server

* make package registry configurable
# Conflicts:
#	scripts/modules/elastic_stack.py
#	scripts/tests/service_tests.py
@simitt simitt deleted the apm-server-managed branch March 8, 2021 07:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants