From 8b22effb20050ae497f914134d36e471184f1a3f Mon Sep 17 00:00:00 2001 From: mtojek Date: Tue, 26 Oct 2021 18:11:17 +0200 Subject: [PATCH 1/3] Use elasticsearch.yml config --- .../profile/_static/docker-compose-stack.yml | 19 +++---------- .../_static/elasticsearch_config_8x.yml | 17 +++++++++++ .../_static/elasticsearch_config_default.yml | 17 +++++++++++ internal/profile/profile.go | 14 ++++++---- internal/profile/static.go | 28 +++++++++++++++++++ 5 files changed, 74 insertions(+), 21 deletions(-) create mode 100644 internal/profile/_static/elasticsearch_config_8x.yml create mode 100644 internal/profile/_static/elasticsearch_config_default.yml diff --git a/internal/profile/_static/docker-compose-stack.yml b/internal/profile/_static/docker-compose-stack.yml index 8a02ab27e9..97ba44268c 100644 --- a/internal/profile/_static/docker-compose-stack.yml +++ b/internal/profile/_static/docker-compose-stack.yml @@ -7,21 +7,10 @@ services: retries: 300 interval: 1s environment: - - "ES_JAVA_OPTS=-Xms1g -Xmx1g" - - "network.host=" - - "transport.host=127.0.0.1" - - "http.host=0.0.0.0" - - "indices.id_field_data.enabled=true" - - "xpack.license.self_generated.type=trial" - - "xpack.security.enabled=true" - - "xpack.security.authc.api_key.enabled=true" - - "ELASTIC_PASSWORD=changeme" - - "script.max_compilations_rate=use-context" - - "script.context.template.max_compilations_rate=unlimited" - - "script.context.ingest.cache_max_size=2000" - - "script.context.processor_conditional.cache_max_size=2000" - - "script.context.template.cache_max_size=2000" - - "ingest.geoip.downloader.enabled=false" + - "ES_JAVA_OPTS=-Xms1g -Xmx1g" + - "ELASTIC_PASSWORD=changeme" + volumes: + - "./elasticsearch.config.${STACK_VERSION_VARIANT}.yml:/usr/share/elasticsearch/config/elasticsearch.yml" ports: - "127.0.0.1:9200:9200" diff --git a/internal/profile/_static/elasticsearch_config_8x.yml b/internal/profile/_static/elasticsearch_config_8x.yml new file mode 100644 index 0000000000..8dc75fdda3 --- /dev/null +++ b/internal/profile/_static/elasticsearch_config_8x.yml @@ -0,0 +1,17 @@ +network.host: "" +transport.host: "127.0.0.1" +http.host: "0.0.0.0" + +indices.id_field_data.enabled: true + +xpack.license.self_generated.type: "trial" +xpack.security.enabled: true +xpack.security.authc.api_key.enabled: true + +script.max_compilations_rate: "use-context" +script.context.template.max_compilations_rate: "unlimited" +script.context.ingest.cache_max_size: 2000 +script.context.processor_conditional.cache_max_size: 2000 +script.context.template.cache_max_size: 2000 + +ingest.geoip.downloader.enabled: false \ No newline at end of file diff --git a/internal/profile/_static/elasticsearch_config_default.yml b/internal/profile/_static/elasticsearch_config_default.yml new file mode 100644 index 0000000000..8dc75fdda3 --- /dev/null +++ b/internal/profile/_static/elasticsearch_config_default.yml @@ -0,0 +1,17 @@ +network.host: "" +transport.host: "127.0.0.1" +http.host: "0.0.0.0" + +indices.id_field_data.enabled: true + +xpack.license.self_generated.type: "trial" +xpack.security.enabled: true +xpack.security.authc.api_key.enabled: true + +script.max_compilations_rate: "use-context" +script.context.template.max_compilations_rate: "unlimited" +script.context.ingest.cache_max_size: 2000 +script.context.processor_conditional.cache_max_size: 2000 +script.context.template.cache_max_size: 2000 + +ingest.geoip.downloader.enabled: false \ No newline at end of file diff --git a/internal/profile/profile.go b/internal/profile/profile.go index 3b8a4c7931..15298fea42 100644 --- a/internal/profile/profile.go +++ b/internal/profile/profile.go @@ -36,12 +36,14 @@ type configFile string // managedProfileFiles is the list of all files managed in a profile // If you create a new file that's managed by a profile, it needs to go in this list var managedProfileFiles = map[configFile]NewConfig{ - KibanaConfigDefaultFile: newKibanaConfigDefault, - KibanaConfig8xFile: newKibanaConfig8x, - PackageRegistryDockerfileFile: newPackageRegistryDockerfile, - PackageRegistryConfigFile: newPackageRegistryConfig, - SnapshotFile: newSnapshotFile, - PackageProfileMetaFile: createProfileMetadata, + ElasticsearchConfigDefaultFile: newElasticsearchConfigDefault, + ElasticsearchConfig8xFile: newElasticsearchConfig8x, + KibanaConfigDefaultFile: newKibanaConfigDefault, + KibanaConfig8xFile: newKibanaConfig8x, + PackageRegistryDockerfileFile: newPackageRegistryDockerfile, + PackageRegistryConfigFile: newPackageRegistryConfig, + SnapshotFile: newSnapshotFile, + PackageProfileMetaFile: createProfileMetadata, } // NewConfigProfile creates a new config profile manager diff --git a/internal/profile/static.go b/internal/profile/static.go index 3a7020c7e3..e27bdedccd 100644 --- a/internal/profile/static.go +++ b/internal/profile/static.go @@ -53,6 +53,34 @@ func newKibanaConfig8x(_ string, profilePath string) (*simpleFile, error) { }, nil } +// ElasticsearchConfigDefaultFile is the default Elasticsearch config file +const ElasticsearchConfigDefaultFile configFile = "elasticsearch.config.default.yml" + +//go:embed _static/elasticsearch_config_default.yml +var elasticsearchConfigDefaultYml string + +func newElasticsearchConfigDefault(_ string, profilePath string) (*simpleFile, error) { + return &simpleFile{ + name: string(ElasticsearchConfigDefaultFile), + path: filepath.Join(profilePath, profileStackPath, string(ElasticsearchConfigDefaultFile)), + body: elasticsearchConfigDefaultYml, + }, nil +} + +// ElasticsearchConfig8xFile is the Elasticsearch config file for 8.x stack family +const ElasticsearchConfig8xFile configFile = "elasticsearch.config.8x.yml" + +//go:embed _static/elasticsearch_config_8x.yml +var elasticsearchConfig8xYml string + +func newElasticsearchConfig8x(_ string, profilePath string) (*simpleFile, error) { + return &simpleFile{ + name: string(ElasticsearchConfig8xFile), + path: filepath.Join(profilePath, profileStackPath, string(ElasticsearchConfig8xFile)), + body: elasticsearchConfigDefaultYml, + }, nil +} + // PackageRegistryConfigFile is the config file for the Elastic Package registry const PackageRegistryConfigFile configFile = "package-registry.config.yml" From e4c23b6ed6456b3273af0cb126525072af169d6b Mon Sep 17 00:00:00 2001 From: mtojek Date: Tue, 26 Oct 2021 18:21:02 +0200 Subject: [PATCH 2/3] Fix --- internal/profile/static.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/profile/static.go b/internal/profile/static.go index e27bdedccd..48ca985738 100644 --- a/internal/profile/static.go +++ b/internal/profile/static.go @@ -77,7 +77,7 @@ func newElasticsearchConfig8x(_ string, profilePath string) (*simpleFile, error) return &simpleFile{ name: string(ElasticsearchConfig8xFile), path: filepath.Join(profilePath, profileStackPath, string(ElasticsearchConfig8xFile)), - body: elasticsearchConfigDefaultYml, + body: elasticsearchConfig8xYml, }, nil } From c0d4cfd137112c4fda76d8d1c6c2bfb6c3e23c3c Mon Sep 17 00:00:00 2001 From: mtojek Date: Wed, 27 Oct 2021 08:24:35 +0200 Subject: [PATCH 3/3] Remove script.* settings --- internal/profile/_static/elasticsearch_config_8x.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/internal/profile/_static/elasticsearch_config_8x.yml b/internal/profile/_static/elasticsearch_config_8x.yml index 8dc75fdda3..c4fb16b745 100644 --- a/internal/profile/_static/elasticsearch_config_8x.yml +++ b/internal/profile/_static/elasticsearch_config_8x.yml @@ -8,10 +8,4 @@ xpack.license.self_generated.type: "trial" xpack.security.enabled: true xpack.security.authc.api_key.enabled: true -script.max_compilations_rate: "use-context" -script.context.template.max_compilations_rate: "unlimited" -script.context.ingest.cache_max_size: 2000 -script.context.processor_conditional.cache_max_size: 2000 -script.context.template.cache_max_size: 2000 - ingest.geoip.downloader.enabled: false \ No newline at end of file