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

feat(opentelemetry): use custom otelcol-orb collector for orb-agent and orb-maestro #2993

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
80 changes: 80 additions & 0 deletions .github/workflows/agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,83 @@ jobs:
- name: Push agent container orbcommunity
if: github.event_name != 'pull_request'
run: docker push -a orbcommunity/orb-agent-full

package-agent-with-otelcol-orb:
mfiedorowicz marked this conversation as resolved.
Show resolved Hide resolved
needs: package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Get branch name
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV

- name: Debug branch name
run: echo ${{ env.BRANCH_NAME }}

- name: Generate ref tag (main)
if: ${{ env.BRANCH_NAME == 'main' || github.event.client_payload.branch_name == 'main' }}
run: |
echo "REF_TAG=latest" >> $GITHUB_ENV

- name: Generate ref tag (develop)
if: ${{ env.BRANCH_NAME == 'develop' || github.event.client_payload.branch_name == 'develop' }}
run: |
echo "REF_TAG=develop" >> $GITHUB_ENV

- name: Debug ref tag
run: echo ${{ env.REF_TAG }}

- name: Append suffix on VERSION file for develop build
if: ${{ env.BRANCH_NAME == 'develop' || github.event.client_payload.branch_name == 'develop' }}
run: |
echo "`cat ${{github.workspace}}/VERSION`-${{ env.REF_TAG }}" > VERSION

- name: Get VERSION
run: |
echo "VERSION=`cat ${{github.workspace}}/VERSION`" >> $GITHUB_ENV

- name: Debug version
run: echo ${{ env.VERSION }}

- name: Replace crashpad and geo-db params
run: |
ESCAPED_REPLACE_LINE1_NEW=$(printf '%s\n' "pvOptions = append(pvOptions, \"--cp-token\", \"${{ secrets.CRASHPAD_TOKEN }}\")" | sed -e 's/[\/&]/\\&/g')
ESCAPED_REPLACE_LINE2_NEW=$(printf '%s\n' "pvOptions = append(pvOptions, \"--cp-url\", \"${{ secrets.CRASHPAD_URL }}\")" | sed -e 's/[\/&]/\\&/g')
ESCAPED_REPLACE_LINE3_NEW=$(printf '%s\n' "pvOptions = append(pvOptions, \"--cp-path\", \"/usr/local/sbin/crashpad_handler\")" | sed -e 's/[\/&]/\\&/g')
ESCAPED_REPLACE_LINE4_NEW=$(printf '%s\n' "pvOptions = append(pvOptions, \"--default-geo-city\", \"/geo-db/city.mmdb\")" | sed -e 's/[\/&]/\\&/g')
ESCAPED_REPLACE_LINE5_NEW=$(printf '%s\n' "pvOptions = append(pvOptions, \"--default-geo-asn\", \"/geo-db/asn.mmdb\")" | sed -e 's/[\/&]/\\&/g')
ESCAPED_REPLACE_LINE6_NEW=$(printf '%s\n' "pvOptions = append(pvOptions, \"--default-service-registry\", \"/iana/custom-iana.csv\")" | sed -e 's/[\/&]/\\&/g')
ESCAPED_REPLACE_LINE1_OLD=$(printf '%s\n' "// pvOptions = append(pvOptions, \"--cp-token\", PKTVISOR_CP_TOKEN)" | sed -e 's/[\/&]/\\&/g')
ESCAPED_REPLACE_LINE2_OLD=$(printf '%s\n' "// pvOptions = append(pvOptions, \"--cp-url\", PKTVISOR_CP_URL)" | sed -e 's/[\/&]/\\&/g')
ESCAPED_REPLACE_LINE3_OLD=$(printf '%s\n' "// pvOptions = append(pvOptions, \"--cp-path\", PKTVISOR_CP_PATH)" | sed -e 's/[\/&]/\\&/g')
ESCAPED_REPLACE_LINE4_OLD=$(printf '%s\n' "// pvOptions = append(pvOptions, \"--default-geo-city\", \"/geo-db/city.mmdb\")" | sed -e 's/[\/&]/\\&/g')
ESCAPED_REPLACE_LINE5_OLD=$(printf '%s\n' "// pvOptions = append(pvOptions, \"--default-geo-asn\", \"/geo-db/asn.mmdb\")" | sed -e 's/[\/&]/\\&/g')
ESCAPED_REPLACE_LINE6_OLD=$(printf '%s\n' "// pvOptions = append(pvOptions, \"--default-service-registry\", \"/iana/custom-iana.csv\")" | sed -e 's/[\/&]/\\&/g')
sed -i -e "s/$ESCAPED_REPLACE_LINE1_OLD/$ESCAPED_REPLACE_LINE1_NEW/g" agent/backend/pktvisor/pktvisor.go
sed -i -e "s/$ESCAPED_REPLACE_LINE2_OLD/$ESCAPED_REPLACE_LINE2_NEW/g" agent/backend/pktvisor/pktvisor.go
sed -i -e "s/$ESCAPED_REPLACE_LINE3_OLD/$ESCAPED_REPLACE_LINE3_NEW/g" agent/backend/pktvisor/pktvisor.go
sed -i -e "s/$ESCAPED_REPLACE_LINE4_OLD/$ESCAPED_REPLACE_LINE4_NEW/g" agent/backend/pktvisor/pktvisor.go
sed -i -e "s/$ESCAPED_REPLACE_LINE5_OLD/$ESCAPED_REPLACE_LINE5_NEW/g" agent/backend/pktvisor/pktvisor.go
sed -i -e "s/$ESCAPED_REPLACE_LINE6_OLD/$ESCAPED_REPLACE_LINE6_NEW/g" agent/backend/pktvisor/pktvisor.go

- name: Build orb-agent with otelcol-orb
shell: bash
run: |
if [ "${{ github.event.inputs.pktvisor_tag }}" == "" ]; then
DIODE_TAG=${{ env.REF_TAG }} PKTVISOR_TAG=${{ env.REF_TAG }} ORB_TAG=${{ env.REF_TAG }} make agent_custom
else
DIODE_TAG=${{ github.event.inputs.diode_tag }} PKTVISOR_TAG=${{ github.event.inputs.pktvisor_tag }} ORB_TAG=${{ github.event.inputs.orb_tag }} make agent_custom
fi

- name: Login to Docker Hub orbcommunity
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.ORB_DOCKERHUB_USERNAME }}
password: ${{ secrets.ORB_DOCKERHUB_TOKEN }}

- name: Push agent container orbcommunity
if: github.event_name != 'pull_request'
run: docker push -a orbcommunity/orb-agent-otelcol-orb
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,18 @@ agent_full:
--tag=$(ORB_DOCKERHUB_REPO)/$(DOCKER_IMAGE_NAME_PREFIX)-agent-full:$(ORB_VERSION)-$(COMMIT_HASH) \
-f agent/docker/Dockerfile.full .

agent_custom:
docker build --no-cache \
--build-arg GOARCH=$(GOARCH) \
--build-arg PKTVISOR_TAG=$(PKTVISOR_TAG) \
--build-arg DIODE_TAG=$(DIODE_TAG) \
--build-arg ORB_TAG=${REF_TAG} \
--build-arg OTEL_TAG=latest \
--tag=$(ORB_DOCKERHUB_REPO)/$(DOCKER_IMAGE_NAME_PREFIX)-agent-custom:$(REF_TAG) \
--tag=$(ORB_DOCKERHUB_REPO)/$(DOCKER_IMAGE_NAME_PREFIX)-agent-custom:$(ORB_VERSION) \
--tag=$(ORB_DOCKERHUB_REPO)/$(DOCKER_IMAGE_NAME_PREFIX)-agent-custom:$(ORB_VERSION)-$(COMMIT_HASH) \
-f agent/docker/Dockerfile.custom .

agent_debug:
docker build \
--build-arg PKTVISOR_TAG=$(PKTVISOR_DEBUG_TAG) \
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.29.0
0.30.0
31 changes: 31 additions & 0 deletions agent/docker/Dockerfile.custom
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
ARG ORB_TAG=develop
ARG PKTVISOR_TAG=develop
ARG DIODE_TAG=develop
ARG OTEL_TAG=latest

FROM orbcommunity/orb-agent:${ORB_TAG} AS orb

FROM orbcommunity/diode-agent:${DIODE_TAG} AS diode

FROM orbcommunity/otelcol-orb-agent:${OTEL_TAG} AS otelcol-orb

FROM orbcommunity/pktvisor:${PKTVISOR_TAG}

# adding orb-agent
RUN mkdir /opt/orb
COPY --from=orb /usr/local/bin/orb-agent /usr/local/bin/orb-agent
COPY ./agent/docker/agent_default_custom.yaml /opt/orb/agent_default.yaml
COPY --from=orb /usr/local/bin/orb-agent-entry.sh /usr/local/bin/orb-agent-entry.sh
COPY --from=orb /run-agent.sh /run-agent.sh

# adding diode-agent
COPY --from=diode /usr/local/bin/diode-agent /usr/local/bin/diode-agent

# adding suzieq patched
COPY --from=diode /root/.suzieq /root/.suzieq

COPY --from=otelcol-orb /otelcol-orb /usr/local/bin/otelcol-orb

RUN chmod a+x /run-agent.sh

ENTRYPOINT [ "/usr/local/bin/orb-agent-entry.sh" ]
16 changes: 16 additions & 0 deletions agent/docker/agent_default_custom.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "1.0"

visor:
taps:

orb:
backends:
pktvisor:
binary: /usr/local/sbin/pktvisord
config_file: /opt/orb/agent_default.yaml
diode:
binary: /usr/local/bin/diode-agent
config_file: /opt/orb/agent_default.yaml
otel:
binary: /usr/local/bin/otelcol-orb
config_file: /opt/orb/agent_default.yaml
4 changes: 2 additions & 2 deletions maestro/config/config_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var k8sOtelCollector = `
"containers": [
{
"name": "otel-collector",
"image": "otel/opentelemetry-collector-contrib:0.91.0",
"image": "orb-community/otelcol-orb-maestro@latest",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend to avoid using latest but stick to specific version (once we have them)

"ports": [
{
"containerPort": 13133,
Expand Down Expand Up @@ -296,7 +296,7 @@ var JsonDeployment = `
"containers": [
{
"name": "otel-collector",
"image": "otel/opentelemetry-collector-contrib:0.91.0",
"image": "orb-community/otelcol-orb-maestro@latest",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here regarding latest

"ports": [
{
"containerPort": 13133,
Expand Down
2 changes: 1 addition & 1 deletion sinker/otel/bridgeservice/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type BridgeService interface {
GetDataSetsFromAgentGroups(ctx context.Context, mfOwnerId string, agentGroupIds []string) (map[string]string, error)
NotifyActiveSink(ctx context.Context, mfOwnerId, sinkId, state, message string) error
GetSinkIdsFromPolicyID(ctx context.Context, mfOwnerId string, policyID string) (map[string]string, error)
IncreamentMessageCounter(publisher, subtopic, channel, protocol string)
IncrementMessageCounter(publisher, subtopic, channel, protocol string)
mfiedorowicz marked this conversation as resolved.
Show resolved Hide resolved
}

func NewBridgeService(logger *zap.Logger,
Expand Down
Loading