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

[k8s] embed hints inputs in agent container image #6381

Merged
merged 2 commits into from
Dec 19, 2024

Conversation

pkoutsovasilis
Copy link
Contributor

@pkoutsovasilis pkoutsovasilis commented Dec 18, 2024

What does this PR do?

This PR embeds the hints-based autodiscovery templates directly into the Elastic Agent container image. These templates, previously fetched by an init container, are now included in the image under /usr/share/elastic-agent/hints.inputs.d. The Elastic Agent has been updated to optionally use these embedded templates based on the Kubernetes hints configuration in the user's settings. If hints-based autodiscovery is enabled, the Elastic Agent dynamically reads from the embedded templates directory, ensuring seamless integration without external dependencies.

Additionally:

  • Introduced a new mechanism for discovering hints-based inputs dynamically from the embedded directory.
  • Updated CI to package the templates into the container image during the build process.
  • Modified the Helm chart to remove the dependency on an init container for downloading the templates.

Why is it important?

This change improves the robustness and efficiency of Elastic Agent deployment in Kubernetes environments by:

  • Eliminating the need for an init container to fetch and extract the templates during pod initialisation.
  • Reducing potential errors due to external network issues or offline environments.
  • Accelerating the pod startup process by preloading the templates into the container image.
  • Supporting environments with strict network policies or without external internet access.

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/fragments using the changelog tool
  • I have added an integration test or an E2E test

Disruptive User Impact

This change should not cause any disruption for users. For users who enable hints-based autodiscovery, the behavior remains consistent, with improved reliability. For users who do not enable this feature, the embedded templates will remain unused, ensuring no impact on performance or functionality.

How to test this PR locally

mage integration:auth
PLATFORMS=linux/arm64 EXTERNAL=true SNAPSHOT=true PACKAGES=docker mage -v package 
INSTANCE_PROVISIONER=kind STACK_PROVISIONER=stateful K8S_VERSION=v1.31.1 SNAPSHOT=true mage integration:kubernetes

Related issues

@pkoutsovasilis pkoutsovasilis self-assigned this Dec 18, 2024
@pkoutsovasilis pkoutsovasilis added Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team backport-8.x Automated backport to the 8.x branch with mergify labels Dec 18, 2024
@pkoutsovasilis pkoutsovasilis force-pushed the k8s/embed_hints_templates branch 6 times, most recently from b78cd45 to 9034f25 Compare December 18, 2024 14:06
@pkoutsovasilis pkoutsovasilis force-pushed the k8s/embed_hints_templates branch from 9034f25 to a3dba7a Compare December 18, 2024 16:58
@pkoutsovasilis pkoutsovasilis marked this pull request as ready for review December 18, 2024 19:30
@pkoutsovasilis pkoutsovasilis requested a review from a team as a code owner December 18, 2024 19:30
@elasticmachine
Copy link
Contributor

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

Copy link
Contributor

@swiatekm swiatekm left a comment

Choose a reason for hiding this comment

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

LGTM, but I'm also not an expert on agent packaging, so more eyes on this would be welcome.

@swiatekm swiatekm requested a review from gizas December 19, 2024 10:42
@pkoutsovasilis
Copy link
Contributor Author

ty both @swiatekm and @andrzej-stencel for the reviews, since you didn't spot anything major I feel we are on the right track 🙂 That said, I am gonna wait a little bit more, hopefully for a review from @blakerouse and @gizas just to make sure that there isn't something that I missed since I am relatively new to this parts of code

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.

Looks good.

Determining if providers.kubernetes.hints.enabled didn't turn out as bad as I thought it was going to.

@pkoutsovasilis pkoutsovasilis merged commit a631362 into elastic:main Dec 19, 2024
13 checks passed
@pkoutsovasilis pkoutsovasilis deleted the k8s/embed_hints_templates branch December 19, 2024 16:13
mergify bot pushed a commit that referenced this pull request Dec 19, 2024
* feat: embed hints inputs in elastic-agent container image

* chore: disable lint overflow warnings

(cherry picked from commit a631362)

# Conflicts:
#	deploy/helm/elastic-agent/examples/kubernetes-hints-autodiscover/rendered/manifest.yaml
#	deploy/helm/elastic-agent/examples/multiple-integrations/rendered/manifest.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify 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.

Investigate the copy of autodiscovery templates inside Elastic Agent image
5 participants