[Fleet] Fix elastic-agent docker image path (#210008)

## Summary

Starting in 9.1-SNAPSHOT, the Elastic Agent image has moved from the
`beats` namespace to its own `elastic-agent` namespace in
docker.elastic.co. This PR updates a few places where the old path is in
use.

### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

- [ ] This was done with a generic find/replace across the Kibana
codebase. I did not test the changes extensively and made a few changes
outside of the Fleet codebase. Codeowners please be aware.
This commit is contained in:
Kyle Pollich 2025-02-11 16:04:03 -05:00 committed by GitHub
parent 00388ed2e1
commit 6df81592ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 36 additions and 16 deletions

View file

@ -49,7 +49,7 @@ export async function enrollAgent(
'-p',
'8220:8220',
'--rm',
`docker.elastic.co/beats/elastic-agent:${version}`,
`docker.elastic.co/elastic-agent/elastic-agent:${version}`,
],
{
shell: true,
@ -77,7 +77,7 @@ export async function enrollAgent(
'-e',
'FLEET_INSECURE=1',
'--rm',
`docker.elastic.co/beats/elastic-agent-complete:${version}`,
`docker.elastic.co/elastic-agent/elastic-agent-complete:${version}`,
],
{
stdio: 'inherit',

View file

@ -301,7 +301,7 @@ docker run --add-host host.docker.internal:host-gateway \
--env FLEET_ENROLL=1 --env FLEET_INSECURE=true\
--env FLEET_URL=https://localhost:8220 \
--env FLEET_ENROLLMENT_TOKEN=enrollment_token \
docker.elastic.co/beats/elastic-agent:8.13.0-SNAPSHOT # <-- Update this version as needed
docker.elastic.co/elastic-agent/elastic-agent:8.13.0-SNAPSHOT # <-- Update this version as needed
```
You can also use the [run_dockerized_agent.sh](./run_dockerized_elastic_agent.sh) script to make this process easier. This script will run a Docker container with Elastic Agent and enroll it to your local Fleet Server. You can also use it to run a Dockerized Fleet Server container if you don't need to develop Fleet Server locally.

View file

@ -5,6 +5,7 @@ Fleet is enabled for the observability and security serverless project types.
To run Elasticsearch and Kibana in serverless mode, the relevant commands are:
For the observability project type:
```bash
# Start Elasticsearch in serverless mode as an observability project
yarn es serverless --projectType=oblt --kill
@ -53,6 +54,7 @@ The `kibana.dev.yml` settings should be mostly the same as for stateful mode. Th
As noted above, the base path should not be set (`server.basePath` setting).
To enroll agents with a standalone Fleet Server set:
```yaml
xpack.fleet.internal.fleetServerStandalone: true
```
@ -103,7 +105,7 @@ docker run \
-e FLEET_ENROLL=1 \
-e FLEET_ENROLLMENT_TOKEN=<enrollment_token>== \
-e FLEET_INSECURE=1 \
--rm docker.elastic.co/beats/elastic-agent:<version>
--rm docker.elastic.co/elastic-agent/elastic-agent:<version>
```
## Troubleshooting

View file

@ -67,12 +67,14 @@ xpack.fleet.outputs:
[Multipass](https://multipass.run/) is a lightweight virtualization tool for running Ubuntu VMs. Follow the instructions at https://multipass.run/install to install Multipass on your local machine.
Advantages of running Elastic Agents on a VM include:
- More realistic setup.
- Ability to use the `elastic-agent` commands, e.g. `sudo elastic-agent status`, `sudo elastic-agent restart`...
- Agents can be upgraded.
- Elastic Defend can be installed.
To run a Fleet Server and agents on VMs, make sure the default output host defined in your `kibana.dev.yml` uses your local IP address (NB: using `localhost` can cause connection issues). For Mac users using a WiFi connection, the local IP address can be retrieved with:
```sh
ipconfig getifaddr en0
```
@ -85,6 +87,7 @@ In Fleet UI, these host URLs should be reflected in the Settings page:
### Running a Fleet Server
1\. Launch a Multipass instance for your Fleet Server:
```sh
multipass launch --name fleet-server --disk 10G --network en0
```
@ -94,11 +97,13 @@ Available options are detailed at https://multipass.run/docs/launch-command.
It is generally recommended to provide additional disk space (default 5G) for running Elastic Agents.
In addition, the `--network` option adds a network interface to the instance, in this case `en0`. This allows the Fleet Server instance to communicate with the enrolled agents via the wifi network interface. You can find out the IP address by running:
```sh
multipass list
```
Example output:
```sh
Name State IPv4 Image
fleet-server Running 192.168.1.1 Ubuntu 24.04 LTS
@ -108,6 +113,7 @@ fleet-server Running 192.168.1.1 Ubuntu 24.04 LTS
Copy the second IP address into the host URLs of the Fleet Server host in your `kibana.dev.yml`. Wait for Kibana to restart.
2\. Shell into the instance:
```sh
multipass shell fleet-server
```
@ -120,6 +126,7 @@ multipass shell fleet-server
![Fleet UI showing the Add Fleet Server flyout, step 2](./screenshots/vm_fleet_server_2.png)
5\. Before copying the install instructions, amend the download URL to suit the desired version and your host architecture:
- Because Multipass only supports the host's architecture, you may need to change `linux-x86_64` to `linux-arm64` (e.g. on M-series Macbooks).
- By default, the proposed version is the latest release. You can explore available versions at https://artifacts-api.elastic.co/v1/versions and then check out `https://artifacts-api.elastic.co/v1/versions/<version>/builds/latest` to find the relevant download URL. An even easier way is to use the API: the following command will output the download URL for the `elastic-agent-8.15.0-SNAPSHOT-linux-arm64.tar.gz` version:
```sh
@ -138,11 +145,13 @@ multipass shell fleet-server
![Fleet UI showing add agent on VM flow, step 1](./screenshots/vm_add_agent_1.png)
2\. Launch a Multipass instance, e.g.:
```sh
multipass launch --name agent1 --disk 10G
```
3\. Shell into the instance:
```sh
multipass shell agent1
```
@ -155,6 +164,7 @@ multipass shell agent1
### Gotchas
1\. The system clock within Multipass instances stops when the host computer is suspended (see https://askubuntu.com/questions/1486977/repeated-incorrect-time-in-multipass-clients-with-ubuntu-22-04). This can result in a running Elastic Agent being incorrectly "in the past" after your laptop was asleep for a while. The easiest fix is to restart all Multipass instances, which will reset their clocks:
```sh
multipass restart --all
```
@ -166,6 +176,7 @@ multipass restart --all
Official documentation: https://www.elastic.co/guide/en/fleet/current/elastic-agent-container.html
The main advantage of running Elastic Agents in a Docker container is a one command setup that can be easily be scripted (see [Using the `run_dockerized_agent.sh` script](#using-the-run_dockerized_agentsh-script) below). There are a few limitations, however, including:
- Agents cannot be upgraded.
- Elastic Defend cannot be installed.
@ -177,6 +188,7 @@ In Fleet UI, these host URLs should be reflected in the Settings page:
### Running a Fleet Server
With Docker running, launch your Fleet Server with:
```sh
docker run \
-e ELASTICSEARCH_HOST=http://host.docker.internal:9200 \
@ -188,8 +200,9 @@ docker run \
-e FLEET_SERVER_ENABLE=1 \
-e FLEET_SERVER_POLICY_ID=fleet-server-policy \
-p 8220:8220 \
--rm docker.elastic.co/beats/elastic-agent:<version>
--rm docker.elastic.co/elastic-agent/elastic-agent:<version>
```
where the version can be e.g. `8.13.3` or `8.15.0-SNAPSHOT`. You can explore the available versions at https://www.docker.elastic.co/r/beats/elastic-agent.
You can also check the list of available environment variables for the `docker run` command in the [elastic-agent source code](https://github.com/elastic/elastic-agent/blob/main/internal/pkg/agent/cmd/container.go#L66-L134).
@ -207,13 +220,14 @@ Once the container is running, it can be treated as a local process running on `
2\. Scroll down to the enrollment CLI steps and copy the enrollment token from the end of the `sudo ./elastic-agent install` command.
3\. Enroll the agent with:
```sh
docker run \
-e FLEET_URL=https://host.docker.internal:8220 \
-e FLEET_ENROLL=1 \
-e FLEET_ENROLLMENT_TOKEN=<enrollment_token> \
-e FLEET_INSECURE=1 \
--rm docker.elastic.co/beats/elastic-agent:<version>
--rm docker.elastic.co/elastic-agent/elastic-agent:<version>
```
After a short moment, the UI should confirm that the agent is enrolled and shipping data:
@ -224,17 +238,21 @@ Tip: if the agent enrolls but there is no incoming data, check the host URL of t
### Using the `run_dockerized_agent.sh` script
You can make either running a Fleet Server or enrolling an agent quicker by using the [run_dockerized_agent.sh](./run_dockerized_elastic_agent.sh) script:
- Copy the script place it somewhere convenient.
- Run `chmod +x` on it to make it executable.
- Update the version and the Kibana base path within the script.
Run a Fleet Server with:
```sh
./run_elastic_agent.sh fleet_server
```
And enroll an Elastic Agent with:
```sh
./run agent -e <enrollment token> -v <version> -t <tags>
```
where the version and tags are optional.

View file

@ -38,7 +38,7 @@ printArgs() {
else
echo "Received enrollment token: ${ENROLLMENT_TOKEN}"
fi
if [[ $TAGS != "" ]]; then
echo "Received tags: ${TAGS}"
fi
@ -62,7 +62,7 @@ if [[ $CMD == "fleet_server" ]]; then
-e FLEET_SERVER_POLICY_ID=${FLEET_SERVER_POLICY_ID} \
-e ELASTIC_AGENT_TAGS=${TAGS} \
-p 8220:8220 \
--rm docker.elastic.co/beats/elastic-agent:${ELASTIC_AGENT_VERSION}
--rm docker.elastic.co/elastic-agent/elastic-agent:${ELASTIC_AGENT_VERSION}
elif [[ $CMD == "agent" ]]; then
echo "Starting Elastic Agent container..."
@ -75,8 +75,8 @@ elif [[ $CMD == "agent" ]]; then
-e FLEET_ENROLLMENT_TOKEN=${ENROLLMENT_TOKEN} \
-e FLEET_INSECURE=1 \
-e ELASTIC_AGENT_TAGS=${TAGS} \
--rm docker.elastic.co/beats/elastic-agent:${ELASTIC_AGENT_VERSION}
--rm docker.elastic.co/elastic-agent/elastic-agent:${ELASTIC_AGENT_VERSION}
elif [[ $CMD == "help" ]]; then
echo "Usage: ./run_elastic_agent.sh <agent/fleet_server> -e <enrollment token> -v <version> -t <tags>"

View file

@ -36,7 +36,7 @@ spec:
# Uncomment if using hints feature
#initContainers:
# - name: k8s-templates-downloader
# image: docker.elastic.co/beats/elastic-agent:VERSION
# image: docker.elastic.co/elastic-agent/elastic-agent:VERSION
# command: ['bash']
# args:
# - -c
@ -48,7 +48,7 @@ spec:
# mountPath: /etc/elastic-agent/inputs.d
containers:
- name: elastic-agent
image: docker.elastic.co/beats/elastic-agent:VERSION
image: docker.elastic.co/elastic-agent/elastic-agent:VERSION
args: ["-c", "/etc/elastic-agent/agent.yml", "-e"]
env:
# The API Key with access privilleges to connect to Elasticsearch. https://www.elastic.co/guide/en/fleet/current/grant-access-to-elasticsearch.html#create-api-key-standalone-agent
@ -341,7 +341,7 @@ spec:
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: elastic-agent
image: docker.elastic.co/beats/elastic-agent:VERSION
image: docker.elastic.co/elastic-agent/elastic-agent:VERSION
env:
# Set to 1 for enrollment into Fleet server. If not set, Elastic Agent is run in standalone mode
- name: FLEET_ENROLL

View file

@ -40,7 +40,7 @@ export default function (providerContext: FtrProviderContext) {
});
apiKey = `${res.id}:${res.api_key}`;
agentImage = `docker.elastic.co/beats/elastic-agent:${await getLatestVersion()}`;
agentImage = `docker.elastic.co/elastic-agent/elastic-agent:${await getLatestVersion()}`;
log.info(agentImage);
await execa('docker', ['pull', agentImage]);
});

View file

@ -50,7 +50,7 @@ export class AgentManager extends Manager {
this.log.info('Running the agent');
const artifact = `docker.elastic.co/beats/elastic-agent:${await getLatestVersion()}`;
const artifact = `docker.elastic.co/elastic-agent/elastic-agent:${await getLatestVersion()}`;
this.log.info(artifact);
const args = [

View file

@ -33,7 +33,7 @@ export class FleetManager extends Manager {
this.requestOptions
);
const serviceToken = response.data.value;
const artifact = `docker.elastic.co/beats/elastic-agent:${await getLatestVersion()}`;
const artifact = `docker.elastic.co/elastic-agent/elastic-agent:${await getLatestVersion()}`;
this.log.info(artifact);
// default fleet server policy no longer created by default