-
Notifications
You must be signed in to change notification settings - Fork 229
Labels
Team:Elastic-Agent-Control-PlaneLabel for the Agent Control Plane teamLabel for the Agent Control Plane teambugSomething isn't workingSomething isn't working
Description
When running Elastic Agent in a container managed by ECK as a DaemonSet, the agent re-enrolls on every pod restart despite valid enrollment state (fleet.enc) being persisted via a hostPath volume. This results in duplicate agent entries in Fleet.
The root cause is a string comparison mismatch in shouldFleetEnroll in container.go.
storedFleetHosts := storedConfig.Fleet.Client.GetHosts()
if len(storedFleetHosts) == 0 || !slices.Contains(storedFleetHosts, setupCfg.Fleet.URL) {
// The Fleet URL in the setup does not exist in the stored configuration, so enrollment is required.
return true, nil
}
setupCfg.Fleet.URL is populated directly from the FLEET_URL environment variable, which includes the scheme.
storedConfig.Fleet.Client.GetHosts returns values from the stored remote.Config struct, which stores the protocol separately in a Protocol field and the host as just host:port.
For confirmed bugs, please report:
- Version: All
- Operating System: Containers
- Steps to Reproduce:
- Deploy ECK 3.3.1 with Elasticsearch, Kibana, and Fleet Server on a Kubernetes cluster
- Deploy an Elastic Agent as a DaemonSet using the ECK Agent CRD with mode: fleet and fleetServerEnabled: false
- The ECK operator injects
FLEET_ENROLL=true,FLEET_URL=https://..., andFLEET_ENROLLMENT_TOKENinto the pod spec, and mounts agent state at/usr/share/elastic-agent/statevia a hostPath volume - Wait for the agent to enroll and become healthy
- Delete a DaemonSet pod
kubectl delete pod <agent-pod> - The DaemonSet controller creates a replacement pod on the same node
- Observe the replacement pod's logs:
Starting enrollment to URL: https://fleet-server-agent-http.default.svc:8220/.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Team:Elastic-Agent-Control-PlaneLabel for the Agent Control Plane teamLabel for the Agent Control Plane teambugSomething isn't workingSomething isn't working
Type
Fields
Give feedbackNo fields configured for Bug.