feat(ext/fleet): Store state in a volume

Prevents duplicate enrollments when the fleet-server container is
re-created.
This commit is contained in:
Antoine Cotten 2022-11-15 15:48:35 +01:00
parent d0b97082cf
commit 1943f25282
No known key found for this signature in database
GPG Key ID: 94637E68D4A79DD0
3 changed files with 10 additions and 1 deletions

View File

@ -1,3 +1,8 @@
ARG ELASTIC_VERSION ARG ELASTIC_VERSION
FROM docker.elastic.co/beats/elastic-agent:${ELASTIC_VERSION} FROM docker.elastic.co/beats/elastic-agent:${ELASTIC_VERSION}
# Ensure the 'state' directory exists and is owned by the 'elastic-agent' user,
# otherwise mounting a named volume in that location creates a directory owned
# by root:root which the 'elastic-agent' user isn't allowed to write to.
RUN mkdir state

View File

@ -33,7 +33,6 @@ management UI: [Fleet UI Settings][fleet-cfg].
## Known Issues ## Known Issues
- Every re-creation of the `fleet-server` container creates a duplicate agent in Fleet's central management.
- Logs and metrics are only collected within the Fleet Server's container. Ultimately, we want to emulate the behaviour - Logs and metrics are only collected within the Fleet Server's container. Ultimately, we want to emulate the behaviour
of the existing Metricsbeat and Filebeat extensions, and collect logs and metrics from all ELK containers of the existing Metricsbeat and Filebeat extensions, and collect logs and metrics from all ELK containers
out-of-the-box. Unfortunately, this kind of use-case isn't (yet) well supported by Fleet, and most advanced out-of-the-box. Unfortunately, this kind of use-case isn't (yet) well supported by Fleet, and most advanced

View File

@ -6,6 +6,8 @@ services:
context: extensions/fleet/ context: extensions/fleet/
args: args:
ELASTIC_VERSION: ${ELASTIC_VERSION} ELASTIC_VERSION: ${ELASTIC_VERSION}
volumes:
- fleet-server:/usr/share/elastic-agent/state:z
environment: environment:
FLEET_SERVER_ENABLE: '1' FLEET_SERVER_ENABLE: '1'
FLEET_SERVER_INSECURE_HTTP: 'true' FLEET_SERVER_INSECURE_HTTP: 'true'
@ -28,3 +30,6 @@ services:
depends_on: depends_on:
- elasticsearch - elasticsearch
- kibana - kibana
volumes:
fleet-server: