elastic / elastic-agent

Elastic Agent - single, unified way to add monitoring for logs, metrics, and other types of data to a host.
Other
20 stars 144 forks source link

Add --proxy-url to the elastic-agent upgrade command #5195

Open mbudge opened 3 months ago

mbudge commented 3 months ago

Hi,

Customers might want to upgrade elastic-agent using the upgrade command on a network using proxies.

Without the --proxy-url command they have to do a manual reinstall if they can't set the proxy.

https://www.elastic.co/guide/en/fleet/current/elastic-agent-cmd-options.html#elastic-agent-upgrade-command

Allowing elastic-agent upgrade do an upgrade of Elastic-agent running in Fleet managed mode would allow customers do an upgrade if there's ever a problem with the Fleet managed upgrade process.

Requirements

cmacknz commented 3 months ago

The proxy_url option is supported in the agent.download section of the policy, but looking closer we don't actually document this. https://github.com/elastic/elastic-agent/blob/907cfa7bca90948da058cf40b52b7c550f5d7300/elastic-agent.yml#L157

No reason we can't also support the --proxy-url argument for convenience to avoid having to edit the configuration as well.

elasticmachine commented 3 months ago

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

cmacknz commented 3 months ago

For reference, we embed our generic HTTP transport settings configuration into the artfiact configuration structure: https://github.com/elastic/elastic-agent/blob/4d074b9ff02433e0c3a70f5e31d55db52fbd9b9d/internal/pkg/agent/application/upgrade/artifact/config.go#L94-L96

https://github.com/elastic/elastic-agent/blob/4d074b9ff02433e0c3a70f5e31d55db52fbd9b9d/internal/pkg/agent/application/upgrade/artifact/config.go#L94-L96

This is what gives us proxy_url in addition to all of the ssl options that exist on our other network connections.

type HTTPClientProxySettings struct {
    // Proxy URL to use for http connections. If the proxy url is configured,
    // it is used for all connection attempts. All proxy related environment
    // variables are ignored.
    URL *ProxyURI `config:"proxy_url" yaml:"proxy_url,omitempty"`

    // Headers configures additional headers that are send to the proxy
    // during CONNECT requests.
    Headers ProxyHeaders `config:"proxy_headers" yaml:"proxy_headers,omitempty"`

    // Disable HTTP proxy support. Configured URLs and environment variables
    // are ignored.
    Disable bool `config:"proxy_disable" yaml:"proxy_disable,omitempty"`
}