Skip to content

Commit

Permalink
Allow to define which ports should be exposed
Browse files Browse the repository at this point in the history
  • Loading branch information
mrodm committed Apr 22, 2024
1 parent c2ff98b commit d9e2124
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/agentdeployer/_static/docker-agent-base.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ services:
- {{ . }}
{{- end }}
{{ end }}
{{ if .exposePorts }}
ports:
{{- range .exposePorts }}
- "{{ . }}"
{{- end }}
{{ end }}
environment:
- FLEET_ENROLL=1
- FLEET_URL=https://fleet-server:8220
Expand Down
1 change: 1 addition & 0 deletions internal/agentdeployer/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ func (d *DockerComposeAgentDeployer) installDockerfile(agentInfo AgentInfo) (str
"capabilities": agentInfo.Agent.LinuxCapabilities,
"runtime": agentInfo.Agent.Runtime,
"pidMode": agentInfo.Agent.PidMode,
"exposePorts": agentInfo.Agent.ExposePorts,
})
if err != nil {
return "", fmt.Errorf("failed to create contents of the docker-compose file %q: %w", customAgentDockerfile, err)
Expand Down
2 changes: 2 additions & 0 deletions internal/agentdeployer/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ type AgentInfo struct {
Runtime string
// LinuxCapabilities is a list of the capabilities needed to run the Elastic Agent process
LinuxCapabilities []string
// ExposePorts is a list of ports to make them available to communicate to the Elastic Agent process
ExposePorts []string
}

// CustomProperties store additional data used to boot up the service, e.g. AWS credentials.
Expand Down
1 change: 1 addition & 0 deletions internal/testrunner/runners/system/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ func (r *runner) createAgentInfo(policy *kibana.Policy, config *testConfig, agen
info.Agent.LinuxCapabilities = config.Agent.LinuxCapabilities
info.Agent.Runtime = config.Agent.Runtime
info.Agent.PidMode = config.Agent.PidMode
info.Agent.ExposePorts = config.Agent.ExposePorts

// If user is defined in the configuration file, it has preference
// and it should not be overwritten by the value in the manifest
Expand Down
1 change: 1 addition & 0 deletions internal/testrunner/runners/system/test_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type testConfig struct {
PidMode string `config:"pid_mode"`
LinuxCapabilities []string `config:"linux_capabilities"`
Runtime string `config:"runtime"`
ExposePorts []string `config:"expose_ports"`
} `config:"agent"`
}

Expand Down

0 comments on commit d9e2124

Please sign in to comment.