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 support to define expose ports for independent agents #1795

Merged
merged 2 commits into from
Apr 25, 2024
Merged
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
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 .ports }}
ports:
{{- range .ports }}
- "{{ . }}"
{{- 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,
"ports": agentInfo.Agent.Ports,
})
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
// Ports is a list of ports to make them available to communicate to the Elastic Agent process
Ports []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.Ports = config.Agent.Ports

// 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"`
Ports []string `config:"ports"`
} `config:"agent"`
}

Expand Down