Skip to content

Commit

Permalink
Remove elastic-agent directory (#12)
Browse files Browse the repository at this point in the history
* move directory

* fix mage cmd

* add missing

* licence header

* licence header

* licence

* fix check

* mage check fix

* fmt

* mage fmt update

* tests

* fix tests

* skip flaky test

* skip tests
  • Loading branch information
narph committed Mar 3, 2022
1 parent f92b169 commit e1baeee
Show file tree
Hide file tree
Showing 607 changed files with 2,341 additions and 3,351 deletions.
6 changes: 3 additions & 3 deletions .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pipeline {
steps {
withGithubNotify(context: "Lint") {
withMageEnv(){
dir("${BASE_DIR}/elastic-agent"){
dir("${BASE_DIR}"){
cmd(label: 'check license, lint', script: 'mage check')
cmd(label: 'update', script: 'mage update')
}
Expand Down Expand Up @@ -65,7 +65,7 @@ pipeline {
deleteDir()
unstash 'source'
withMageEnv(){
dir("${BASE_DIR}/elastic-agent"){
dir("${BASE_DIR}"){
cmd(label: 'Go build', script: 'mage build')
}
}
Expand All @@ -76,7 +76,7 @@ pipeline {
steps {
withGithubNotify(context: "Test-${PLATFORM}") {
withMageEnv(){
dir("${BASE_DIR}/elastic-agent"){
dir("${BASE_DIR}"){
cmd(label: 'Go unitTest', script: 'mage unitTest')
}
}
Expand Down
30 changes: 24 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/build
/*/*.template*.json
**/html_docs
elastic-agent/data
elastic-agent/pkg/agent/operation/tests/downloads
data
internal/pkg/agent/operation/tests/downloads

# Files
.DS_Store
Expand All @@ -19,10 +19,8 @@ beat.db
*.keystore
go_env.properties
mage_output_file.go
elastic-agent/elastic_agent
elastic-agent/fleet.yml
elastic-agent/pkg/agent/operation/tests/scripts/configurable-1.0-darwin-x86_64/configurable
elastic-agent/pkg/agent/operation/tests/scripts/serviceable-1.0-darwin-x86_64/serviceable
elastic_agent
fleet.yml

# Editor swap files
*.swp
Expand All @@ -44,3 +42,23 @@ elastic-agent/pkg/agent/operation/tests/scripts/serviceable-1.0-darwin-x86_64/se

# Files generated with the bump version automations
*.bck


# agent
build/
elastic-agent
elastic-agent.dev.yml
elastic-agent.yml.*
fleet.yml
fleet.yml.lock
fleet.yml.old
internal/pkg/agent/operation/tests/scripts/short--1.0.yml
internal/pkg/agent/operation/tests/scripts/configurable-1.0-darwin-x86/configurable
internal/pkg/agent/operation/tests/scripts/servicable-1.0-darwin-x86/configurable
internal/pkg/agent/transpiler/tests/exec-1.0-darwin-x86_64/exec
internal/pkg/agent/operation/tests/scripts/configurable-1.0-darwin-x86_64/configurable
internal/pkg/agent/operation/tests/scripts/serviceable-1.0-darwin-x86_64/serviceable
internal/pkg/agent/application/fleet.yml

# VSCode
/.vscode
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
86 changes: 83 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,84 @@
[![Build Status](https://internal-ci.elastic.co/job/elastic-agent/job/elastic-agent-poc-mbp/job/main/badge/icon)](https://internal-ci.elastic.co/job/elastic-agent/job/elastic-agent-poc-mbp/job/main/)
# POC Elastic Agent
# Elastic Agent developer docs

T
The source files for the general Elastic Agent documentation are currently stored
in the [observability-docs](https://github.com/elastic/observability-docs) repo. The following docs are only focused on getting developers started building code for Elastic Agent.

## Testing

Prerequisites:
- installed [mage](https://github.com/magefile/mage)

### Testing docker container

Running Elastic Agent in a docker container is a common use case. To build the Elastic Agent and create a docker image run the following command:

```
DEV=true SNAPSHOT=true PLATFORMS=linux/amd64 TYPES=docker mage package
```

If you are in the 7.13 branch, this will create the `docker.elastic.co/beats/elastic-agent:7.13.0-SNAPSHOT` image in your local environment. Now you can use this to for example test this container with the stack in elastic-package:

```
elastic-package stack up --version=7.13.0-SNAPSHOT -v
```

Please note that the docker container is built in both standard and 'complete' variants.
The 'complete' variant contains extra files, like the chromium browser, that are too large
for the standard variant.

### Testing Elastic Agent on Kubernetes

#### Prerequisites
- create kubernetes cluster using kind, check [here](https://github.com/elastic/beats/blob/master/metricbeat/module/kubernetes/_meta/test/docs/README.md) for details
- deploy kube-state-metrics, check [here](https://github.com/elastic/beats/blob/master/metricbeat/module/kubernetes/_meta/test/docs/README.md) for details
- deploy required infrastructure:
- for elastic agent in standalone mode: EK stack or use [elastic cloud](https://cloud.elastic.co), check [here](https://github.com/elastic/beats/blob/master/metricbeat/module/kubernetes/_meta/test/docs/README.md) for details
- for managed mode: use [elastic cloud](https://cloud.elastic.co) or bring up the stack on docker and then connect docker network with kubernetes kind nodes:
```
elastic-package stack up -d -v
docker network connect elastic-package-stack_default <kind_container_id>
```

1. Build elastic-agent:
```bash
cd x-pack/elastic-agent
DEV=true PLATFORMS=linux/amd64 TYPES=docker mage package
```
2. Build docker image:
```bash
cd build/package/elastic-agent/elastic-agent-linux-amd64.docker/docker-build
docker build -t custom-agent-image .
```
3. Load this image in your kind cluster:
```
kind load docker-image custom-agent-image:latest
```
4. Deploy agent with that image:
- download all-in-ome manifest for elastic-agent in standalone or managed mode, change version if needed
```
ELASTIC_AGENT_VERSION="8.0"
ELASTIC_AGENT_MODE="standalone" # ELASTIC_AGENT_MODE="managed"
curl -L -O https://raw.githubusercontent.com/elastic/beats/${ELASTIC_AGENT_VERSION}/deploy/kubernetes/elastic-agent-${ELASTIC_AGENT_MODE}-kubernetes.yaml
```
- Modify downloaded manifest:
- change image name to the one, that was created in the previous step and add `imagePullPolicy: Never`:
```
containers:
- name: elastic-agent
image: custom-agent-image:latest
imagePullPolicy: Never
```
- set environment variables accordingly to the used setup.
Elastic-agent in standalone mode: set `ES_USERNAME`, `ES_PASSWORD`,`ES_HOST`.
Elastic-agent in managed mode: set `FLEET_URL` and `FLEET_ENROLLMENT_TOKEN`.
- create
```
kubectl apply -f elastic-agent-${ELASTIC_AGENT_MODE}-kubernetes.yaml
```
5. Check status of elastic-agent:
```
kubectl -n kube-system get pods -l app=elastic-agent
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 3 additions & 16 deletions dev-tools/cmd/license/license_generate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 3 additions & 16 deletions dev-tools/mage/build.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package mage

Expand Down
41 changes: 8 additions & 33 deletions dev-tools/mage/check.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package mage

Expand Down Expand Up @@ -189,24 +176,12 @@ func GoVet() error {
// CheckLicenseHeaders checks license headers in .go files.
func CheckLicenseHeaders() error {
fmt.Println(">> fmt - go-licenser: Checking for missing headers")

mg.Deps(InstallGoLicenser)

var license string
switch BeatLicense {
case "ASL2", "ASL 2.0":
license = "ASL2"
case "Elastic", "Elastic License":
license = "Elastic"
default:
return errors.Errorf("unknown license type %v", BeatLicense)
}

licenser := gotool.Licenser
return licenser(licenser.Check(), licenser.License(license))
}




return licenser(
licenser.Check(),
licenser.License("Elastic"),
)

}
19 changes: 3 additions & 16 deletions dev-tools/mage/clean.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package mage

Expand Down
19 changes: 3 additions & 16 deletions dev-tools/mage/common.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package mage

Expand Down
19 changes: 3 additions & 16 deletions dev-tools/mage/common_test.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package mage

Expand Down
22 changes: 4 additions & 18 deletions dev-tools/mage/config.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package mage

Expand Down Expand Up @@ -68,6 +55,7 @@ type ConfigFileParams struct {
Short, Reference, Docker ConfigParams
}

// ConfigParams defines config param template
type ConfigParams struct {
Template string
Deps []interface{}
Expand Down Expand Up @@ -216,5 +204,3 @@ func makeHeading(title, separator string) string {
rightEquals := leftEquals + len(title)%2
return "# " + strings.Repeat(separator, leftEquals) + " " + title + " " + strings.Repeat(separator, rightEquals)
}


19 changes: 3 additions & 16 deletions dev-tools/mage/copy.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package mage

Expand Down
Loading

0 comments on commit e1baeee

Please sign in to comment.