Skip to content

Commit 3131065

Browse files
authored
Add support to use wolfi Elastic Agent image starting in 8.16.0-SNAPSHOT (#2038)
Add support to use wolfi Elastic Agent image starting with Elastic stack 8.16.0-SNAPSHOT. This feature can be disabled using a new environment variable: ELASTIC_PACKAGE_DISABLE_ELASTIC_AGENT_WOLFI. Currently, the default value of this environment variable is "false", so it is enabled (it is taken into account just from 8.16.0-SNAPSHOT onward).
1 parent d8572d9 commit 3131065

File tree

5 files changed

+43
-1
lines changed

5 files changed

+43
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ test-stack-command-86:
7373
./scripts/test-stack-command.sh 8.6.2
7474

7575
test-stack-command-8x:
76-
./scripts/test-stack-command.sh 8.16.0-32bc94b7-SNAPSHOT
76+
./scripts/test-stack-command.sh 8.16.0-54ba7abd-SNAPSHOT
7777

7878
test-stack-command-with-apm-server:
7979
APM_SERVER_ENABLED=true ./scripts/test-stack-command.sh

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,9 @@ There are available some environment variables that could be used to change some
692692

693693
- Related to tests:
694694
- `ELASTIC_PACKAGE_SERVERLESS_PIPELINE_TEST_DISABLE_COMPARE_RESULTS`: If set to `true`, the results from pipeline tests are not compared to avoid errors from GeoIP.
695+
- `ELASTIC_PACKAGE_DISABLE_ELASTIC_AGENT_WOLFI`: If set to `true`, the Elastic Agent image used for running agents will be using the Ubuntu docker images
696+
(e.g. `docker.elastic.co/elastic-agent/elastic-agent-complete`). If set to `false`, the Elastic Agent image used for the running agents will be based on the wolfi
697+
images (e.g. `docker.elastic.co/elastic-agent/elastic-agent-wolfi`). Default: `false`.
695698

696699
- To configure the Elastic stack to be used by `elastic-package`:
697700
- `ELASTIC_PACKAGE_ELASTICSEARCH_HOST`: Host of the elasticsearch (e.g. https://127.0.0.1:9200)

internal/install/application_configuration.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"fmt"
1010
"os"
1111
"path/filepath"
12+
"strings"
1213

1314
"github.com/Masterminds/semver/v3"
1415

@@ -23,10 +24,14 @@ import (
2324
const (
2425
stackVersion715 = "7.15.0-SNAPSHOT"
2526
stackVersion820 = "8.2.0-SNAPSHOT"
27+
// Not setting here 8.16.0-SNAPSHOT to take also into account prerelease versions
28+
// like 8.16.0-21bba6f5-SNAPSHOT
29+
stackVersion8160 = "8.16.0-00000000-SNAPSHOT"
2630

2731
elasticAgentImageName = "docker.elastic.co/beats/elastic-agent"
2832
elasticAgentCompleteLegacyImageName = "docker.elastic.co/beats/elastic-agent-complete"
2933
elasticAgentCompleteImageName = "docker.elastic.co/elastic-agent/elastic-agent-complete"
34+
elasticAgentWolfiImageName = "docker.elastic.co/elastic-agent/elastic-agent-wolfi"
3035
elasticsearchImageName = "docker.elastic.co/elasticsearch/elasticsearch"
3136
kibanaImageName = "docker.elastic.co/kibana/kibana"
3237
logstashImageName = "docker.elastic.co/logstash/logstash"
@@ -37,9 +42,12 @@ const (
3742
var (
3843
elasticAgentCompleteFirstSupportedVersion = semver.MustParse(stackVersion715)
3944
elasticAgentCompleteOwnNamespaceVersion = semver.MustParse(stackVersion820)
45+
elasticAgentWolfiVersion = semver.MustParse(stackVersion8160)
4046

4147
// ProfileNameEnvVar is the name of the environment variable to set the default profile
4248
ProfileNameEnvVar = environment.WithElasticPackagePrefix("PROFILE")
49+
50+
disableElasticAgentWolfiEnvVar = environment.WithElasticPackagePrefix("DISABLE_ELASTIC_AGENT_WOLFI")
4351
)
4452

4553
func DefaultConfiguration() *ApplicationConfiguration {
@@ -150,6 +158,15 @@ func selectElasticAgentImageName(version string) string {
150158
logger.Errorf("stack version not in semver format (value: %s): %v", v, err)
151159
return elasticAgentImageName
152160
}
161+
162+
disableWolfiImages := false
163+
valueEnv, ok := os.LookupEnv(disableElasticAgentWolfiEnvVar)
164+
if ok && strings.ToLower(valueEnv) != "false" {
165+
disableWolfiImages = true
166+
}
167+
if !disableWolfiImages && !v.LessThan(elasticAgentWolfiVersion) {
168+
return elasticAgentWolfiImageName
169+
}
153170
if !v.LessThan(elasticAgentCompleteOwnNamespaceVersion) {
154171
return elasticAgentCompleteImageName
155172
}

internal/install/application_configuration_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,22 @@ func TestSelectElasticAgentImageName_NextStackInOwnNamespace(t *testing.T) {
5151
selected := selectElasticAgentImageName(version)
5252
assert.Equal(t, selected, elasticAgentCompleteImageName)
5353
}
54+
55+
func TestSelectElasticAgentImageName_WolfiImage(t *testing.T) {
56+
version := "8.16.0-SNAPSHOT"
57+
selected := selectElasticAgentImageName(version)
58+
assert.Equal(t, selected, elasticAgentWolfiImageName)
59+
}
60+
61+
func TestSelectElasticAgentImageName_DisableWolfiImageEnvVar(t *testing.T) {
62+
version := "8.16.0-SNAPSHOT"
63+
t.Setenv(disableElasticAgentWolfiEnvVar, "true")
64+
selected := selectElasticAgentImageName(version)
65+
assert.Equal(t, selected, elasticAgentCompleteImageName)
66+
}
67+
func TestSelectElasticAgentImageName_EnableWolfiImageEnvVar(t *testing.T) {
68+
version := "8.16.0-SNAPSHOT"
69+
t.Setenv(disableElasticAgentWolfiEnvVar, "false")
70+
selected := selectElasticAgentImageName(version)
71+
assert.Equal(t, selected, elasticAgentWolfiImageName)
72+
}

tools/readme/readme.md.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ There are available some environment variables that could be used to change some
234234

235235
- Related to tests:
236236
- `ELASTIC_PACKAGE_SERVERLESS_PIPELINE_TEST_DISABLE_COMPARE_RESULTS`: If set to `true`, the results from pipeline tests are not compared to avoid errors from GeoIP.
237+
- `ELASTIC_PACKAGE_DISABLE_ELASTIC_AGENT_WOLFI`: If set to `true`, the Elastic Agent image used for running agents will be using the Ubuntu docker images
238+
(e.g. `docker.elastic.co/elastic-agent/elastic-agent-complete`). If set to `false`, the Elastic Agent image used for the running agents will be based on the wolfi
239+
images (e.g. `docker.elastic.co/elastic-agent/elastic-agent-wolfi`). Default: `false`.
237240

238241
- To configure the Elastic stack to be used by `elastic-package`:
239242
- `ELASTIC_PACKAGE_ELASTICSEARCH_HOST`: Host of the elasticsearch (e.g. https://127.0.0.1:9200)

0 commit comments

Comments
 (0)