Skip to content

Commit 776cded

Browse files
committed
Allow to define which ports should be exposed
1 parent de0336c commit 776cded

File tree

5 files changed

+11
-0
lines changed

5 files changed

+11
-0
lines changed

internal/agentdeployer/_static/docker-agent-base.yml.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ services:
2020
{{ end }}
2121
cap_drop:
2222
- ALL
23+
{{ if .exposePorts }}
24+
ports:
25+
{{- range .exposePorts }}
26+
- "{{ . }}"
27+
{{- end }}
28+
{{ end }}
2329
environment:
2430
- FLEET_ENROLL=1
2531
- FLEET_URL=https://fleet-server:8220

internal/agentdeployer/agent.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ func (d *DockerComposeAgentDeployer) installDockerfile(agentInfo AgentInfo) (str
256256
"capabilities": agentInfo.Agent.LinuxCapabilities,
257257
"runtime": agentInfo.Agent.Runtime,
258258
"pidMode": agentInfo.Agent.PidMode,
259+
"exposePorts": agentInfo.Agent.ExposePorts,
259260
})
260261
if err != nil {
261262
return "", fmt.Errorf("failed to create contents of the docker-compose file %q: %w", customAgentDockerfile, err)

internal/agentdeployer/info.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ type AgentInfo struct {
8282
Runtime string
8383
// LinuxCapabilities is a list of the capabilities needed to run the Elastic Agent process
8484
LinuxCapabilities []string
85+
// ExposePorts is a list of ports to make them available to communicate to the Elastic Agent process
86+
ExposePorts []string
8587
}
8688

8789
// CustomProperties store additional data used to boot up the service, e.g. AWS credentials.

internal/testrunner/runners/system/runner.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ func (r *runner) createAgentInfo(policy *kibana.Policy, config *testConfig, agen
338338
info.Agent.LinuxCapabilities = config.Agent.LinuxCapabilities
339339
info.Agent.Runtime = config.Agent.Runtime
340340
info.Agent.PidMode = config.Agent.PidMode
341+
info.Agent.ExposePorts = config.Agent.ExposePorts
341342

342343
// If user is defined in the configuration file, it has preference
343344
// and it should not be overwritten by the value in the manifest

internal/testrunner/runners/system/test_config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ type testConfig struct {
5858
PidMode string `config:"pid_mode"`
5959
LinuxCapabilities []string `config:"linux_capabilities"`
6060
Runtime string `config:"runtime"`
61+
ExposePorts []string `config:"expose_ports"`
6162
} `config:"agent"`
6263
}
6364

0 commit comments

Comments
 (0)