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

[8.x](backport #6381) [k8s] embed hints inputs in agent container image #6409

Merged
merged 3 commits into from
Dec 23, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Dec 19, 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

* 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
@mergify mergify bot requested a review from a team as a code owner December 19, 2024 16:53
@mergify mergify bot added backport conflicts There is a conflict in the backported pull request labels Dec 19, 2024
@mergify mergify bot requested review from michalpristas and blakerouse and removed request for a team December 19, 2024 16:53
Copy link
Contributor Author

mergify bot commented Dec 19, 2024

Cherry-pick of a631362 has failed:

On branch mergify/bp/8.x/pr-6381
Your branch is up to date with 'origin/8.x'.

You are currently cherry-picking commit a631362d5.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   changelog/fragments/1734512365-embed-hints-inputs-in-agent-container-image.yaml
	modified:   deploy/helm/elastic-agent/templates/integrations/_kubernetes/_kubernetes.tpl
	modified:   deploy/helm/elastic-agent/templates/integrations/_kubernetes/_kubernetes_hints.tpl
	modified:   deploy/helm/elastic-agent/templates/integrations/_kubernetes/_preset_pernode.tpl
	modified:   dev-tools/packaging/package_test.go
	modified:   dev-tools/packaging/packages.yml
	modified:   internal/pkg/agent/application/application.go
	modified:   internal/pkg/composable/providers/kubernetes/config.go
	new file:   internal/pkg/composable/providers/kubernetes/config_test.go
	modified:   internal/pkg/config/loader.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   deploy/helm/elastic-agent/examples/kubernetes-hints-autodiscover/rendered/manifest.yaml
	both modified:   deploy/helm/elastic-agent/examples/multiple-integrations/rendered/manifest.yaml

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Copy link
Contributor Author

mergify bot commented Dec 23, 2024

This pull request has not been merged yet. Could you please review and merge it @pkoutsovasilis? 🙏

@pkoutsovasilis pkoutsovasilis merged commit c24173a into 8.x Dec 23, 2024
13 checks passed
@pkoutsovasilis pkoutsovasilis deleted the mergify/bp/8.x/pr-6381 branch December 23, 2024 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport conflicts There is a conflict in the backported pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant