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

Docker image running Elastic Agent in Otel mode #5248

Merged
merged 13 commits into from
Aug 20, 2024

Conversation

michalpristas
Copy link
Contributor

@michalpristas michalpristas commented Aug 2, 2024

Adding new type of docker image for amd64 and arm64
Image is based on wolfi and contains agent binary without components resulting in 277MB
Using separate otel entrypoint and Dockerfile templates for simplification

fixes: #5246

How to test this PR

These steps were added after this PR was merged and it's functionality was available in the next snapshot build.

  1. Run Elastic Agent 8.16.0-SNAPSHOT in a Docker container, setting the new environment variable introduced in this PR to run Agent in OTel mode.
    $ docker run -e ELASTIC_AGENT_OTEL=true --rm --name agent docker.elastic.co/beats/elastic-agent-complete:8.16.0-SNAPSHOT
    
  2. In a new window/tab, check the process list running inside the container.
    $ docker exec agent sh -c 'ps aux'
    
  3. Verify that there is an elastic-agent otel process and no Beats or other sub-processes of the elastic-agent otel process.

@michalpristas michalpristas added enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team Team:Elastic-Agent Label for the Agent team labels Aug 2, 2024
@michalpristas michalpristas requested a review from cmacknz August 2, 2024 09:46
@michalpristas michalpristas self-assigned this Aug 2, 2024
@michalpristas michalpristas requested a review from a team as a code owner August 2, 2024 09:46
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

Copy link
Contributor

mergify bot commented Aug 2, 2024

This pull request does not have a backport label. Could you fix it @michalpristas? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 8./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

I like the idea of a second dockerfile, as I know the other is complicated. On the other hand I do worry about the issues this brings of having to make updates in two places (like pcap adjustments not being consistent, or adjustments to deps, etc.).

My question is how much is this really saving in complexity in the file? It looks similar but without the synthetics stuff with is already conditional.

@michalpristas
Copy link
Contributor Author

@blakerouse if we agree on keeping components (still a question), i will merge this into a single docker file,
with components out it seemed more clean to have separate dockerfile instead of nested conditional statements.

@michalpristas michalpristas marked this pull request as draft August 5, 2024 13:57
@michalpristas michalpristas marked this pull request as ready for review August 5, 2024 14:30
@@ -265,3 +265,7 @@ RUN echo -e '#!/bin/sh\nexec /usr/local/bin/docker-entrypoint' > /app/apm.sh &&
{{- else }}
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/docker-entrypoint"]
{{- end }}

{{- if contains .image_name "-otel" }}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

starting with a default config


set -eo pipefail

exec {{ .BeatName }} otel "$@"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

kept entrypoint separate to avoid starting conditionally based on ENV vars

@ycombinator ycombinator requested a review from blakerouse August 8, 2024 20:55
@michalpristas
Copy link
Contributor Author

michalpristas commented Aug 9, 2024

failures on k8s integ tests. related: #5275

@strawgate
Copy link
Contributor

Do we want to discuss the inclusion of components and the use of a separate dockerfile in the PR or in the issue? I have an open item in the issue

@cmacknz
Copy link
Member

cmacknz commented Aug 9, 2024

Yeah, thinking more I think our life might be easier if we just support this with an environment variable. #5246 (comment)

An elastic-agent-otel container is probably easier for users, but adding an env var that is equivalent to running elastic-agent otel in the container isn't much more work than changing the image name.

@michalpristas
Copy link
Contributor Author

Updated entrypoint to execute proper command based on env var.
Hopefully we can unblock observability team soon

@strawgate
Copy link
Contributor

Did we confirm that the operator allows customizing the env vars?

@michalpristas
Copy link
Contributor Author

yes this is something i initially offered and they were happy with env vars

@cmacknz
Copy link
Member

cmacknz commented Aug 9, 2024

This should probably have a basic smoke test. Probably something can be added using the tests in https://github.com/elastic/elastic-agent/blob/main/testing/integration/kubernetes_agent_standalone_test.go as a base.

@michalpristas michalpristas requested a review from a team as a code owner August 12, 2024 08:58
Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

Much simplier, but doesn't reduce the image size. That is something that will come with time, I believe.

Comment on lines +249 to +251
"beat/metrics-monitoring": false,
"filestream-monitoring": false,
"system/metrics-default": false,
Copy link
Member

Choose a reason for hiding this comment

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

Is there actually a way you can tell we started the OTel collector?

This test would still pass if we started elastic agent as usual, but disabled monitoring and didn't use the system/metrics integration/

Copy link
Contributor Author

@michalpristas michalpristas Aug 13, 2024

Choose a reason for hiding this comment

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

yes but scenario you mentioned is not the default config nor any config we test with so chance of false positive is really small, especially when agent is reported healthy.
no way to tell agent is in otel besides logs that are with default config printed to stdout.

Copy link
Member

Choose a reason for hiding this comment

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

There isn't an HTTP port or something that returns otel specific data or something?

I don't feel that strongly about this

Copy link
Member

Choose a reason for hiding this comment

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

Improving this is something we could follow up with.

Copy link

@ycombinator ycombinator merged commit 852d47c into elastic:main Aug 20, 2024
13 checks passed
@ycombinator
Copy link
Contributor

@amolnater-qasource I have added testing instructions for this PR to the PR description.

@amolnater-qasource
Copy link

Thank you!! @ycombinator

@amolnater-qasource
Copy link

Hi Team,
We have tested this PR on Ubuntu 24.

Steps followed:

  1. Run: sudo docker run -e ELASTIC_AGENT_OTEL=true --rm --name agent docker.elastic.co/beats/elastic-agent-complete:8.16.0-SNAPSHOT
  2. On a new instance run: sudo docker exec agent sh -c 'ps aux'
  3. Observe: elastic-agent otel process is available.
  4. Observe no Beats or other sub-processes are available.

Screenshots:
image
image

Hence, we are marking this ticket as QA:Validated.
Please let us know if we are missing anything here.

cc: @pierrehilbert

Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip enhancement New feature or request skip-changelog Team:Elastic-Agent Label for the Agent team Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docker image running Elastic Agent in Otel mode
7 participants