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 stack provider for Elastic Cloud #1230

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0f98577
Add stack provider for Elastic Cloud
jsoriano Apr 21, 2023
8315709
Fix version
jsoriano Apr 21, 2023
8d7b1d7
Merge remote-tracking branch 'origin/main' into stack-cloud-provider
jsoriano May 22, 2023
ff03886
Upload GeoIP databases
jsoriano May 22, 2023
4cede7e
Replace GeoIP database in cloud deployment
jsoriano May 23, 2023
8298102
Start local agent connected to cloud
jsoriano May 23, 2023
1931b77
Create Agent policy
jsoriano May 24, 2023
0938e7a
Fix path to env file
jsoriano May 24, 2023
3a1643f
Retrieve Fleet Server url from Fleet API
jsoriano May 24, 2023
7f1450a
Merge remote-tracking branch 'origin/main' into stack-cloud-provider
jsoriano May 24, 2023
f71f8cb
Use facts directly in templates where possible
jsoriano May 24, 2023
ee3a31b
Some refactors
jsoriano May 24, 2023
6255827
Reduce size of deployment
jsoriano May 25, 2023
9b22f2c
Parameterize deployment
jsoriano May 25, 2023
4565592
Update deployments on stack up
jsoriano May 25, 2023
4864a3d
Use diferent compose project names per project
jsoriano May 25, 2023
42b95a7
Install zipped package
jsoriano May 25, 2023
a41b053
Merge remote-tracking branch 'origin/main' into stack-cloud-provider
jsoriano May 26, 2023
ed9e89d
Remove TODO
jsoriano May 26, 2023
c61f7db
Merge remote-tracking branch 'origin/main' into stack-cloud-provider
jsoriano Jul 12, 2023
74b5d1e
Merge remote-tracking branch 'origin/main' into stack-cloud-provider
jsoriano Jul 25, 2023
7a3f2f2
Merge remote-tracking branch 'origin/main' into stack-cloud-provider
jsoriano Jul 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func systemCommandAction(cmd *cobra.Command, args []string) error {

profile, err := cobraext.GetProfileFlag(cmd)
if err != nil {
return nil
return err
}

signal.Enable()
Expand Down
2 changes: 1 addition & 1 deletion cmd/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func upCommandAction(cmd *cobra.Command, args []string) error {

profile, err := cobraext.GetProfileFlag(cmd)
if err != nil {
return nil
return err
}

_, serviceName := filepath.Split(packageRoot)
Expand Down
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/boumenot/gocover-cobertura v1.2.0
github.com/cespare/xxhash/v2 v2.2.0
github.com/dustin/go-humanize v1.0.1
github.com/elastic/cloud-sdk-go v1.11.0
github.com/elastic/elastic-integration-corpus-generator-tool v0.5.0
github.com/elastic/go-elasticsearch/v7 v7.17.10
github.com/elastic/go-licenser v0.4.1
Expand All @@ -28,6 +29,7 @@ require (
github.com/mholt/archiver/v3 v3.5.1
github.com/olekukonko/tablewriter v0.0.5
github.com/pmezard/go-difflib v1.0.0
github.com/sethvargo/go-retry v0.2.4
github.com/shirou/gopsutil/v3 v3.23.6
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.4
Expand Down Expand Up @@ -56,6 +58,7 @@ require (
github.com/acomagu/bufpipe v1.0.4 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/creasty/defaults v1.7.0 // indirect
Expand All @@ -73,11 +76,16 @@ require (
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/analysis v0.21.1 // indirect
github.com/go-openapi/errors v0.20.3 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/loads v0.21.0 // indirect
github.com/go-openapi/runtime v0.23.0 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
github.com/go-openapi/strfmt v0.21.3 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/validate v0.20.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
Expand Down Expand Up @@ -120,6 +128,7 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nwaples/rardecode v1.1.3 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
Expand Down
244 changes: 244 additions & 0 deletions go.sum

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions internal/profile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fmt"
"os"
"path/filepath"
"strconv"
"strings"

"github.com/elastic/go-resource"
Expand Down Expand Up @@ -154,6 +155,15 @@ func (profile Profile) Config(name string, def string) string {
return v
}

// Config returns a configuration setting as integer, or its default if setting not found
func (profile Profile) ConfigInt(name string, def int) (int, error) {
v, found := profile.config.get(name)
if !found {
return def, nil
}
return strconv.Atoi(v)
}

// ErrNotAProfile is returned in cases where we don't have a valid profile directory
var ErrNotAProfile = errors.New("not a profile")

Expand Down
10 changes: 10 additions & 0 deletions internal/stack/_static/cloud-elastic-agent.env.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{ $version := fact "agent_version" }}
FLEET_ENROLL=1
FLEET_URL={{ fact "fleet_url" }}
KIBANA_FLEET_HOST={{ fact "kibana_host" }}
KIBANA_HOST={{ fact "kibana_host" }}
ELASTICSEARCH_USERNAME={{ fact "username" }}
ELASTICSEARCH_PASSWORD={{ fact "password" }}
{{ if not (semverLessThan $version "8.0.0") }}
FLEET_TOKEN_POLICY_NAME=Elastic-Agent (elastic-package)
{{ end }}
26 changes: 26 additions & 0 deletions internal/stack/_static/cloud-elastic-agent.yml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '2.3'
services:
elastic-agent:
image: "{{ fact "agent_image" }}"
healthcheck:
test: "elastic-agent status"
timeout: 2s
start_period: 360s
retries: 180
interval: 5s
hostname: docker-fleet-agent
env_file: "./cloud-elastic-agent.env"
volumes:
- type: bind
source: ../../../tmp/service_logs/
target: /tmp/service_logs/
# Mount service_logs under /run too as a testing workaround for the journald input (see elastic-package#1235).
- type: bind
source: ../../../tmp/service_logs/
target: /run/service_logs/

elastic-agent_is_ready:
image: tianon/true
depends_on:
elastic-agent:
condition: service_healthy
Loading