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

Allow setting ES api key via env variable in container mode #5536

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

swiatekm
Copy link
Contributor

@swiatekm swiatekm commented Sep 12, 2024

What does this PR do?

Remove defaults for username and password when running in container mode, and also allow api_key to be set in that mode via the ELASTICSEARCH_API_KEY environment variable.

Note that the first of these changes is breaking. I've added two separate changelog entries to make this clear.

Why is it important?

It's very useful for users to be able to use an ES api key for authentication without needing to override the whole config file.

Checklist

  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

Disruptive User Impact

This is a breaking change for users who rely on the default username and password in container mode. These users will need to explicitly set these values after this change is rolled out. After the upgrade, the agent will simply fail to start, and will complain about lack of authentication credentials.

How to test this PR locally

DEV=true SNAPSHOT=true EXTERNAL=true PACKAGES=docker mage package
docker run -e ELASTICSEARCH_API_KEY="***" -e ELASTICSEARCH_HOSTS="***" --rm docker.elastic.co/beats/elastic-agent-complete:9.0.0-SNAPSHOT

This should successfully start if the host and api key are valid.

Related issues

Closes #97.

Copy link
Contributor

mergify bot commented Sep 12, 2024

This pull request does not have a backport label. Could you fix it @swiatekm? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label to automatically backport to the 8./d branch. /d is the digit

Copy link
Contributor

mergify bot commented Sep 12, 2024

backport-v8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label and remove the backport-8.x label.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Sep 12, 2024
@swiatekm swiatekm added backport-skip and removed backport-8.x Automated backport to the 8.x branch with mergify labels Sep 12, 2024
@jlind23
Copy link
Contributor

jlind23 commented Sep 19, 2024

@ycombinator @nimarezainia if this is considered a breaking shouldn't make it land only in 9.x?

@swiatekm
Copy link
Contributor Author

@jlind23 that was my intent, though I believe @cmacknz mentioned wanting to consider it for 8.x as well.

FYI, I'm waiting for E2E tests to be successfully runnable on this change before submitting it properly.

@jlind23
Copy link
Contributor

jlind23 commented Sep 19, 2024

Thanks @swiatekm! @cmacknz do we really need it for 8.x?

FYI, I'm waiting for E2E tests to be successfully runnable on this change before submitting it properly.

This should be shortly solved probably tomorrow EOD the latest.

Also remove defaults for username and password set this way.
@swiatekm swiatekm marked this pull request as ready for review September 20, 2024 13:47
@swiatekm swiatekm requested a review from a team as a code owner September 20, 2024 13:47
@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Sep 20, 2024
@elasticmachine
Copy link
Contributor

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

Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

swiatekm added a commit to elastic/ingest-docs that referenced this pull request Sep 30, 2024
This is to bring the docs in line with the change in
elastic/elastic-agent#5536.
swiatekm added a commit to elastic/ingest-docs that referenced this pull request Sep 30, 2024
This is to bring the docs in line with the change in
elastic/elastic-agent#5536.
@jlind23
Copy link
Contributor

jlind23 commented Sep 30, 2024

@swiatekm Are we good to merge this in 9.0?
cc @ycombinator

@swiatekm
Copy link
Contributor Author

@swiatekm Are we good to merge this in 9.0? cc @ycombinator

I think so. I considered adding an E2E test for it, but it ended up being a lot of setup for such a trivial check.

@ycombinator
Copy link
Contributor

Yes, this is a breaking change and is OK to merge (only) in 9.0. @swiatekm go ahead and merge whenever you get the chance.

@swiatekm swiatekm merged commit 218c984 into main Oct 1, 2024
10 checks passed
@swiatekm swiatekm deleted the feat/container-credentials branch October 1, 2024 08:43
swiatekm added a commit to elastic/ingest-docs that referenced this pull request Oct 2, 2024
This is to bring the docs in line with the change in
elastic/elastic-agent#5536.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

elastic-agent container output API key support
6 participants