Skip to content
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

Add profile setting to enable serverless in compose #1766

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,10 @@ The following settings are available per profile:
Defaults to false.
* `stack.self_monitor_enabled` enables monitoring and the system package for the default
policy assigned to the managed Elastic Agent. Defaults to false.
* `stack.serverless_enabled` uses serverless configuration when possible on non serverless
stack providers.
* `stack.serverless.type` selects the type of serverless project to start when using
the serverless stack provider.
the serverless stack provider or `stack.serverless_enabled`.
* `stack.serverless.region` can be used to select the region to use when starting
serverless projects.

Expand Down
10 changes: 10 additions & 0 deletions internal/stack/_static/docker-compose-stack.yml.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{- $username := fact "username" -}}
{{- $password := fact "password" -}}
{{- $apm_enabled := fact "apm_enabled" -}}
{{- $serverless_enabled := fact "serverless_enabled" -}}
{{- $version := fact "kibana_version" -}}

{{- $fleet_healthcheck_success_checks := 3 -}}
Expand All @@ -11,7 +12,11 @@
{{- end -}}
services:
elasticsearch:
{{ if eq $serverless_enabled "true" }}
image: "docker.elastic.co/kibana-ci/elasticsearch-serverless:latest-verified"
{{ else }}
image: "${ELASTICSEARCH_IMAGE_REF}"
{{ end }}
healthcheck:
test: "curl -s --cacert /usr/share/elasticsearch/config/certs/ca-cert.pem -f -u {{ $username }}:{{ $password }} https://127.0.0.1:9200/_cat/health | cut -f4 -d' ' | grep -E '(green|yellow)'"
start_period: 300s
Expand All @@ -24,6 +29,7 @@ services:
- "../certs/elasticsearch:/usr/share/elasticsearch/config/certs"
- "{{ fact "geoip_dir" }}:/usr/share/elasticsearch/config/ingest-geoip"
- "./service_tokens:/usr/share/elasticsearch/config/service_tokens"
- "/tmp/logs:/usr/share/elasticsearch/logs"
ports:
- "127.0.0.1:9200:9200"

Expand All @@ -34,7 +40,11 @@ services:
condition: service_healthy

kibana:
{{ if eq $serverless_enabled "true" }}
image: "docker.elastic.co/kibana-ci/kibana-serverless:latest"
{{ else }}
image: "${KIBANA_IMAGE_REF}"
{{ end }}
depends_on:
elasticsearch:
condition: service_healthy
Expand Down
9 changes: 9 additions & 0 deletions internal/stack/_static/elasticsearch.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@ tracing.apm.enabled: true
tracing.apm.agent.server_url: "http://fleet-server:8200"
tracing.apm.agent.environment: "dev"
{{ end }}

{{ $serverless_enabled := fact "serverless_enabled" }}
{{ if eq $serverless_enabled "true" }}
discovery.type: "single-node"
stateless.enabled: true
stateless.object_store.type: fs
stateless.object_store.bucket: stack
path.repo: /usr/share/elasticsearch/objectstore
{{ end }}
12 changes: 12 additions & 0 deletions internal/stack/_static/kibana.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,15 @@ xpack.fleet.outputs:
{{ indent $agent_key " " }}
{{ end }}
{{ end }}

{{ $serverless_enabled := fact "serverless_enabled" }}
{{ $serverless_project_type := fact "serverless_project_type" }}
{{ if eq $serverless_enabled "true" }}
{{ if eq $serverless_project_type "observability" }}
serverless: oblt
{{ end }}
{{ if eq $serverless_project_type "security" }}
serverless: security
{{ end }}
{{ end }}

26 changes: 15 additions & 11 deletions internal/stack/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ const (
elasticsearchUsername = "elastic"
elasticsearchPassword = "changeme"

configAPMEnabled = "stack.apm_enabled"
configGeoIPDir = "stack.geoip_dir"
configKibanaHTTP2Enabled = "stack.kibana_http2_enabled"
configLogstashEnabled = "stack.logstash_enabled"
configSelfMonitorEnabled = "stack.self_monitor_enabled"
configAPMEnabled = "stack.apm_enabled"
configGeoIPDir = "stack.geoip_dir"
configKibanaHTTP2Enabled = "stack.kibana_http2_enabled"
configLogstashEnabled = "stack.logstash_enabled"
configSelfMonitorEnabled = "stack.self_monitor_enabled"
configServerlessEnabled = "stack.serverless_enabled"
configServerlessProjectType = "stack.serverless.type"
)

var (
Expand Down Expand Up @@ -158,12 +160,14 @@ func applyResources(profile *profile.Profile, stackVersion string) error {
"username": elasticsearchUsername,
"password": elasticsearchPassword,

"apm_enabled": profile.Config(configAPMEnabled, "false"),
"geoip_dir": profile.Config(configGeoIPDir, "./ingest-geoip"),
"logstash_enabled": profile.Config(configLogstashEnabled, "false"),
"self_monitor_enabled": profile.Config(configSelfMonitorEnabled, "false"),
"agent_publish_ports": strings.Join(agentPorts, ","),
"kibana_http2_enabled": profile.Config(configKibanaHTTP2Enabled, "true"),
"apm_enabled": profile.Config(configAPMEnabled, "false"),
"geoip_dir": profile.Config(configGeoIPDir, "./ingest-geoip"),
"logstash_enabled": profile.Config(configLogstashEnabled, "false"),
"self_monitor_enabled": profile.Config(configSelfMonitorEnabled, "false"),
"serverless_enabled": profile.Config(configServerlessEnabled, "false"),
"serverless_project_type": profile.Config(configServerlessProjectType, "observability"),
"agent_publish_ports": strings.Join(agentPorts, ","),
"kibana_http2_enabled": profile.Config(configKibanaHTTP2Enabled, "true"),
})

if err := os.MkdirAll(stackDir, 0755); err != nil {
Expand Down
4 changes: 3 additions & 1 deletion tools/readme/readme.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,10 @@ The following settings are available per profile:
Defaults to false.
* `stack.self_monitor_enabled` enables monitoring and the system package for the default
policy assigned to the managed Elastic Agent. Defaults to false.
* `stack.serverless_enabled` uses serverless configuration when possible on non serverless
stack providers.
* `stack.serverless.type` selects the type of serverless project to start when using
the serverless stack provider.
the serverless stack provider or `stack.serverless_enabled`.
* `stack.serverless.region` can be used to select the region to use when starting
serverless projects.

Expand Down