-
Notifications
You must be signed in to change notification settings - Fork 713
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 writes data into its own container #4260
Comments
This turns out to be non-trivial to fix. HostPath volumes are mounted Persistent Volumes (I tried the the GKE ones) are mounted without the cc @david-kow |
The filesystem structure is: The problem is that the install path by default is a subdirectory of the data directory which we want to have on the host via @david-kow suggested to override the latter two download settings to have Elastic Agent install into a directory inside the container in which we can execute and keep the data directory on the
The only approach I got working was to to bind mount on top of the |
I raised an issue against the Beats/Elastic Agent repository. Until this is fixed in Elastic Agent which could take a few releases. We can do two things:
We bind mount the hostPath volume to apiVersion: batch/v1
kind: Job
metadata:
name: agent-inspect
spec:
template:
spec:
containers:
- name: agent
image: docker.elastic.co/beats/elastic-agent:7.11.1
command: ["ls", "/usr/share/elastic-agent/data"]
restartPolicy: Never We keep that information around in memory or even in a ConfigMap keyed by Elastic Agent version and use it to construct the volume mount. It's not great but should do the trick. Open to alternative suggestions |
Can we somehow avoid storing the hash information somewhere by running a fancy one-liner script in an init container that would create a symlink from |
Cross device/filesystem symlinks are not possible afaik |
I prototyped a workaround here. There is another idea that uses a custom entrypoint to symlink the
Alternatively we could just document the limitation and explain how users can mount a hostPath volume themselves to the right path for the time being. |
I think I'm leaning towards this. We can even keep this documentation updated with right paths for any future Elastic Agent versions released without the fix. |
Closing this, we added documentation, adjusted the recipes. A fix is merged in Elastic Agent and will ship with 7.13. I have raised #4260 to integrate the Agent fix into ECK's Agent controller |
We mount
/usr/lib/$K8S_NS/$NAME/agent-data
to/usr/share/data
but Elastic Agent uses/usr/share/elastic-agent/data
cloud-on-k8s/pkg/controller/agent/pod.go
Line 33 in 072c591
This means that Elastic Agent is writing data into its own container. That includes all binaries it install as part of any configured packages (Metricbeat and Filebeat for example). This also means that it will lose its identity and runtime state on container restarts.
The intention behind using the
hostPath
volume was to create a persistent store for Agent identity and runtime state. We are doing the same thing for Beats.The text was updated successfully, but these errors were encountered: