-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Agent] Respect connector_id defined in agentless (#2989)
- Loading branch information
Showing
9 changed files
with
57 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,47 @@ | ||
# This file is for internal experimental purposes only. | ||
# Please do not use this file for any real-world workloads. | ||
|
||
FROM docker.elastic.co/elastic-agent/elastic-agent:9.0.0-SNAPSHOT | ||
|
||
USER root | ||
# Install dependencies | ||
RUN apt update | ||
RUN apt install software-properties-common -y | ||
RUN add-apt-repository ppa:deadsnakes/ppa | ||
RUN apt install python3.11 python3.11-venv make -y | ||
|
||
# TEMPORARY STUFF | ||
# I need vim to edit some fields | ||
# Git is needed to pull connectors repo | ||
# yq is needed to append our input to elastic-agent.yml | ||
RUN add-apt-repository ppa:rmescandon/yq | ||
RUN apt install vim git yq -y | ||
|
||
# Copy and install python agent client | ||
# TODO: also package this with revision and everything | ||
|
||
# Install apt-get dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
software-properties-common \ | ||
vim \ | ||
wget \ | ||
git \ | ||
make \ | ||
&& add-apt-repository ppa:deadsnakes/ppa \ | ||
&& apt-get update && apt-get install -y python3.11 python3.11-venv \ | ||
&& apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
# Install Go-based yq separately | ||
RUN wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && \ | ||
chmod +x /usr/bin/yq | ||
|
||
# Copy project files | ||
COPY ./ /usr/share/connectors | ||
|
||
# Set working directory | ||
WORKDIR /usr/share/connectors | ||
|
||
# Install Python agent client | ||
RUN PYTHON=python3.11 make clean install install-agent | ||
|
||
# Add component | ||
# Agent directory name is dynamic and based on build hash, so we need to move in two steps | ||
# Copy and move the component files into the dynamic agent directory | ||
COPY ./resources/agent/python-elastic-agent-client /tmp/python-elastic-agent-client | ||
COPY ./resources/agent/python-elastic-agent-client.spec.yml /tmp/python-elastic-agent-client.spec.yml | ||
RUN mv /tmp/python-elastic-agent-client /usr/share/elastic-agent/data/elastic-agent-$(cat /usr/share/elastic-agent/.build_hash.txt| cut -c 1-6)/components/python-elastic-agent-client | ||
RUN mv /tmp/python-elastic-agent-client.spec.yml /usr/share/elastic-agent/data/elastic-agent-$(cat /usr/share/elastic-agent/.build_hash.txt| cut -c 1-6)/components/python-elastic-agent-client.spec.yml | ||
|
||
# add input to the elastic-agent.yml | ||
RUN yq eval --inplace '.inputs += { "type": "connectors-py", "id": "connectors-py", "use_output": "default"}' /usr/share/elastic-agent/elastic-agent.yml | ||
RUN BUILD_DIR=$(cat /usr/share/elastic-agent/.build_hash.txt | cut -c 1-6) && \ | ||
mv /tmp/python-elastic-agent-client \ | ||
/usr/share/elastic-agent/data/elastic-agent-${BUILD_DIR}/components/python-elastic-agent-client && \ | ||
mv /tmp/python-elastic-agent-client.spec.yml \ | ||
/usr/share/elastic-agent/data/elastic-agent-${BUILD_DIR}/components/python-elastic-agent-client.spec.yml | ||
|
||
WORKDIR /usr/share/elastic-agent | ||
# Modify the elastic-agent.yml file | ||
RUN yq eval --inplace '.inputs += { "type": "connectors-py", "id": "connectors-py", "use_output": "default"}' \ | ||
/usr/share/elastic-agent/elastic-agent.yml | ||
|
||
# Set the final working directory | ||
WORKDIR /usr/share/elastic-agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.