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

Add serverless provider #1374

Merged
merged 66 commits into from
Sep 7, 2023
Merged

Add serverless provider #1374

merged 66 commits into from
Sep 7, 2023

Conversation

mrodm
Copy link
Contributor

@mrodm mrodm commented Jul 28, 2023

This PR adds a new provider to create Serverless projects.

It requires to set these two environment variables :

  • EC_API_KEY
  • EC_HOST

Notes:

  • In pipeline tests, Geo IP field keys have been skipped
    • It cannot be set a specific GeoIP database to make the test stable.
  • A local agent is started locally (using docker-compose). This agent is configured and connected to the new project.
    • As done locally, if elastic-agent starts to fail, it is retried once

Tested with the following packages from integrations repository:

  • elastic_package_registry
  • nginx
  • apache
  • haproxy
  • system
  • mysql
  • squid
  • gcp
  • tomcat
  • zookeeper
  • winlog
  • zoom
  • sql_input
  • redis
  • aws (just asset and pipeline tests)

How to test

export EC_API_KEY="xx"
# if not defined EC_HOST, it will be used the default value
export EC_HOST="xx"

elastic-package profiles create serverless --from default
elastic-package profiles use serverless

# check that this new profile is selected
elastic-package profiles list

# Boot up a new project and check its status
elastic-package stack up -v -d --version 8.9.0 --provider serverless
elastic-package stack status

# from the package folder install or test
elastic-package install
elastic-package test -v

# Delete the project
elastic-package install down -v

@mrodm mrodm self-assigned this Jul 28, 2023
@mrodm mrodm force-pushed the add_provider branch 2 times, most recently from 601eec1 to d0f9a9b Compare July 28, 2023 15:52
fleet server endpoint is built based on the elasticsearch endpoint

fix creation
@mrodm
Copy link
Contributor Author

mrodm commented Aug 16, 2023

/test

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @mrodm

internal/stack/serverless.go Outdated Show resolved Hide resolved
Comment on lines -21 to -22
var observedServices = []string{"elasticsearch", elasticAgentService, fleetServerService, "kibana", "package-registry"}

Copy link
Contributor Author

@mrodm mrodm Aug 23, 2023

Choose a reason for hiding this comment

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

Now dump and status would be getting the services directly from the docker daemon. Not all these services are available when serverless provider is used.

These containers are obtained from here:
https://github.com/elastic/elastic-package/pull/1374/files#diff-b4efb1ac558d15d3077525cb9be59dce12ee723a4749253e9ca7cc860419f1f8R401-R462

@mrodm mrodm requested a review from jsoriano September 5, 2023 13:12
@mrodm
Copy link
Contributor Author

mrodm commented Sep 6, 2023

buildkite test this

1 similar comment
@mrodm
Copy link
Contributor Author

mrodm commented Sep 6, 2023

buildkite test this

@mrodm
Copy link
Contributor Author

mrodm commented Sep 6, 2023

/test

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

Great job here 🚀

internal/profile/_static/config.yml.example Outdated Show resolved Hide resolved
internal/serverless/client.go Outdated Show resolved Hide resolved
if host == "" {
return nil, fmt.Errorf("unable to obtain value from %s environment variable", hostEnvName)
logger.Debugf("Using default host URL: %s", defaultHostURL)
Copy link
Member

Choose a reason for hiding this comment

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

Nit. Maybe we can print in any case what endpoint is used.

Copy link
Contributor Author

@mrodm mrodm Sep 7, 2023

Choose a reason for hiding this comment

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

Moved this logger.Debug after creating the client with all the options.

I also ensured that environment variables (EC_HOST) has preference over the configuration set in the profile (e.g. ~/.elastic-package/profiles/serverless/config.yml)

internal/stack/serverless.go Outdated Show resolved Hide resolved
@mrodm mrodm requested a review from jsoriano September 7, 2023 08:21
Comment on lines +56 to +59
host := os.Getenv(elasticCloudEndpointEnv)
if host != "" {
c.host = host
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there is an environment variable defined it would have preference over the configuration set in the profile.

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

LGTM! 🌻

@mrodm
Copy link
Contributor Author

mrodm commented Sep 7, 2023

buildkite test this

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @mrodm

@mrodm mrodm merged commit 9d80c6c into elastic:main Sep 7, 2023
1 check passed
@mrodm mrodm deleted the add_provider branch September 7, 2023 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants