Skip to content

Commit

Permalink
Add serverless flag to stack up
Browse files Browse the repository at this point in the history
The idea behind this pull request is to be able to run a `serverless` stack of Elasticsearch with the following command:

```
elastic-package stack up --version=8.8.0-SNAPSHOT -v --serverless
```

I'm opening this PR as draft as I have a few questions on how to implement it best.
  • Loading branch information
ruflin committed Apr 24, 2023
1 parent cb10ae3 commit 7d823a9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cmd/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ func setupStackCommand() *cobraext.Command {
return cobraext.FlagParsingError(err, cobraext.StackVersionFlagName)
}

/*serverless, err := cmd.Flags().GetString(cobraext.ServerlessFlagName)
if err != nil {
return cobraext.FlagParsingError(err, cobraext.ServerlessFlagName)
}*/

profile, err := getProfileFlag(cmd)
if err != nil {
return err
Expand Down
3 changes: 3 additions & 0 deletions internal/cobraext/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ const (
ZipPackageFilePathFlagShorthand = "z"
ZipPackageFilePathFlagDescription = "path to the zip package file (*.zip)"

ServerlessFlagName = "serverless"
ServerlessFlagDescription = "serverless flag (true or false)"

// To be removed promote commands flags
DirectionFlagName = "direction"
DirectionFlagDescription = "promotion direction"
Expand Down
3 changes: 2 additions & 1 deletion internal/stack/_static/docker-compose-stack.yml.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{ $username := fact "username" }}
{{ $password := fact "password" }}
{{ $serverless := fact "serverless" }}
version: '2.3'
services:
elasticsearch:
Expand All @@ -9,7 +10,7 @@ services:
start_period: 300s
interval: 5s
environment:
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
- "ES_JAVA_OPTS=-Xms1g -Xmx1g -Des.serverless={{ $serverless }}"
- "ELASTIC_PASSWORD={{ $password }}"
volumes:
- "./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml"
Expand Down
4 changes: 4 additions & 0 deletions internal/stack/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const (

elasticsearchUsername = "elastic"
elasticsearchPassword = "changeme"

serverless = "false"
)

var (
Expand Down Expand Up @@ -118,6 +120,8 @@ func applyResources(profile *profile.Profile, stackVersion string) error {
"username": elasticsearchUsername,
"password": elasticsearchPassword,

"serverless": serverless,

"geoip_dir": profile.Config("stack.geoip_dir", "./ingest-geoip"),
})

Expand Down

0 comments on commit 7d823a9

Please sign in to comment.