Skip to content

Add serverless provider#1374

Merged
mrodm merged 66 commits into
elastic:mainfrom
mrodm:add_provider
Sep 7, 2023
Merged

Add serverless provider#1374
mrodm merged 66 commits into
elastic:mainfrom
mrodm:add_provider

Conversation

@mrodm

@mrodm mrodm commented Jul 28, 2023

Copy link
Copy Markdown
Contributor

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

mrodm commented Aug 16, 2023

Copy link
Copy Markdown
Contributor Author

/test

@elasticmachine

Copy link
Copy Markdown
Contributor

💚 Build Succeeded

History

cc @mrodm

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

@mrodm mrodm Aug 23, 2023

Copy link
Copy Markdown
Contributor Author

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

mrodm commented Sep 6, 2023

Copy link
Copy Markdown
Contributor Author

buildkite test this

1 similar comment
@mrodm

mrodm commented Sep 6, 2023

Copy link
Copy Markdown
Contributor Author

buildkite test this

@mrodm

mrodm commented Sep 6, 2023

Copy link
Copy Markdown
Contributor Author

/test

@jsoriano jsoriano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great job here 🚀

Comment thread internal/profile/_static/config.yml.example Outdated
Comment thread internal/serverless/client.go Outdated
Comment thread internal/serverless/client.go Outdated
host := os.Getenv(hostEnvName)
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
Copy Markdown
Contributor

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.

@mrodm mrodm Sep 7, 2023

Copy link
Copy Markdown
Contributor Author

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)

Comment thread internal/stack/serverless.go Outdated
@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
Copy Markdown
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.

@jsoriano jsoriano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! 🌻

@mrodm

mrodm commented Sep 7, 2023

Copy link
Copy Markdown
Contributor Author

buildkite test this

@elasticmachine

Copy link
Copy Markdown
Contributor

💚 Build Succeeded

History

cc @mrodm

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