zmoog / otel-collector-contrib

Collection of personal OTel Collector related projects
Apache License 2.0
0 stars 0 forks source link

Deploy the OTel collector on docker and k8s #9

Open zmoog opened 1 month ago

zmoog commented 1 month ago

For Docker, I build a simple Dockerfile

FROM cgr.dev/chainguard/go AS builder
ENV CGO_ENABLED 0
ARG BUILD_REF
COPY . /app
RUN cd /app && go build -o otelcol-dev ./collector/otelcol-dev

FROM cgr.dev/chainguard/glibc-dynamic
ARG BUILD_DATE
ARG BUILD_REF
COPY --from=builder /app/otelcol-dev /usr/bin/    
COPY collector/config.yaml /app/config.yaml
CMD ["/usr/bin/otelcol-dev", "--config", "/app/config.yaml"]

Build using:

make service

And run using:

export ZCS_CLIENT_ID=""
export ZCS_AUTH_KEY=""
export ZCS_THING_KEY=""
export TOGGL_API_TOKEN=""
export ELASTICSEARCH_ENDPOINTS=""
export ELASTICSEARCH_USERNAME=""
export ELASTICSEARCH_PASSWORD=""

docker run --rm --name otel-collector \
    -e ZCS_CLIENT_ID="${ZCS_CLIENT_ID}" \
    -e ZCS_AUTH_KEY="${ZCS_AUTH_KEY}" \
    -e ZCS_THING_KEY="${ZCS_THING_KEY}" \
    -e TOGGL_API_TOKEN="${TOGGL_API_TOKEN}" \
    -e ELASTICSEARCH_ENDPOINTS="${ELASTICSEARCH_ENDPOINTS}" \
    -e ELASTICSEARCH_USERNAME="${ELASTICSEARCH_USERNAME}" \
    -e ELASTICSEARCH_PASSWORD="${ELASTICSEARCH_PASSWORD}" \
    -i zmoog/otel-collector:0.1.0
zmoog commented 1 month ago

I'm starting from bender's k8s deployment files at https://github.com/zmoog/go-bender/tree/main/zarf/k8s