Beats: [Functionbeat]聽Docker

Created on 14 Dec 2019  路  7Comments  路  Source: elastic/beats

Hello,

we want to deploy functionbeat changes via our CI/CD pipeline. Our idea was to run a small docker container to execute functionbeat commands instead of downloading the functionbeat binary for the right platform.

Can you provide a docker image for functionbeat as well like for all other beats?

Best regards,
Christian

Functionbeat Services Backlog

Most helpful comment

@CEikermann @andresrc

The working Dockerfile looks like this -

FROM debian:latest

ARG FUNCTIONBEAT_VERSION=7.6.1

ADD https://artifacts.elastic.co/downloads/beats/functionbeat/functionbeat-${FUNCTIONBEAT_VERSION}-linux-x86_64.tar.gz /tmp

RUN \
    apt-get update \
    && apt-get install -y --no-install-recommends \
    curl \
    && rm -rf /var/lib/apt/lists/* && \
    tar xzvf /tmp/functionbeat-${FUNCTIONBEAT_VERSION}-linux-x86_64.tar.gz && \
    mv functionbeat-${FUNCTIONBEAT_VERSION}-linux-x86_64/functionbeat /bin/functionbeat && \
    chmod a+x /bin/functionbeat

ENV PATH /bin/functionbeat:$PATH

ENTRYPOINT ["functionbeat"]

All 7 comments

@andresrc I would also like to have a docker image for Functionbeats.
I am trying to deploy a serverless function for centralized logging. However the normal alpine image gives below error while executing functionbeat.

$ docker run -it --entrypoint sh functionbeat-v9:latest                                                                   [14:41:58]
/ #
/ # which functionbeat
/bin/functionbeat
/ #
/ # functionbeat
sh: functionbeat: not found

My Dockerfile looks like below.

FROM alpine:latest

ARG FUNCTIONBEAT_VERSION=7.6.1

ADD https://artifacts.elastic.co/downloads/beats/functionbeat/functionbeat-${FUNCTIONBEAT_VERSION}-linux-x86_64.tar.gz /tmp

RUN apk add --update --no-cache curl && \
    tar xzvf /tmp/functionbeat-${FUNCTIONBEAT_VERSION}-linux-x86_64.tar.gz && \
    mv functionbeat-${FUNCTIONBEAT_VERSION}-linux-x86_64/functionbeat /bin/ && \
    chmod a+x /bin/functionbeat

ENV PATH /bin/functionbeat:$PATH

ENTRYPOINT ["/bin/functionbeat"]`

@CEikermann @andresrc

The working Dockerfile looks like this -

FROM debian:latest

ARG FUNCTIONBEAT_VERSION=7.6.1

ADD https://artifacts.elastic.co/downloads/beats/functionbeat/functionbeat-${FUNCTIONBEAT_VERSION}-linux-x86_64.tar.gz /tmp

RUN \
    apt-get update \
    && apt-get install -y --no-install-recommends \
    curl \
    && rm -rf /var/lib/apt/lists/* && \
    tar xzvf /tmp/functionbeat-${FUNCTIONBEAT_VERSION}-linux-x86_64.tar.gz && \
    mv functionbeat-${FUNCTIONBEAT_VERSION}-linux-x86_64/functionbeat /bin/functionbeat && \
    chmod a+x /bin/functionbeat

ENV PATH /bin/functionbeat:$PATH

ENTRYPOINT ["functionbeat"]

Thank you for sharing!

FROM ubuntu:latest

ARG FUNCTIONBEAT_VERSION=7.7.1

ADD https://artifacts.elastic.co/downloads/beats/functionbeat/functionbeat-${FUNCTIONBEAT_VERSION}-linux-x86_64.tar.gz /tmp

RUN \
    apt-get update \
    && apt-get install -y --no-install-recommends \
    curl \
    && rm -rf /var/lib/apt/lists/* && \
    tar xzvf /tmp/functionbeat-${FUNCTIONBEAT_VERSION}-linux-x86_64.tar.gz && \
    mv -v functionbeat-${FUNCTIONBEAT_VERSION}-linux-x86_64 /opt/functionbeat

WORKDIR /opt/functionbeat
ENV PATH /opt/functionbeat:$PATH

ENTRYPOINT ["functionbeat"]

I got error "Missing pkg/functionbeat-aws" for above dockerfile, so i fix it for current version

I get the following error each time:

Function: functionbeat, could not deploy, error: bucket 'functionbeat-deployment' already exist and you don't have permission to access it.

I pass the AWS credentials into the container as environment variables. Locally (without Docker Image), the deployment works with my credentials.

This is my docker run command:

docker run -it --rm \
-v $(pwd)/config:/functionbeat/config:ro \
--env AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
--env AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
--env AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \
--env AWS_SECURITY_TOKEN=$AWS_SECURITY_TOKEN \
--env AWS_REGION=eu-central-1 \
--env AWS_DEFAULT_REGION=eu-central-1 \
myorga/functionbeat:latest \
deploy functionbeat -c /functionbeat/config/functionbeat.yml -e -v -d "*"

I have no idea what I am doing wrong. I also have the problem with the above Dockerfile.

Pinging @elastic/integrations-services (Team:Services)

Together with @mmathea-ep we could now solve the problem and build a running Docker Image. Apparently Python is required for the functionbeat executable to work.

This is our Dockerfile:

FROM python:3.7.9-slim-buster as functionbeat-download

ENV FUNCTIONBEAT_VERSION=7.8.1
ENV FUNCTIONBEAT_PACKAGE=functionbeat-${FUNCTIONBEAT_VERSION}-linux-x86_64

ADD https://artifacts.elastic.co/downloads/beats/functionbeat/${FUNCTIONBEAT_PACKAGE}.tar.gz /tmp
RUN mkdir -p /functionbeat && \
    tar -xvf /tmp/${FUNCTIONBEAT_PACKAGE}.tar.gz --strip 1 -C /functionbeat

FROM python:3.7.9-slim-buster

RUN addgroup functionbeat \
 && useradd -g functionbeat --no-create-home functionbeat

USER functionbeat

ENV PATH /bin/functionbeat:$PATH

ENTRYPOINT ["/bin/functionbeat"]
CMD ["help"]

WORKDIR /functionbeat
VOLUME ["/functionbeat/config"]

COPY --from=functionbeat-download /functionbeat/functionbeat /bin/functionbeat
COPY --from=functionbeat-download /functionbeat/pkg/functionbeat-aws /functionbeat/pkg/functionbeat-aws

You can run it via:

docker run -it --rm \
-v $(pwd)/config:/functionbeat/config:ro \
--env AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
--env AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
--env AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \
--env AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION \
{{ DOCKER IMAGE }} \
deploy {{ FUNCTIONBEAT_NAME }} -c /functionbeat/config/functionbeat.yml -e -v -d "*"

Starting from your current directory the folder /config is mounted into the container. In this folder you should place the config file functionbeat.yml.

Was this page helpful?
0 / 5 - 0 ratings