From 4979ef7169cea6d6d24c60b0d55fe4c04b7d8f09 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Pegoraro Date: Tue, 30 Jan 2024 12:16:36 -0300 Subject: [PATCH 1/5] chore(VERSION): bump version since last release. --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index ae6dd4e20..c25c8e5b7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.29.0 +0.30.0 From fca211966376b98c84966c49dea1c88b0a06a888 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Pegoraro Date: Wed, 7 Feb 2024 13:41:20 -0300 Subject: [PATCH 2/5] feat(agent): add build and image for new otelcol-orb agent image. --- .github/workflows/agent.yml | 80 ++++++++++++++++++++++++++++++++++ Makefile | 12 +++++ agent/docker/Dockerfile.custom | 31 +++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 agent/docker/Dockerfile.custom diff --git a/.github/workflows/agent.yml b/.github/workflows/agent.yml index 4ff3756c9..2700e7d7b 100644 --- a/.github/workflows/agent.yml +++ b/.github/workflows/agent.yml @@ -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: + 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 \ No newline at end of file diff --git a/Makefile b/Makefile index f07c3ef7c..a2ba39bdc 100644 --- a/Makefile +++ b/Makefile @@ -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) \ diff --git a/agent/docker/Dockerfile.custom b/agent/docker/Dockerfile.custom new file mode 100644 index 000000000..d4d6175c5 --- /dev/null +++ b/agent/docker/Dockerfile.custom @@ -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-contrib + +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_full.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-contrib /otelcol-contrib /usr/local/bin/otelcol-contrib + +RUN chmod a+x /run-agent.sh + +ENTRYPOINT [ "/usr/local/bin/orb-agent-entry.sh" ] From bfdb4ee5f3f04d1845c651cc776324a9e52d090b Mon Sep 17 00:00:00 2001 From: Luiz Henrique Pegoraro Date: Wed, 7 Feb 2024 13:43:19 -0300 Subject: [PATCH 3/5] feat(maestro): use image from otelcol-orb-maestro. --- maestro/config/config_builder.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maestro/config/config_builder.go b/maestro/config/config_builder.go index 76c921d4e..b8a7cf4aa 100644 --- a/maestro/config/config_builder.go +++ b/maestro/config/config_builder.go @@ -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", "ports": [ { "containerPort": 13133, @@ -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", "ports": [ { "containerPort": 13133, From 21cab6b2203a7c23bb3bba323ca7d9a57246eb13 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Pegoraro Date: Wed, 7 Feb 2024 13:43:36 -0300 Subject: [PATCH 4/5] feat(sinker): fix typo. --- sinker/otel/bridgeservice/bridge.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sinker/otel/bridgeservice/bridge.go b/sinker/otel/bridgeservice/bridge.go index bd348758e..3e5291348 100644 --- a/sinker/otel/bridgeservice/bridge.go +++ b/sinker/otel/bridgeservice/bridge.go @@ -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) } func NewBridgeService(logger *zap.Logger, From e4023c5de8cedfc8706fc6fa3cdaf4690a2869f9 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Pegoraro Date: Wed, 7 Feb 2024 13:53:10 -0300 Subject: [PATCH 5/5] feat(agent): fix binary for otelcol-orb. --- agent/docker/Dockerfile.custom | 6 +++--- agent/docker/agent_default_custom.yaml | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 agent/docker/agent_default_custom.yaml diff --git a/agent/docker/Dockerfile.custom b/agent/docker/Dockerfile.custom index d4d6175c5..eb844a822 100644 --- a/agent/docker/Dockerfile.custom +++ b/agent/docker/Dockerfile.custom @@ -7,14 +7,14 @@ 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-contrib +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_full.yaml /opt/orb/agent_default.yaml +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 @@ -24,7 +24,7 @@ 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-contrib /otelcol-contrib /usr/local/bin/otelcol-contrib +COPY --from=otelcol-orb /otelcol-orb /usr/local/bin/otelcol-orb RUN chmod a+x /run-agent.sh diff --git a/agent/docker/agent_default_custom.yaml b/agent/docker/agent_default_custom.yaml new file mode 100644 index 000000000..7d7ec9cc6 --- /dev/null +++ b/agent/docker/agent_default_custom.yaml @@ -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