-
Notifications
You must be signed in to change notification settings - Fork 108
migrate fleet integration_policy to framework, fix secret churn #797
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,6 @@ jobs: | |
xpack.security.enabled: true | ||
xpack.security.authc.api_key.enabled: true | ||
xpack.security.authc.token.enabled: true | ||
xpack.security.http.ssl.enabled: false | ||
xpack.watcher.enabled: true | ||
xpack.license.self_generated.type: trial | ||
repositories.url.allowed_urls: https://example.com/* | ||
|
@@ -80,10 +79,28 @@ jobs: | |
ELASTICSEARCH_USERNAME: ${{ env.KIBANA_SYSTEM_USERNAME }} | ||
ELASTICSEARCH_PASSWORD: ${{ env.KIBANA_SYSTEM_PASSWORD }} | ||
XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY: a7a6311933d3503b89bc2dbc36572c33a6c10925682e591bffcab6911c06786d | ||
# LOGGING_ROOT_LEVEL: debug | ||
# LOGGING_ROOT_LEVEL: debug | ||
ports: | ||
- 5601:5601 | ||
options: --health-cmd="curl http://localhost:5601/api/status" --health-interval=10s --health-timeout=5s --health-retries=10 | ||
fleet: | ||
image: docker.elastic.co/beats/elastic-agent:${{ matrix.version }} | ||
env: | ||
SERVER_NAME: fleet | ||
FLEET_ENROLL: "1" | ||
FLEET_URL: https://fleet:8220 | ||
FLEET_INSECURE: "true" | ||
FLEET_SERVER_ENABLE: "1" | ||
FLEET_SERVER_POLICY_ID: fleet-server | ||
FLEET_SERVER_ELASTICSEARCH_HOST: http://elasticsearch:9200 | ||
FLEET_SERVER_ELASTICSEARCH_INSECURE: "true" | ||
FLEET_SERVER_INSECURE_HTTP: "true" | ||
KIBANA_HOST: http://kibana:5601 | ||
KIBANA_FLEET_SETUP: "1" | ||
KIBANA_FLEET_PASSWORD: ${{ env.ELASTIC_PASSWORD }} | ||
ports: | ||
- 8220:8220 | ||
options: --restart="unless-stopped" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To test for secret storage, an actual fleet server is necessary. It'll fail until the kibana password is set, so keep restarting it. |
||
|
||
timeout-minutes: 15 | ||
strategy: | ||
|
@@ -123,8 +140,6 @@ jobs: | |
- name: Setup Kibana user | ||
run: make set-kibana-password | ||
env: | ||
ELASTICSEARCH_ENDPOINTS: "http://localhost:9200" | ||
ELASTICSEARCH_USERNAME: "elastic" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused arguments in this makefile directive |
||
ELASTICSEARCH_PASSWORD: ${{ env.ELASTIC_PASSWORD }} | ||
KIBANA_SYSTEM_USERNAME: ${{ env.KIBANA_SYSTEM_USERNAME }} | ||
KIBANA_SYSTEM_PASSWORD: ${{ env.KIBANA_SYSTEM_PASSWORD }} | ||
|
@@ -134,10 +149,17 @@ jobs: | |
run: |- | ||
echo "apikey=$(make create-es-api-key | jq -r .encoded)" >> "$GITHUB_OUTPUT" | ||
env: | ||
ELASTICSEARCH_ENDPOINTS: "http://localhost:9200" | ||
ELASTICSEARCH_USERNAME: "elastic" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused arguments in this makefile directive |
||
ELASTICSEARCH_PASSWORD: ${{ env.ELASTIC_PASSWORD }} | ||
|
||
- id: setup-fleet | ||
name: Setup Fleet | ||
if: matrix.version == '8.10.3' || matrix.version == '8.11.4' || matrix.version == '8.12.2' || matrix.version == '8.13.4' || matrix.version == '8.14.3' || matrix.version == '8.15.0' | ||
run: |- | ||
make setup-kibana-fleet | ||
env: | ||
ELASTICSEARCH_PASSWORD: ${{ env.ELASTIC_PASSWORD }} | ||
FLEET_NAME: "fleet" | ||
|
||
- id: force-install-synthetics | ||
name: Force install synthetics | ||
if: matrix.version == '8.14.3' || matrix.version == '8.15.0' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,11 @@ KIBANA_SYSTEM_USERNAME ?= kibana_system | |
KIBANA_SYSTEM_PASSWORD ?= password | ||
KIBANA_API_KEY_NAME ?= kibana-api-key | ||
|
||
FLEET_NAME ?= terraform-elasticstack-fleet | ||
FLEET_ENDPOINT ?= https://$(FLEET_NAME):8220 | ||
|
||
SOURCE_LOCATION ?= $(shell pwd) | ||
, := , | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. escaping JSON commas in the setup fleet payloads. This makes me sad, but not much of a better way to do it when wrapping in the retry func |
||
|
||
export GOBIN = $(shell pwd)/bin | ||
|
||
|
@@ -72,7 +76,7 @@ retry = until [ $$(if [ -z "$$attempt" ]; then echo -n "0"; else echo -n "$$atte | |
# To run specific test (e.g. TestAccResourceActionConnector) execute `make docker-testacc TESTARGS='-run ^TestAccResourceActionConnector$$'` | ||
# To enable tracing (or debugging), execute `make docker-testacc TF_LOG=TRACE` | ||
.PHONY: docker-testacc | ||
docker-testacc: docker-elasticsearch docker-kibana ## Run acceptance tests in the docker container | ||
docker-testacc: docker-elasticsearch docker-kibana docker-fleet ## Run acceptance tests in the docker container | ||
@ docker run --rm \ | ||
-e ELASTICSEARCH_ENDPOINTS="$(ELASTICSEARCH_ENDPOINTS)" \ | ||
-e KIBANA_ENDPOINT="$(KIBANA_ENDPOINT)" \ | ||
|
@@ -163,6 +167,30 @@ docker-kibana-with-tls: docker-network docker-elasticsearch set-kibana-password | |
docker.elastic.co/kibana/kibana:$(STACK_VERSION); \ | ||
fi) | ||
|
||
.PHONY: docker-fleet | ||
docker-fleet: docker-network docker-elasticsearch docker-kibana setup-kibana-fleet ## Start Fleet node in docker container | ||
@ docker rm -f $(FLEET_NAME) &> /dev/null || true | ||
@ $(call retry, 5, if ! docker ps --format '{{.Names}}' | grep -w $(FLEET_NAME) > /dev/null 2>&1 ; then \ | ||
docker run -d \ | ||
-p 8220:8220 \ | ||
-e SERVER_NAME=fleet \ | ||
-e FLEET_ENROLL=1 \ | ||
-e FLEET_URL=$(FLEET_ENDPOINT) \ | ||
-e FLEET_INSECURE=true \ | ||
-e FLEET_SERVER_ENABLE=1 \ | ||
-e FLEET_SERVER_POLICY_ID=fleet-server \ | ||
-e FLEET_SERVER_ELASTICSEARCH_HOST=$(ELASTICSEARCH_ENDPOINTS) \ | ||
-e FLEET_SERVER_ELASTICSEARCH_INSECURE=true \ | ||
-e FLEET_SERVER_INSECURE_HTTP=true \ | ||
-e KIBANA_HOST=$(KIBANA_ENDPOINT) \ | ||
-e KIBANA_FLEET_SETUP=1 \ | ||
-e KIBANA_FLEET_USERNAME=$(ELASTICSEARCH_USERNAME) \ | ||
-e KIBANA_FLEET_PASSWORD=$(ELASTICSEARCH_PASSWORD) \ | ||
--name $(FLEET_NAME) \ | ||
--network $(ELASTICSEARCH_NETWORK) \ | ||
docker.elastic.co/beats/elastic-agent:$(STACK_VERSION); \ | ||
fi) | ||
|
||
|
||
.PHONY: docker-network | ||
docker-network: ## Create a dedicated network for ES and test runs | ||
|
@@ -172,19 +200,25 @@ docker-network: ## Create a dedicated network for ES and test runs | |
|
||
.PHONY: set-kibana-password | ||
set-kibana-password: ## Sets the ES KIBANA_SYSTEM_USERNAME's password to KIBANA_SYSTEM_PASSWORD. This expects Elasticsearch to be available at localhost:9200 | ||
@ $(call retry, 10, curl -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" http://localhost:9200/_security/user/$(KIBANA_SYSTEM_USERNAME)/_password -d "{\"password\":\"$(KIBANA_SYSTEM_PASSWORD)\"}" | grep -q "^{}") | ||
@ $(call retry, 10, curl -sS -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" http://localhost:9200/_security/user/$(KIBANA_SYSTEM_USERNAME)/_password -d '{"password":"$(KIBANA_SYSTEM_PASSWORD)"}' | grep -q "^{}") | ||
|
||
.PHONY: create-es-api-key | ||
create-es-api-key: ## Creates and outputs a new API Key. This expects Elasticsearch to be available at localhost:9200 | ||
@ $(call retry, 10, curl -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" http://localhost:9200/_security/api_key -d "{\"name\":\"$(KIBANA_API_KEY_NAME)\"}") | ||
@ $(call retry, 10, curl -sS -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" http://localhost:9200/_security/api_key -d '{"name":"$(KIBANA_API_KEY_NAME)"}') | ||
|
||
.PHONY: create-es-bearer-token | ||
create-es-bearer-token: | ||
@ $(call retry, 10, curl -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" http://localhost:9200/_security/oauth2/token -d "{\"grant_type\": \"client_credentials\"}") | ||
create-es-bearer-token: ## Creates and outputs a new OAuth bearer token. This expects Elasticsearch to be available at localhost:9200 | ||
@ $(call retry, 10, curl -sS -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" http://localhost:9200/_security/oauth2/token -d '{"grant_type":"client_credentials"}') | ||
|
||
.PHONY: setup-kibana-fleet | ||
setup-kibana-fleet: ## Creates the agent and integration policies required to run Fleet. This expects Kibana to be available at localhost:5601 | ||
@ $(call retry, 10, curl -sS --fail-with-body -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" -H "kbn-xsrf: true" http://localhost:5601/api/fleet/fleet_server_hosts -d '{"name":"default"$(,)"host_urls":["$(FLEET_ENDPOINT)"]$(,)"is_default":true}') | ||
@ $(call retry, 10, curl -sS --fail-with-body -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" -H "kbn-xsrf: true" http://localhost:5601/api/fleet/agent_policies -d '{"id":"fleet-server"$(,)"name":"Fleet Server"$(,)"namespace":"default"$(,)"monitoring_enabled":["logs"$(,)"metrics"]}') | ||
@ $(call retry, 10, curl -sS --fail-with-body -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" -H "kbn-xsrf: true" http://localhost:5601/api/fleet/package_policies -d '{"name":"fleet-server"$(,)"namespace":"default"$(,)"policy_id":"fleet-server"$(,)"enabled":true$(,)"inputs":[{"type":"fleet-server"$(,)"enabled":true$(,)"streams":[]$(,)"vars":{}}]$(,)"package":{"name":"fleet_server"$(,)"version":"1.5.0"}}') | ||
|
||
.PHONY: docker-clean | ||
docker-clean: ## Try to remove provisioned nodes and assigned network | ||
@ docker rm -f $(ELASTICSEARCH_NAME) $(KIBANA_NAME) || true | ||
@ docker rm -f $(ELASTICSEARCH_NAME) $(KIBANA_NAME) $(FLEET_NAME) || true | ||
@ docker network rm $(ELASTICSEARCH_NETWORK) || true | ||
|
||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaults to false, not included in the makefile