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

[Agent] Introduce mage demo command #17312

Merged
merged 9 commits into from
Apr 14, 2020

Conversation

michalpristas
Copy link
Contributor

@michalpristas michalpristas commented Mar 30, 2020

What does this PR do?

Introducing mage demo command, which runs a current agent in a container.
command first checks whether image with name elastic-agent-{commit} already exists and if not it prepares a build and create an image, then it runs the container
If docker image already exists it runs the image straight away.

Command needs to be run from within x-pack/agent directory

By default it will enroll to local kibana at locahost:5601. It will use default credentials.
To tweak this behavior use these env variables which will be passed to docker image (default values in square brackets):

FLEET_SETUP - if set to 1 fleet setup will be performed creating a fleet user [false]
FLEET_ADMIN_PASSWORD - used for new fleet user [elastic]
FLEET_ADMIN_USERNAME - used for new fleet user [changeme]
FLEET_CONFIG_ID - config related to new token [defaul]
FLEET_ENROLLMENT_TOKEN - existing enrollment token to be used for enroll
FLEET_TOKEN_NAME - token name for a token to be created
KIBANA_HOST - actual kibana host [http://localhost:5601]
KIBANA_PASSWORD - password for accessing kibana API [changeme]
KIBANA_USERNAME - username for accessing kibana API [elastic]

Why is it important?

To helps devs running an agent without need of tweaking anything.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/ingest-management (Project:fleet)

@ph
Copy link
Contributor

ph commented Apr 10, 2020

@michalpristas I've been trying to test this out locally without luck, I've started with a cleaned environment and I only get an issue that it cannot pull the elastic agent. I've run the following commands:

  • docker system prune -a
  • git reset --hard HEAD
  • git clean -fxd
  • mage demo

The result I get is:

>> Building using: cmd='build/mage-linux-amd64 golangCrossBuild', env=[CC=o64-clang, CXX=o64-clang++, GOARCH=amd64, GOARM=, GOOS=darwin, PLATFORM_ID=darwin-amd64]
>> Building using: cmd='build/mage-linux-amd64 buildGoDaemon', env=[CC=gcc, CXX=g++, GOARCH=amd64, GOARM=, GOOS=linux, PLATFORM_ID=linux-amd64]
>> Building using: cmd='build/mage-linux-amd64 golangCrossBuild', env=[CC=gcc, CXX=g++, GOARCH=386, GOARM=, GOOS=linux, PLATFORM_ID=linux-386]
/tmp/ccCnN3gJ.o: In function `main':
god.c:(.text+0x2e0): warning: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
god.c:(.text+0x279): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/tmp/ccOSMPL0.o: In function `main':
god.c:(.text+0x2a6): warning: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
god.c:(.text+0x23e): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
>> package: Building elastic-agent type=docker for platform=linux/amd64
>> package: Building elastic-agent type=tar.gz for platform=linux/amd64
>> package: Building elastic-agent type=tar.gz for platform=linux/386
Unable to find image 'elastic-agent:latest' locally
docker: Error response from daemon: pull access denied for elastic-agent, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
Error: running "docker run --network host -e FLEET_ENROLL=1 elastic-agent" failed with exit code 125

@ph ph self-requested a review April 10, 2020 12:40
@ph
Copy link
Contributor

ph commented Apr 10, 2020

I also did a double check, I do not have anything set or customized in my docker environment, I am running it with the default options.

Copy link
Contributor

@ph ph left a comment

Choose a reason for hiding this comment

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

LGTM, not sure over the weekend what fixed my dev env.. :/

@ph ph added the needs_backport PR is waiting to be backported to other branches. label Apr 14, 2020
@michalpristas michalpristas merged commit 9557fe1 into elastic:master Apr 14, 2020
michalpristas added a commit that referenced this pull request Apr 15, 2020
Cherry-pick #17312 to 7.x: [Agent] Introduce mage demo command #17721
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement needs_backport PR is waiting to be backported to other branches.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants