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

[UII] Add proxy args to install snippets #193922

Merged
merged 14 commits into from
Oct 1, 2024

Conversation

jen-huang
Copy link
Contributor

@jen-huang jen-huang commented Sep 24, 2024

Summary

Resolves #184222. This PR:

  • Ensures custom agent binary download source URI is respected where ever it appears in command snippets, for both Fleet Server and Elastic Agent install instructions
    • If a proxy is associated with the source URI, the appropriate args are added to the commands as well
    • For curl commands, these are appended as --proxy <url> and --proxy-header "<key>-<value>" (repeated for each header key/value pair)
    • For Windows, these are appended as -Proxy "<url>" and -Headers @{"<key1>"="<value1>"; "<key2>"="<value2>"}
  • Adjusts Fleet Server ./elastic-agent install instructions so that:
    • --fleet-server-es is the value of the data output host set on that Fleet Server policy (must be ES output)
    • If a proxy is associated with that ES output, the corresponding args are appended:
      --proxy-url=<url> and --proxy-header "<key>-<value>" (repeated for each header key/value pair)

The internal API at /internal/fleet/settings/enrollment has new properties added to its response to support this:

  fleet_server: {
    es_output?: Output;
    es_output_proxy?: FleetProxy;
  };
  download_source_proxy?: FleetProxy;

Examples

Fleet Server install with proxied custom download and proxied ES host:

curl -L -O https://my-agent-binary-source/beats/elastic-agent/elastic-agent-9.0.0-linux-x86_64.tar.gz --proxy http://some-proxy:1111 --proxy-header "Accept-Language=en-US,en;q=0.5" --proxy-header "Accept-Encoding=gzip, deflate, br"
tar xzvf elastic-agent-9.0.0-linux-x86_64.tar.gz
cd elastic-agent-9.0.0-linux-x86_64
sudo ./elastic-agent install \
  --fleet-server-es=http://localhost:9999 \
  --fleet-server-service-token=REDACTED \
  --fleet-server-policy=027a180f-2f4a-4dd1-a531-bf1d1d64179f \
  --fleet-server-port=8220 \
  --proxy-url=http://some-proxy:1111 \
  --proxy-header="Accept-Language=en-US,en;q=0.5" \
  --proxy-header="Accept-Encoding=gzip, deflate, br"
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri https://my-agent-binary-source/beats/elastic-agent/elastic-agent-9.0.0-windows-x86_64.zip -OutFile elastic-agent-9.0.0-windows-x86_64.zip -Proxy "http://some-proxy:1111" -Headers @{"Accept-Language"="en-US,en;q=0.5";"Accept-Encoding"="gzip, deflate, br"}
Expand-Archive .\elastic-agent-9.0.0-windows-x86_64.zip
cd elastic-agent-9.0.0-windows-x86_64
.\elastic-agent.exe install `
  --fleet-server-es=http://localhost:9999 `
  --fleet-server-service-token=REDACTED `
  --fleet-server-policy=027a180f-2f4a-4dd1-a531-bf1d1d64179f `
  --fleet-server-port=8220 `
  --proxy-url=http://some-proxy:1111 `
  --proxy-header="Accept-Language=en-US,en;q=0.5" `
  --proxy-header="Accept-Encoding=gzip, deflate, br"

Elastic Agent install with proxied download source and proxied Fleet Server host:

curl -L -O https://my-agent-binary-source/beats/elastic-agent/elastic-agent-8.15.1-darwin-aarch64.tar.gz --proxy http://some-proxy:1111 --proxy-header "Accept-Language=en-US,en;q=0.5" --proxy-header "Accept-Encoding=gzip, deflate, br"
tar xzvf elastic-agent-8.15.1-darwin-aarch64.tar.gz
cd elastic-agent-8.15.1-darwin-aarch64
sudo ./elastic-agent install --url=https://localhost:2222 --enrollment-token=REDACTED --proxy-url=http://some-proxy:1111 --proxy-header "Accept-Language=en-US,en;q=0.5" --proxy-header "Accept-Encoding=gzip, deflate, br"
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri https://my-agent-binary-source/beats/elastic-agent/elastic-agent-8.15.1-windows-x86_64.zip -OutFile elastic-agent-8.15.1-windows-x86_64.zip -Proxy "http://some-proxy:1111" -Headers @{"Accept-Language"="en-US,en;q=0.5";"Accept-Encoding"="gzip, deflate, br"}
Expand-Archive .\elastic-agent-8.15.1-windows-x86_64.zip -DestinationPath .
cd elastic-agent-8.15.1-windows-x86_64
.\elastic-agent.exe install --url=https://localhost:2222 --enrollment-token=REDACTED --proxy-url=http://some-proxy:1111 --proxy-header "Accept-Language=en-US,en;q=0.5" --proxy-header "Accept-Encoding=gzip, deflate, br"

To-do

  • Unit tests
  • API integration tests for enrollment settings endpoint

@jen-huang jen-huang added release_note:fix Team:Fleet Team label for Observability Data Collection Fleet team backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) labels Sep 24, 2024
@jen-huang jen-huang self-assigned this Sep 24, 2024
@obltmachine
Copy link

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@jen-huang jen-huang marked this pull request as ready for review September 24, 2024 23:18
@jen-huang jen-huang requested a review from a team as a code owner September 24, 2024 23:18
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@@ -23,6 +23,12 @@ properties:
type: string
download_source_id:
type: string
space_ids:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for adding this 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 the spec for this API isn't actually compiled due to it being an internal route, but figured I'd keep it up-to-date anyway

@@ -70,26 +78,28 @@ function getArtifact(

export function getInstallCommandForPlatform(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if it will make sense to use an an object with named parameters here as argument, as we have so many parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this was really annoying when I was working here. I'll go ahead and change it to an object

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@jen-huang
Copy link
Contributor Author

jen-huang commented Sep 25, 2024

@lucabelluccini As you filed the original issue, could you give this a look to make sure I captured everything with the right proxy args and syntax? TIA 🙏

@nchaulet nchaulet self-requested a review September 26, 2024 04:19
Copy link
Contributor

@lucabelluccini lucabelluccini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @jen-huang

I would double check with Elastic Agent team how --proxy-url <url> will be applied to the local config and which will be the affected "connections".

We always pass the --proxy-url <url> (and this is what I suggested in the issue 😓 ) but I think it might be needed to have separate scoped proxy settings...

@jen-huang
Copy link
Contributor Author

jen-huang commented Sep 26, 2024

I would double check with Elastic Agent team how --proxy-url <url> will be applied to the local config and which will be the affected "connections".

@lucabelluccini I clarified with that team that setting --proxy-url when installing Fleet Server is for establishing a connection with Elasticsearch. When used with a normal Elastic Agent installation, it is used for establishing a connection with the Fleet Server host.

TBH I was hoping for a second set of eyes on the curl and Invoke-WebRequest parameters for proxying download sources :D

@jen-huang jen-huang removed the request for review from nchaulet September 30, 2024 18:07
@jen-huang jen-huang requested a review from a team September 30, 2024 18:07
Copy link
Contributor

@criamico criamico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a small comment but otherwise LGTM

export const getDownloadBaseUrl = (downloadSource?: DownloadSource) => {
return downloadSource?.host.endsWith('/')
? downloadSource.host.substring(0, downloadSource.host.length - 1)
: 'https://artifacts.elastic.co/downloads';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: you could use the constant in

export const DEFAULT_DOWNLOAD_SOURCE_URI = 'https://artifacts.elastic.co/downloads/';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call, thank you!

@jen-huang jen-huang enabled auto-merge (squash) October 1, 2024 17:37
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Fleet Cypress Tests #4 / View agents list Agent status filter should filter on healthy (16 result)

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 1.7MB 1.7MB +1.3KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 171.2KB 171.4KB +113.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @jen-huang

@jen-huang jen-huang merged commit 121ff39 into elastic:main Oct 1, 2024
24 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11132154920

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.x Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 193922

Questions ?

Please refer to the Backport tool documentation

@jen-huang
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

jen-huang added a commit to jen-huang/kibana that referenced this pull request Oct 1, 2024
## Summary

Resolves elastic#184222. This PR:

- Ensures custom agent binary download source URI is respected where
ever it appears in command snippets, for both Fleet Server and Elastic
Agent install instructions
- If a proxy is associated with the source URI, the appropriate args are
added to the commands as well
- For `curl` commands, these are appended as `--proxy <url>` and
`--proxy-header "<key>-<value>"` (repeated for each header key/value
pair)
- For Windows, these are appended as `-Proxy "<url>"` and `-Headers
@{"<key1>"="<value1>"; "<key2>"="<value2>"}`
- Adjusts Fleet Server `./elastic-agent install` instructions so that:
- `--fleet-server-es` is the value of the data output host set on that
Fleet Server policy (must be ES output)
- If a proxy is associated with that ES output, the corresponding args
are appended:
`--proxy-url=<url>` and `--proxy-header "<key>-<value>"` (repeated for
each header key/value pair)

The internal API at `/internal/fleet/settings/enrollment` has new
properties added to its response to support this:
```
  fleet_server: {
    es_output?: Output;
    es_output_proxy?: FleetProxy;
  };
  download_source_proxy?: FleetProxy;
```

## Examples

**Fleet Server install with proxied custom download and proxied ES
host:**
```
curl -L -O https://my-agent-binary-source/beats/elastic-agent/elastic-agent-9.0.0-linux-x86_64.tar.gz --proxy http://some-proxy:1111 --proxy-header "Accept-Language=en-US,en;q=0.5" --proxy-header "Accept-Encoding=gzip, deflate, br"
tar xzvf elastic-agent-9.0.0-linux-x86_64.tar.gz
cd elastic-agent-9.0.0-linux-x86_64
sudo ./elastic-agent install \
  --fleet-server-es=http://localhost:9999 \
  --fleet-server-service-token=REDACTED \
  --fleet-server-policy=027a180f-2f4a-4dd1-a531-bf1d1d64179f \
  --fleet-server-port=8220 \
  --proxy-url=http://some-proxy:1111 \
  --proxy-header="Accept-Language=en-US,en;q=0.5" \
  --proxy-header="Accept-Encoding=gzip, deflate, br"
```
```
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri https://my-agent-binary-source/beats/elastic-agent/elastic-agent-9.0.0-windows-x86_64.zip -OutFile elastic-agent-9.0.0-windows-x86_64.zip -Proxy "http://some-proxy:1111" -Headers @{"Accept-Language"="en-US,en;q=0.5";"Accept-Encoding"="gzip, deflate, br"}
Expand-Archive .\elastic-agent-9.0.0-windows-x86_64.zip
cd elastic-agent-9.0.0-windows-x86_64
.\elastic-agent.exe install `
  --fleet-server-es=http://localhost:9999 `
  --fleet-server-service-token=REDACTED `
  --fleet-server-policy=027a180f-2f4a-4dd1-a531-bf1d1d64179f `
  --fleet-server-port=8220 `
  --proxy-url=http://some-proxy:1111 `
  --proxy-header="Accept-Language=en-US,en;q=0.5" `
  --proxy-header="Accept-Encoding=gzip, deflate, br"
```

**Elastic Agent install with proxied download source and proxied Fleet
Server host:**
```
curl -L -O https://my-agent-binary-source/beats/elastic-agent/elastic-agent-8.15.1-darwin-aarch64.tar.gz --proxy http://some-proxy:1111 --proxy-header "Accept-Language=en-US,en;q=0.5" --proxy-header "Accept-Encoding=gzip, deflate, br"
tar xzvf elastic-agent-8.15.1-darwin-aarch64.tar.gz
cd elastic-agent-8.15.1-darwin-aarch64
sudo ./elastic-agent install --url=https://localhost:2222 --enrollment-token=REDACTED --proxy-url=http://some-proxy:1111 --proxy-header "Accept-Language=en-US,en;q=0.5" --proxy-header "Accept-Encoding=gzip, deflate, br"
```
```
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri https://my-agent-binary-source/beats/elastic-agent/elastic-agent-8.15.1-windows-x86_64.zip -OutFile elastic-agent-8.15.1-windows-x86_64.zip -Proxy "http://some-proxy:1111" -Headers @{"Accept-Language"="en-US,en;q=0.5";"Accept-Encoding"="gzip, deflate, br"}
Expand-Archive .\elastic-agent-8.15.1-windows-x86_64.zip -DestinationPath .
cd elastic-agent-8.15.1-windows-x86_64
.\elastic-agent.exe install --url=https://localhost:2222 --enrollment-token=REDACTED --proxy-url=http://some-proxy:1111 --proxy-header "Accept-Language=en-US,en;q=0.5" --proxy-header "Accept-Encoding=gzip, deflate, br"
```

### To-do
- [x] Unit tests
- [x] API integration tests for enrollment settings endpoint

(cherry picked from commit 121ff39)

# Conflicts:
#	x-pack/plugins/fleet/server/types/rest_spec/settings.ts
jen-huang added a commit that referenced this pull request Oct 2, 2024
# Backport

This will backport the following commits from `main` to `8.x`:
- [[UII] Add proxy args to install snippets
(#193922)](#193922)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Jen
Huang","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-01T19:30:24Z","message":"[UII]
Add proxy args to install snippets (#193922)\n\n##
Summary\r\n\r\nResolves #184222. This PR:\r\n\r\n- Ensures custom agent
binary download source URI is respected where\r\never it appears in
command snippets, for both Fleet Server and Elastic\r\nAgent install
instructions\r\n- If a proxy is associated with the source URI, the
appropriate args are\r\nadded to the commands as well\r\n- For `curl`
commands, these are appended as `--proxy <url>` and\r\n`--proxy-header
\"<key>-<value>\"` (repeated for each header key/value\r\npair)\r\n- For
Windows, these are appended as `-Proxy \"<url>\"` and
`-Headers\r\n@{\"<key1>\"=\"<value1>\"; \"<key2>\"=\"<value2>\"}`\r\n-
Adjusts Fleet Server `./elastic-agent install` instructions so
that:\r\n- `--fleet-server-es` is the value of the data output host set
on that\r\nFleet Server policy (must be ES output)\r\n- If a proxy is
associated with that ES output, the corresponding args\r\nare
appended:\r\n`--proxy-url=<url>` and `--proxy-header \"<key>-<value>\"`
(repeated for\r\neach header key/value pair)\r\n\r\nThe internal API at
`/internal/fleet/settings/enrollment` has new\r\nproperties added to its
response to support this:\r\n```\r\n fleet_server: {\r\n es_output?:
Output;\r\n es_output_proxy?: FleetProxy;\r\n };\r\n
download_source_proxy?: FleetProxy;\r\n```\r\n\r\n##
Examples\r\n\r\n**Fleet Server install with proxied custom download and
proxied ES\r\nhost:**\r\n```\r\ncurl -L -O
https://my-agent-binary-source/beats/elastic-agent/elastic-agent-9.0.0-linux-x86_64.tar.gz
--proxy http://some-proxy:1111 --proxy-header
\"Accept-Language=en-US,en;q=0.5\" --proxy-header
\"Accept-Encoding=gzip, deflate, br\"\r\ntar xzvf
elastic-agent-9.0.0-linux-x86_64.tar.gz\r\ncd
elastic-agent-9.0.0-linux-x86_64\r\nsudo ./elastic-agent install \\\r\n
--fleet-server-es=http://localhost:9999 \\\r\n
--fleet-server-service-token=REDACTED \\\r\n
--fleet-server-policy=027a180f-2f4a-4dd1-a531-bf1d1d64179f \\\r\n
--fleet-server-port=8220 \\\r\n --proxy-url=http://some-proxy:1111
\\\r\n --proxy-header=\"Accept-Language=en-US,en;q=0.5\" \\\r\n
--proxy-header=\"Accept-Encoding=gzip, deflate,
br\"\r\n```\r\n```\r\n$ProgressPreference =
'SilentlyContinue'\r\nInvoke-WebRequest -Uri
https://my-agent-binary-source/beats/elastic-agent/elastic-agent-9.0.0-windows-x86_64.zip
-OutFile elastic-agent-9.0.0-windows-x86_64.zip -Proxy
\"http://some-proxy:1111\" -Headers
@{\"Accept-Language\"=\"en-US,en;q=0.5\";\"Accept-Encoding\"=\"gzip,
deflate, br\"}\r\nExpand-Archive
.\\elastic-agent-9.0.0-windows-x86_64.zip\r\ncd
elastic-agent-9.0.0-windows-x86_64\r\n.\\elastic-agent.exe install `\r\n
--fleet-server-es=http://localhost:9999 `\r\n
--fleet-server-service-token=REDACTED `\r\n
--fleet-server-policy=027a180f-2f4a-4dd1-a531-bf1d1d64179f `\r\n
--fleet-server-port=8220 `\r\n --proxy-url=http://some-proxy:1111 `\r\n
--proxy-header=\"Accept-Language=en-US,en;q=0.5\" `\r\n
--proxy-header=\"Accept-Encoding=gzip, deflate,
br\"\r\n```\r\n\r\n**Elastic Agent install with proxied download source
and proxied Fleet\r\nServer host:**\r\n```\r\ncurl -L -O
https://my-agent-binary-source/beats/elastic-agent/elastic-agent-8.15.1-darwin-aarch64.tar.gz
--proxy http://some-proxy:1111 --proxy-header
\"Accept-Language=en-US,en;q=0.5\" --proxy-header
\"Accept-Encoding=gzip, deflate, br\"\r\ntar xzvf
elastic-agent-8.15.1-darwin-aarch64.tar.gz\r\ncd
elastic-agent-8.15.1-darwin-aarch64\r\nsudo ./elastic-agent install
--url=https://localhost:2222 --enrollment-token=REDACTED
--proxy-url=http://some-proxy:1111 --proxy-header
\"Accept-Language=en-US,en;q=0.5\" --proxy-header
\"Accept-Encoding=gzip, deflate,
br\"\r\n```\r\n```\r\n$ProgressPreference =
'SilentlyContinue'\r\nInvoke-WebRequest -Uri
https://my-agent-binary-source/beats/elastic-agent/elastic-agent-8.15.1-windows-x86_64.zip
-OutFile elastic-agent-8.15.1-windows-x86_64.zip -Proxy
\"http://some-proxy:1111\" -Headers
@{\"Accept-Language\"=\"en-US,en;q=0.5\";\"Accept-Encoding\"=\"gzip,
deflate, br\"}\r\nExpand-Archive
.\\elastic-agent-8.15.1-windows-x86_64.zip -DestinationPath .\r\ncd
elastic-agent-8.15.1-windows-x86_64\r\n.\\elastic-agent.exe install
--url=https://localhost:2222 --enrollment-token=REDACTED
--proxy-url=http://some-proxy:1111 --proxy-header
\"Accept-Language=en-US,en;q=0.5\" --proxy-header
\"Accept-Encoding=gzip, deflate, br\"\r\n```\r\n\r\n### To-do\r\n- [x]
Unit tests\r\n- [x] API integration tests for enrollment settings
endpoint","sha":"121ff399672673844c5a92996c7a379894abeea8","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Fleet","v9.0.0","backport:prev-minor"],"number":193922,"url":"https://github.com/elastic/kibana/pull/193922","mergeCommit":{"message":"[UII]
Add proxy args to install snippets (#193922)\n\n##
Summary\r\n\r\nResolves #184222. This PR:\r\n\r\n- Ensures custom agent
binary download source URI is respected where\r\never it appears in
command snippets, for both Fleet Server and Elastic\r\nAgent install
instructions\r\n- If a proxy is associated with the source URI, the
appropriate args are\r\nadded to the commands as well\r\n- For `curl`
commands, these are appended as `--proxy <url>` and\r\n`--proxy-header
\"<key>-<value>\"` (repeated for each header key/value\r\npair)\r\n- For
Windows, these are appended as `-Proxy \"<url>\"` and
`-Headers\r\n@{\"<key1>\"=\"<value1>\"; \"<key2>\"=\"<value2>\"}`\r\n-
Adjusts Fleet Server `./elastic-agent install` instructions so
that:\r\n- `--fleet-server-es` is the value of the data output host set
on that\r\nFleet Server policy (must be ES output)\r\n- If a proxy is
associated with that ES output, the corresponding args\r\nare
appended:\r\n`--proxy-url=<url>` and `--proxy-header \"<key>-<value>\"`
(repeated for\r\neach header key/value pair)\r\n\r\nThe internal API at
`/internal/fleet/settings/enrollment` has new\r\nproperties added to its
response to support this:\r\n```\r\n fleet_server: {\r\n es_output?:
Output;\r\n es_output_proxy?: FleetProxy;\r\n };\r\n
download_source_proxy?: FleetProxy;\r\n```\r\n\r\n##
Examples\r\n\r\n**Fleet Server install with proxied custom download and
proxied ES\r\nhost:**\r\n```\r\ncurl -L -O
https://my-agent-binary-source/beats/elastic-agent/elastic-agent-9.0.0-linux-x86_64.tar.gz
--proxy http://some-proxy:1111 --proxy-header
\"Accept-Language=en-US,en;q=0.5\" --proxy-header
\"Accept-Encoding=gzip, deflate, br\"\r\ntar xzvf
elastic-agent-9.0.0-linux-x86_64.tar.gz\r\ncd
elastic-agent-9.0.0-linux-x86_64\r\nsudo ./elastic-agent install \\\r\n
--fleet-server-es=http://localhost:9999 \\\r\n
--fleet-server-service-token=REDACTED \\\r\n
--fleet-server-policy=027a180f-2f4a-4dd1-a531-bf1d1d64179f \\\r\n
--fleet-server-port=8220 \\\r\n --proxy-url=http://some-proxy:1111
\\\r\n --proxy-header=\"Accept-Language=en-US,en;q=0.5\" \\\r\n
--proxy-header=\"Accept-Encoding=gzip, deflate,
br\"\r\n```\r\n```\r\n$ProgressPreference =
'SilentlyContinue'\r\nInvoke-WebRequest -Uri
https://my-agent-binary-source/beats/elastic-agent/elastic-agent-9.0.0-windows-x86_64.zip
-OutFile elastic-agent-9.0.0-windows-x86_64.zip -Proxy
\"http://some-proxy:1111\" -Headers
@{\"Accept-Language\"=\"en-US,en;q=0.5\";\"Accept-Encoding\"=\"gzip,
deflate, br\"}\r\nExpand-Archive
.\\elastic-agent-9.0.0-windows-x86_64.zip\r\ncd
elastic-agent-9.0.0-windows-x86_64\r\n.\\elastic-agent.exe install `\r\n
--fleet-server-es=http://localhost:9999 `\r\n
--fleet-server-service-token=REDACTED `\r\n
--fleet-server-policy=027a180f-2f4a-4dd1-a531-bf1d1d64179f `\r\n
--fleet-server-port=8220 `\r\n --proxy-url=http://some-proxy:1111 `\r\n
--proxy-header=\"Accept-Language=en-US,en;q=0.5\" `\r\n
--proxy-header=\"Accept-Encoding=gzip, deflate,
br\"\r\n```\r\n\r\n**Elastic Agent install with proxied download source
and proxied Fleet\r\nServer host:**\r\n```\r\ncurl -L -O
https://my-agent-binary-source/beats/elastic-agent/elastic-agent-8.15.1-darwin-aarch64.tar.gz
--proxy http://some-proxy:1111 --proxy-header
\"Accept-Language=en-US,en;q=0.5\" --proxy-header
\"Accept-Encoding=gzip, deflate, br\"\r\ntar xzvf
elastic-agent-8.15.1-darwin-aarch64.tar.gz\r\ncd
elastic-agent-8.15.1-darwin-aarch64\r\nsudo ./elastic-agent install
--url=https://localhost:2222 --enrollment-token=REDACTED
--proxy-url=http://some-proxy:1111 --proxy-header
\"Accept-Language=en-US,en;q=0.5\" --proxy-header
\"Accept-Encoding=gzip, deflate,
br\"\r\n```\r\n```\r\n$ProgressPreference =
'SilentlyContinue'\r\nInvoke-WebRequest -Uri
https://my-agent-binary-source/beats/elastic-agent/elastic-agent-8.15.1-windows-x86_64.zip
-OutFile elastic-agent-8.15.1-windows-x86_64.zip -Proxy
\"http://some-proxy:1111\" -Headers
@{\"Accept-Language\"=\"en-US,en;q=0.5\";\"Accept-Encoding\"=\"gzip,
deflate, br\"}\r\nExpand-Archive
.\\elastic-agent-8.15.1-windows-x86_64.zip -DestinationPath .\r\ncd
elastic-agent-8.15.1-windows-x86_64\r\n.\\elastic-agent.exe install
--url=https://localhost:2222 --enrollment-token=REDACTED
--proxy-url=http://some-proxy:1111 --proxy-header
\"Accept-Language=en-US,en;q=0.5\" --proxy-header
\"Accept-Encoding=gzip, deflate, br\"\r\n```\r\n\r\n### To-do\r\n- [x]
Unit tests\r\n- [x] API integration tests for enrollment settings
endpoint","sha":"121ff399672673844c5a92996c7a379894abeea8"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193922","number":193922,"mergeCommit":{"message":"[UII]
Add proxy args to install snippets (#193922)\n\n##
Summary\r\n\r\nResolves #184222. This PR:\r\n\r\n- Ensures custom agent
binary download source URI is respected where\r\never it appears in
command snippets, for both Fleet Server and Elastic\r\nAgent install
instructions\r\n- If a proxy is associated with the source URI, the
appropriate args are\r\nadded to the commands as well\r\n- For `curl`
commands, these are appended as `--proxy <url>` and\r\n`--proxy-header
\"<key>-<value>\"` (repeated for each header key/value\r\npair)\r\n- For
Windows, these are appended as `-Proxy \"<url>\"` and
`-Headers\r\n@{\"<key1>\"=\"<value1>\"; \"<key2>\"=\"<value2>\"}`\r\n-
Adjusts Fleet Server `./elastic-agent install` instructions so
that:\r\n- `--fleet-server-es` is the value of the data output host set
on that\r\nFleet Server policy (must be ES output)\r\n- If a proxy is
associated with that ES output, the corresponding args\r\nare
appended:\r\n`--proxy-url=<url>` and `--proxy-header \"<key>-<value>\"`
(repeated for\r\neach header key/value pair)\r\n\r\nThe internal API at
`/internal/fleet/settings/enrollment` has new\r\nproperties added to its
response to support this:\r\n```\r\n fleet_server: {\r\n es_output?:
Output;\r\n es_output_proxy?: FleetProxy;\r\n };\r\n
download_source_proxy?: FleetProxy;\r\n```\r\n\r\n##
Examples\r\n\r\n**Fleet Server install with proxied custom download and
proxied ES\r\nhost:**\r\n```\r\ncurl -L -O
https://my-agent-binary-source/beats/elastic-agent/elastic-agent-9.0.0-linux-x86_64.tar.gz
--proxy http://some-proxy:1111 --proxy-header
\"Accept-Language=en-US,en;q=0.5\" --proxy-header
\"Accept-Encoding=gzip, deflate, br\"\r\ntar xzvf
elastic-agent-9.0.0-linux-x86_64.tar.gz\r\ncd
elastic-agent-9.0.0-linux-x86_64\r\nsudo ./elastic-agent install \\\r\n
--fleet-server-es=http://localhost:9999 \\\r\n
--fleet-server-service-token=REDACTED \\\r\n
--fleet-server-policy=027a180f-2f4a-4dd1-a531-bf1d1d64179f \\\r\n
--fleet-server-port=8220 \\\r\n --proxy-url=http://some-proxy:1111
\\\r\n --proxy-header=\"Accept-Language=en-US,en;q=0.5\" \\\r\n
--proxy-header=\"Accept-Encoding=gzip, deflate,
br\"\r\n```\r\n```\r\n$ProgressPreference =
'SilentlyContinue'\r\nInvoke-WebRequest -Uri
https://my-agent-binary-source/beats/elastic-agent/elastic-agent-9.0.0-windows-x86_64.zip
-OutFile elastic-agent-9.0.0-windows-x86_64.zip -Proxy
\"http://some-proxy:1111\" -Headers
@{\"Accept-Language\"=\"en-US,en;q=0.5\";\"Accept-Encoding\"=\"gzip,
deflate, br\"}\r\nExpand-Archive
.\\elastic-agent-9.0.0-windows-x86_64.zip\r\ncd
elastic-agent-9.0.0-windows-x86_64\r\n.\\elastic-agent.exe install `\r\n
--fleet-server-es=http://localhost:9999 `\r\n
--fleet-server-service-token=REDACTED `\r\n
--fleet-server-policy=027a180f-2f4a-4dd1-a531-bf1d1d64179f `\r\n
--fleet-server-port=8220 `\r\n --proxy-url=http://some-proxy:1111 `\r\n
--proxy-header=\"Accept-Language=en-US,en;q=0.5\" `\r\n
--proxy-header=\"Accept-Encoding=gzip, deflate,
br\"\r\n```\r\n\r\n**Elastic Agent install with proxied download source
and proxied Fleet\r\nServer host:**\r\n```\r\ncurl -L -O
https://my-agent-binary-source/beats/elastic-agent/elastic-agent-8.15.1-darwin-aarch64.tar.gz
--proxy http://some-proxy:1111 --proxy-header
\"Accept-Language=en-US,en;q=0.5\" --proxy-header
\"Accept-Encoding=gzip, deflate, br\"\r\ntar xzvf
elastic-agent-8.15.1-darwin-aarch64.tar.gz\r\ncd
elastic-agent-8.15.1-darwin-aarch64\r\nsudo ./elastic-agent install
--url=https://localhost:2222 --enrollment-token=REDACTED
--proxy-url=http://some-proxy:1111 --proxy-header
\"Accept-Language=en-US,en;q=0.5\" --proxy-header
\"Accept-Encoding=gzip, deflate,
br\"\r\n```\r\n```\r\n$ProgressPreference =
'SilentlyContinue'\r\nInvoke-WebRequest -Uri
https://my-agent-binary-source/beats/elastic-agent/elastic-agent-8.15.1-windows-x86_64.zip
-OutFile elastic-agent-8.15.1-windows-x86_64.zip -Proxy
\"http://some-proxy:1111\" -Headers
@{\"Accept-Language\"=\"en-US,en;q=0.5\";\"Accept-Encoding\"=\"gzip,
deflate, br\"}\r\nExpand-Archive
.\\elastic-agent-8.15.1-windows-x86_64.zip -DestinationPath .\r\ncd
elastic-agent-8.15.1-windows-x86_64\r\n.\\elastic-agent.exe install
--url=https://localhost:2222 --enrollment-token=REDACTED
--proxy-url=http://some-proxy:1111 --proxy-header
\"Accept-Language=en-US,en;q=0.5\" --proxy-header
\"Accept-Encoding=gzip, deflate, br\"\r\n```\r\n\r\n### To-do\r\n- [x]
Unit tests\r\n- [x] API integration tests for enrollment settings
endpoint","sha":"121ff399672673844c5a92996c7a379894abeea8"}}]}]
BACKPORT-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) release_note:fix Team:Fleet Team label for Observability Data Collection Fleet team v8.16.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Agent / Install snippets to include proxy parameter if specified in the policy
8 participants