From ae3f99bc99b0f2fb3da1dc4374c1f07ac6246bde Mon Sep 17 00:00:00 2001 From: mtojek Date: Mon, 8 Mar 2021 15:58:39 +0100 Subject: [PATCH 01/18] Enable Fleet Server --- internal/install/static_kibana_config_yml.go | 1 + internal/install/static_snapshot_yml.go | 1 + 2 files changed, 2 insertions(+) diff --git a/internal/install/static_kibana_config_yml.go b/internal/install/static_kibana_config_yml.go index 02bdf48b8..b2da29828 100644 --- a/internal/install/static_kibana_config_yml.go +++ b/internal/install/static_kibana_config_yml.go @@ -17,6 +17,7 @@ xpack.fleet.enabled: true xpack.fleet.registryUrl: "http://package-registry:8080" xpack.fleet.agents.enabled: true xpack.fleet.agents.elasticsearch.host: "http://elasticsearch:9200" +xpack.fleet.agents.fleetServerEnabled: true xpack.fleet.agents.kibana.host: "http://kibana:5601" xpack.fleet.agents.tlsCheckDisabled: true xpack.encryptedSavedObjects.encryptionKey: "12345678901234567890123456789012" diff --git a/internal/install/static_snapshot_yml.go b/internal/install/static_snapshot_yml.go index 84c0a397b..be2c7e03c 100644 --- a/internal/install/static_snapshot_yml.go +++ b/internal/install/static_snapshot_yml.go @@ -90,6 +90,7 @@ services: - "FLEET_ENROLL=1" - "FLEET_ENROLL_INSECURE=1" - "FLEET_INSECURE=1" + - "FLEET_SERVER_ENABLE=1" - "FLEET_SETUP=1" - "FLEET_URL=http://kibana:5601" - "KIBANA_HOST=http://kibana:5601" From 3054a2854f686c3b2b8905fe15237ab4922a633a Mon Sep 17 00:00:00 2001 From: mtojek Date: Tue, 9 Mar 2021 09:35:43 +0100 Subject: [PATCH 02/18] Add FLEET_SERVER_INSECURE_HTTP --- internal/install/static_snapshot_yml.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/install/static_snapshot_yml.go b/internal/install/static_snapshot_yml.go index be2c7e03c..bae2d66fc 100644 --- a/internal/install/static_snapshot_yml.go +++ b/internal/install/static_snapshot_yml.go @@ -89,6 +89,7 @@ services: environment: - "FLEET_ENROLL=1" - "FLEET_ENROLL_INSECURE=1" + - "FLEET_SERVER_INSECURE_HTTP=1" - "FLEET_INSECURE=1" - "FLEET_SERVER_ENABLE=1" - "FLEET_SETUP=1" From 9e82f14c132816a8687de62e553497785ed97a95 Mon Sep 17 00:00:00 2001 From: mtojek Date: Tue, 16 Mar 2021 16:40:43 +0100 Subject: [PATCH 03/18] Fix: connect to the Fleet Server --- internal/install/static_kibana_config_yml.go | 2 +- internal/install/static_snapshot_yml.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/install/static_kibana_config_yml.go b/internal/install/static_kibana_config_yml.go index b2da29828..ebd0d3676 100644 --- a/internal/install/static_kibana_config_yml.go +++ b/internal/install/static_kibana_config_yml.go @@ -18,7 +18,7 @@ xpack.fleet.registryUrl: "http://package-registry:8080" xpack.fleet.agents.enabled: true xpack.fleet.agents.elasticsearch.host: "http://elasticsearch:9200" xpack.fleet.agents.fleetServerEnabled: true -xpack.fleet.agents.kibana.host: "http://kibana:5601" +xpack.fleet.agents.kibana.host: "http://localhost:8220" xpack.fleet.agents.tlsCheckDisabled: true xpack.encryptedSavedObjects.encryptionKey: "12345678901234567890123456789012" ` diff --git a/internal/install/static_snapshot_yml.go b/internal/install/static_snapshot_yml.go index 2af1bd3f9..c251cc789 100644 --- a/internal/install/static_snapshot_yml.go +++ b/internal/install/static_snapshot_yml.go @@ -93,8 +93,8 @@ services: - "FLEET_INSECURE=1" - "FLEET_SERVER_ENABLE=1" - "FLEET_SETUP=1" - - "FLEET_URL=http://kibana:5601" - - "KIBANA_HOST=http://kibana:5601" + ports: + - "127.0.0.1:8220:8220" volumes: - type: bind source: ../tmp/service_logs/ From b1bd3f7d6b31bdcf38e53a5cd61efbecdadc2446 Mon Sep 17 00:00:00 2001 From: mtojek Date: Thu, 25 Mar 2021 09:15:29 +0100 Subject: [PATCH 04/18] More vars --- internal/install/static_snapshot_yml.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/install/static_snapshot_yml.go b/internal/install/static_snapshot_yml.go index c251cc789..0be3c2b08 100644 --- a/internal/install/static_snapshot_yml.go +++ b/internal/install/static_snapshot_yml.go @@ -89,9 +89,10 @@ services: environment: - "FLEET_ENROLL=1" - "FLEET_ENROLL_INSECURE=1" - - "FLEET_SERVER_INSECURE_HTTP=1" - "FLEET_INSECURE=1" - "FLEET_SERVER_ENABLE=1" + - "FLEET_SERVER_HOST=0.0.0.0" + - "FLEET_SERVER_INSECURE_HTTP=1" - "FLEET_SETUP=1" ports: - "127.0.0.1:8220:8220" From 5b2311e3d1ff33e914119a6ef43b2819e4fe6d45 Mon Sep 17 00:00:00 2001 From: mtojek Date: Thu, 25 Mar 2021 14:56:16 +0100 Subject: [PATCH 05/18] Use vars defined in beats/container.go --- internal/install/static_snapshot_yml.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/install/static_snapshot_yml.go b/internal/install/static_snapshot_yml.go index 0be3c2b08..cda3cd6a3 100644 --- a/internal/install/static_snapshot_yml.go +++ b/internal/install/static_snapshot_yml.go @@ -87,8 +87,6 @@ services: interval: 1s hostname: docker-fleet-agent environment: - - "FLEET_ENROLL=1" - - "FLEET_ENROLL_INSECURE=1" - "FLEET_INSECURE=1" - "FLEET_SERVER_ENABLE=1" - "FLEET_SERVER_HOST=0.0.0.0" From 3e2b85fd22db1a964be19b6fbf7828cac02153f6 Mon Sep 17 00:00:00 2001 From: mtojek Date: Thu, 25 Mar 2021 15:02:37 +0100 Subject: [PATCH 06/18] WIP --- internal/testrunner/runners/system/runner.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/testrunner/runners/system/runner.go b/internal/testrunner/runners/system/runner.go index b1406e602..feb5f79ef 100644 --- a/internal/testrunner/runners/system/runner.go +++ b/internal/testrunner/runners/system/runner.go @@ -299,8 +299,14 @@ func (r *runner) runTest(config *testConfig, ctxt servicedeployer.ServiceContext return nil } - logger.Debug("adding package data stream to test policy...") + /* + logger.Debug("add fleet-server data stream to test policy...") + fleetServer := createPackageDatastream(*policy, *pkgManifest, *dataStreamManifest, *config) + if err := kib.AddPackageDataStreamToPolicy(fleetServer); err != nil { + return result.WithError(errors.Wrap(err, "could not add data stream config to policy")) + }*/ + logger.Debug("adding package data stream to test policy...") ds := createPackageDatastream(*policy, *pkgManifest, *dataStreamManifest, *config) if err := kib.AddPackageDataStreamToPolicy(ds); err != nil { return result.WithError(errors.Wrap(err, "could not add data stream config to policy")) From e069db00c7e64258344cd0b73662ecfe01e897be Mon Sep 17 00:00:00 2001 From: mtojek Date: Fri, 26 Mar 2021 12:47:37 +0100 Subject: [PATCH 07/18] Revert --- internal/testrunner/runners/system/runner.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/internal/testrunner/runners/system/runner.go b/internal/testrunner/runners/system/runner.go index feb5f79ef..7d740bb2f 100644 --- a/internal/testrunner/runners/system/runner.go +++ b/internal/testrunner/runners/system/runner.go @@ -299,13 +299,6 @@ func (r *runner) runTest(config *testConfig, ctxt servicedeployer.ServiceContext return nil } - /* - logger.Debug("add fleet-server data stream to test policy...") - fleetServer := createPackageDatastream(*policy, *pkgManifest, *dataStreamManifest, *config) - if err := kib.AddPackageDataStreamToPolicy(fleetServer); err != nil { - return result.WithError(errors.Wrap(err, "could not add data stream config to policy")) - }*/ - logger.Debug("adding package data stream to test policy...") ds := createPackageDatastream(*policy, *pkgManifest, *dataStreamManifest, *config) if err := kib.AddPackageDataStreamToPolicy(ds); err != nil { From f1d5135e0618a9337799132e69116089843a8aa8 Mon Sep 17 00:00:00 2001 From: mtojek Date: Fri, 26 Mar 2021 13:17:13 +0100 Subject: [PATCH 08/18] Try with two agent instances --- internal/install/static_snapshot_yml.go | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/internal/install/static_snapshot_yml.go b/internal/install/static_snapshot_yml.go index cda3cd6a3..6130e526f 100644 --- a/internal/install/static_snapshot_yml.go +++ b/internal/install/static_snapshot_yml.go @@ -74,7 +74,7 @@ services: package-registry: condition: service_healthy - elastic-agent: + fleet-server: image: ${ELASTIC_AGENT_IMAGE_REF} depends_on: elasticsearch: @@ -87,13 +87,27 @@ services: interval: 1s hostname: docker-fleet-agent environment: - - "FLEET_INSECURE=1" - "FLEET_SERVER_ENABLE=1" - - "FLEET_SERVER_HOST=0.0.0.0" - "FLEET_SERVER_INSECURE_HTTP=1" - - "FLEET_SETUP=1" + - "KIBANA_FLEET_SETUP=1" + - "KIBANA_FLEET_HOST=http://kibana:5601" ports: - "127.0.0.1:8220:8220" + + elastic-agent: + image: ${ELASTIC_AGENT_IMAGE_REF} + depends_on: + fleet-server: + condition: service_healthy + healthcheck: + test: "sh -c 'grep \"Agent is starting\" /usr/share/elastic-agent/elastic-agent.log*'" + retries: 30 + interval: 1s + hostname: docker-fleet-agent + environment: + - "FLEET_ENROLL=1" + - "FLEET_INSECURE=1" + - "FLEET_URL=http://fleet-server:8220" volumes: - type: bind source: ../tmp/service_logs/ From 5088df3912dd09d678b37dfaf1134329833901af Mon Sep 17 00:00:00 2001 From: mtojek Date: Fri, 26 Mar 2021 13:48:15 +0100 Subject: [PATCH 09/18] Clean variables --- internal/install/static_kibana_config_yml.go | 2 +- internal/install/static_kubernetes_elastic_agent_yml.go | 6 +----- internal/install/static_snapshot_yml.go | 5 +++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/internal/install/static_kibana_config_yml.go b/internal/install/static_kibana_config_yml.go index ebd0d3676..d9369212c 100644 --- a/internal/install/static_kibana_config_yml.go +++ b/internal/install/static_kibana_config_yml.go @@ -18,7 +18,7 @@ xpack.fleet.registryUrl: "http://package-registry:8080" xpack.fleet.agents.enabled: true xpack.fleet.agents.elasticsearch.host: "http://elasticsearch:9200" xpack.fleet.agents.fleetServerEnabled: true -xpack.fleet.agents.kibana.host: "http://localhost:8220" +xpack.fleet.agents.kibana.host: "http://fleet-server:8220" xpack.fleet.agents.tlsCheckDisabled: true xpack.encryptedSavedObjects.encryptionKey: "12345678901234567890123456789012" ` diff --git a/internal/install/static_kubernetes_elastic_agent_yml.go b/internal/install/static_kubernetes_elastic_agent_yml.go index e66bc62f1..f6e23ed39 100644 --- a/internal/install/static_kubernetes_elastic_agent_yml.go +++ b/internal/install/static_kubernetes_elastic_agent_yml.go @@ -30,14 +30,10 @@ spec: env: - name: FLEET_ENROLL value: "1" - - name: FLEET_ENROLL_INSECURE - value: "1" - name: FLEET_INSECURE value: "1" - name: FLEET_URL - value: "http://kibana:5601" - - name: KIBANA_HOST - value: "http://kibana:5601" + value: "http://fleet-server:8220" - name: NODE_NAME valueFrom: fieldRef: diff --git a/internal/install/static_snapshot_yml.go b/internal/install/static_snapshot_yml.go index 6130e526f..e9d516415 100644 --- a/internal/install/static_snapshot_yml.go +++ b/internal/install/static_snapshot_yml.go @@ -85,12 +85,13 @@ services: test: "sh -c 'grep \"Agent is starting\" /usr/share/elastic-agent/elastic-agent.log*'" retries: 30 interval: 1s - hostname: docker-fleet-agent + hostname: docker-fleet-server environment: - "FLEET_SERVER_ENABLE=1" - "FLEET_SERVER_INSECURE_HTTP=1" - "KIBANA_FLEET_SETUP=1" - "KIBANA_FLEET_HOST=http://kibana:5601" + - "FLEET_SERVER_HOST=0.0.0.0" ports: - "127.0.0.1:8220:8220" @@ -101,7 +102,7 @@ services: condition: service_healthy healthcheck: test: "sh -c 'grep \"Agent is starting\" /usr/share/elastic-agent/elastic-agent.log*'" - retries: 30 + retries: 60 interval: 1s hostname: docker-fleet-agent environment: From 706ce73415f8967d53e54405f0b70335a791dd8d Mon Sep 17 00:00:00 2001 From: mtojek Date: Fri, 26 Mar 2021 16:57:01 +0100 Subject: [PATCH 10/18] Increase retry --- internal/install/static_snapshot_yml.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/install/static_snapshot_yml.go b/internal/install/static_snapshot_yml.go index e9d516415..100ea0f00 100644 --- a/internal/install/static_snapshot_yml.go +++ b/internal/install/static_snapshot_yml.go @@ -82,8 +82,8 @@ services: kibana: condition: service_healthy healthcheck: - test: "sh -c 'grep \"Agent is starting\" /usr/share/elastic-agent/elastic-agent.log*'" - retries: 30 + test: "curl -f http://127.0.0.1:8220/api/status | grep HEALTHY 2>&1 >/dev/null" + retries: 60 interval: 1s hostname: docker-fleet-server environment: @@ -102,7 +102,7 @@ services: condition: service_healthy healthcheck: test: "sh -c 'grep \"Agent is starting\" /usr/share/elastic-agent/elastic-agent.log*'" - retries: 60 + retries: 30 interval: 1s hostname: docker-fleet-agent environment: From 9f68f0d6402bf5e9b6440f20ddc7cff8ae62bc8b Mon Sep 17 00:00:00 2001 From: mtojek Date: Fri, 26 Mar 2021 17:04:07 +0100 Subject: [PATCH 11/18] Retries --- internal/install/static_snapshot_yml.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/install/static_snapshot_yml.go b/internal/install/static_snapshot_yml.go index 100ea0f00..3278ab0fe 100644 --- a/internal/install/static_snapshot_yml.go +++ b/internal/install/static_snapshot_yml.go @@ -102,7 +102,7 @@ services: condition: service_healthy healthcheck: test: "sh -c 'grep \"Agent is starting\" /usr/share/elastic-agent/elastic-agent.log*'" - retries: 30 + retries: 90 interval: 1s hostname: docker-fleet-agent environment: From 69ecf9b9fa65fde94e74216d21d992e2e8e1e721 Mon Sep 17 00:00:00 2001 From: mtojek Date: Mon, 29 Mar 2021 14:04:55 +0200 Subject: [PATCH 12/18] Try: increase healthcheck interval --- internal/install/static_snapshot_yml.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/install/static_snapshot_yml.go b/internal/install/static_snapshot_yml.go index 3278ab0fe..45f2be49f 100644 --- a/internal/install/static_snapshot_yml.go +++ b/internal/install/static_snapshot_yml.go @@ -83,8 +83,8 @@ services: condition: service_healthy healthcheck: test: "curl -f http://127.0.0.1:8220/api/status | grep HEALTHY 2>&1 >/dev/null" - retries: 60 - interval: 1s + retries: 12 + interval: 5s hostname: docker-fleet-server environment: - "FLEET_SERVER_ENABLE=1" From 58c47e03c568ebb4718a0199125989c9d2f0a3ac Mon Sep 17 00:00:00 2001 From: mtojek Date: Wed, 31 Mar 2021 10:20:59 +0200 Subject: [PATCH 13/18] Dump fleet-server logs --- internal/stack/dump.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/stack/dump.go b/internal/stack/dump.go index a135390f2..d47a5e156 100644 --- a/internal/stack/dump.go +++ b/internal/stack/dump.go @@ -15,7 +15,7 @@ import ( "github.com/elastic/elastic-package/internal/logger" ) -var observedServices = []string{"elasticsearch", "elastic-agent", "kibana", "package-registry"} +var observedServices = []string{"elasticsearch", "elastic-agent", "fleet-server", "kibana", "package-registry"} // DumpOptions defines dumping options for Elatic stack data. type DumpOptions struct { From c46a537a3ba13d5f035de544a38caed6c217da1c Mon Sep 17 00:00:00 2001 From: mtojek Date: Tue, 6 Apr 2021 15:43:22 +0200 Subject: [PATCH 14/18] Fix: bad merge --- internal/install/static_snapshot_yml.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/internal/install/static_snapshot_yml.go b/internal/install/static_snapshot_yml.go index 1457595c0..42ff35bfa 100644 --- a/internal/install/static_snapshot_yml.go +++ b/internal/install/static_snapshot_yml.go @@ -84,7 +84,26 @@ services: condition: service_healthy healthcheck: test: "curl -f http://127.0.0.1:8220/api/status | grep HEALTHY 2>&1 >/dev/null" - retries: 30 + retries: 12 + interval: 5s + hostname: docker-fleet-server + environment: + - "FLEET_SERVER_ENABLE=1" + - "FLEET_SERVER_INSECURE_HTTP=1" + - "KIBANA_FLEET_SETUP=1" + - "KIBANA_FLEET_HOST=http://kibana:5601" + - "FLEET_SERVER_HOST=0.0.0.0" + ports: + - "127.0.0.1:8220:8220" + + elastic-agent: + image: ${ELASTIC_AGENT_IMAGE_REF} + depends_on: + fleet-server: + condition: service_healthy + healthcheck: + test: "sh -c 'grep \"Agent is starting\" -r . --include=elastic-agent-json.log'" + retries: 90 interval: 1s hostname: docker-fleet-agent environment: From 50ece51543264a871486e96a231284c0b840e135 Mon Sep 17 00:00:00 2001 From: mtojek Date: Wed, 7 Apr 2021 09:50:56 +0200 Subject: [PATCH 15/18] Latest fixes --- internal/install/static_snapshot_yml.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/install/static_snapshot_yml.go b/internal/install/static_snapshot_yml.go index 42ff35bfa..a36c03d27 100644 --- a/internal/install/static_snapshot_yml.go +++ b/internal/install/static_snapshot_yml.go @@ -92,7 +92,6 @@ services: - "FLEET_SERVER_INSECURE_HTTP=1" - "KIBANA_FLEET_SETUP=1" - "KIBANA_FLEET_HOST=http://kibana:5601" - - "FLEET_SERVER_HOST=0.0.0.0" ports: - "127.0.0.1:8220:8220" @@ -102,7 +101,7 @@ services: fleet-server: condition: service_healthy healthcheck: - test: "sh -c 'grep \"Agent is starting\" -r . --include=elastic-agent-json.log'" + test: "./elastic-agent status" retries: 90 interval: 1s hostname: docker-fleet-agent From fc412cb170425d3cdb5eeaa0f2d825e93e38238a Mon Sep 17 00:00:00 2001 From: mtojek Date: Wed, 7 Apr 2021 10:04:48 +0200 Subject: [PATCH 16/18] Revert FLEET_SERVER_HOST --- internal/install/static_snapshot_yml.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/install/static_snapshot_yml.go b/internal/install/static_snapshot_yml.go index a36c03d27..6e6fe0a53 100644 --- a/internal/install/static_snapshot_yml.go +++ b/internal/install/static_snapshot_yml.go @@ -92,6 +92,7 @@ services: - "FLEET_SERVER_INSECURE_HTTP=1" - "KIBANA_FLEET_SETUP=1" - "KIBANA_FLEET_HOST=http://kibana:5601" + - "FLEET_SERVER_HOST=0.0.0.0" ports: - "127.0.0.1:8220:8220" From 9ee732c479df7a786c33414945e2ee10170923ca Mon Sep 17 00:00:00 2001 From: mtojek Date: Wed, 7 Apr 2021 10:14:19 +0200 Subject: [PATCH 17/18] Fix --- internal/install/static_snapshot_yml.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/install/static_snapshot_yml.go b/internal/install/static_snapshot_yml.go index 6e6fe0a53..2fe10a39b 100644 --- a/internal/install/static_snapshot_yml.go +++ b/internal/install/static_snapshot_yml.go @@ -92,7 +92,6 @@ services: - "FLEET_SERVER_INSECURE_HTTP=1" - "KIBANA_FLEET_SETUP=1" - "KIBANA_FLEET_HOST=http://kibana:5601" - - "FLEET_SERVER_HOST=0.0.0.0" ports: - "127.0.0.1:8220:8220" @@ -102,7 +101,7 @@ services: fleet-server: condition: service_healthy healthcheck: - test: "./elastic-agent status" + test: "sh -c 'grep \"Agent is starting\" -r . --include=elastic-agent-json.log'" retries: 90 interval: 1s hostname: docker-fleet-agent From 0f537502de1ef729ff8655f8f49612ffc6b7b464 Mon Sep 17 00:00:00 2001 From: mtojek Date: Wed, 7 Apr 2021 10:23:28 +0200 Subject: [PATCH 18/18] FLEET_SERVER_HOST is required --- internal/install/static_snapshot_yml.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/install/static_snapshot_yml.go b/internal/install/static_snapshot_yml.go index 2fe10a39b..42ff35bfa 100644 --- a/internal/install/static_snapshot_yml.go +++ b/internal/install/static_snapshot_yml.go @@ -92,6 +92,7 @@ services: - "FLEET_SERVER_INSECURE_HTTP=1" - "KIBANA_FLEET_SETUP=1" - "KIBANA_FLEET_HOST=http://kibana:5601" + - "FLEET_SERVER_HOST=0.0.0.0" ports: - "127.0.0.1:8220:8220"