Skip to content

Commit

Permalink
Merge branch 'kube-logging:main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelpissolatto authored Jan 4, 2024
2 parents 797100a + 832e4ac commit 9f0811c
Show file tree
Hide file tree
Showing 12 changed files with 637 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
matrix:
fluentd:
- v1.16
- v1.16-ruby3.2
image-type:
- base
- filters
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
matrix:
fluentd:
- v1.16
- v1.16-ruby3.2
image-type:
- base
- filters
Expand Down
6 changes: 5 additions & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"extends": [
"config:base",
"schedule:daily",
"group:all"
"group:all",
"config:recommended"
],
"ignorePaths": [
"v1.16-ruby3.2/"
],
"automerge": true,
"major": {
Expand Down
100 changes: 100 additions & 0 deletions v1.16-ruby3.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
FROM public.ecr.aws/sumologic/kubernetes-fluentd:latest-alpine@sha256:b44e3526ae59b558576de5695aa5d6b1bdd4e0a080372f0f25d77a4d2092a476 AS sumo

# Adapted from https://github.com/SumoLogic/sumologic-kubernetes-fluentd/blob/main/alpine.Dockerfile#L102C1-L142C16
FROM ruby:3.2.2-alpine3.18 as base

ARG BUILD_DEPS=" \
make gcc g++ libc-dev \
wget bzip2 zlib-dev git linux-headers \
automake autoconf libtool build-base \
ruby-dev libc6-compat geoip-dev \
snappy-dev gnupg \
"

RUN addgroup -S -g 101 fluent && adduser -S -G fluent -u 100 fluent \
# for log storage (maybe shared with host)
&& mkdir -p /fluentd/log \
# configuration/plugins path (default: copied from .)
&& mkdir -p /fluentd/etc /fluentd/plugins \
&& chown -R fluent /fluentd && chgrp -R fluent /fluentd \
&& mkdir -p /buffers && chown -R fluent /buffers

COPY --from=sumo --chown=fluent:fluent /usr/local/bundle /usr/local/bundle

RUN apk add --no-cache \
ca-certificates \
ruby ruby-irb ruby-etc \
tini libmaxminddb geoip \
snappy \
&& apk add --no-cache $BUILD_DEPS \
&& apk add --no-cache "libssl3>=3.1.4-r1" \
&& apk add --no-cache "libcrypto3>=3.1.4-r1" \
&& echo 'gem: --no-document' >> /etc/gemrc \
# need to rebuild these gems to have the extensions installed
&& fluent-gem install \
bigdecimal:1.4.4 \
oj:3.15.0 \
google-protobuf:3.21.12 \
nio4r:2.6.0 \
snappy:0.3.0 \
# The only required fluentd dependency is the label router
# kubeclient install is upgrading the one from the base image
&& fluent-gem install specific_install -v 0.3.8 \
&& fluent-gem specific_install -l https://github.com/ManageIQ/kubeclient.git --ref 054bff2c5e31a555004be2b3c4d32fb9dc5e6a0f \
&& fluent-gem specific_install -l https://github.com/kube-logging/fluent-plugin-label-router.git --ref 2ff43789f895735b7852e0a1a809280e22d9e8ef \
# TODO remove once the default version is greater than 0.12.1 https://avd.aquasec.com/nvd/2023/cve-2023-36617/
&& fluent-gem install uri -v 0.12.2 \
&& find /usr/local/bundle/gems/ -newer /etc/gemrc -exec chown fluent:fluent {} \; \
&& apk del $BUILD_DEPS \
&& rm -rf /usr/local/bundle/cache/* && find /usr/local/bundle -name '*.o' -delete

COPY fluent.conf /fluentd/etc/
COPY entrypoint.sh /bin/
COPY healthy.sh /bin/

ENV FLUENTD_CONF="fluent.conf"
ENV LD_PRELOAD=""
EXPOSE 24224 5140

USER fluent

ENTRYPOINT ["tini", "--", "/bin/entrypoint.sh"]
CMD ["fluentd"]

### Image with all the filters
FROM base AS filters

ADD ./filters/Gemfile /Gemfile.filters
ADD ./filters/Gemfile.lock /Gemfile.filters.lock

USER root

ENV BUNDLE_WITHOUT="output,test,development"

RUN apk add --no-cache $BUILD_DEPS \
&& touch /etc/gemrc \
&& fluent-gem install --file Gemfile.filters \
&& find /usr/local/bundle/gems/ -newer /etc/gemrc -exec chown fluent:fluent {} \; \
&& apk del $BUILD_DEPS \
&& rm -rf /usr/local/bundle/cache/* && find /usr/local/bundle -name '*.o' -delete

USER fluent

### Image with all the filters and outputs
FROM filters as full

ADD ./outputs/Gemfile /Gemfile.outputs
ADD ./outputs/Gemfile.lock /Gemfile.outputs.lock

USER root

RUN apk add --no-cache $BUILD_DEPS \
&& touch /etc/gemrc \
&& fluent-gem specific_install -l https://github.com/kube-logging/fluent-plugin-gcs.git --ref 71a0932e75509545a2d28e337642ee1f973cca90 \
&& fluent-gem specific_install -l https://github.com/acquia/fluent-plugin-syslog_rfc5424.git --ref 5199be67d1a385f529fa1d6b6023e95ba7fac27d \
&& fluent-gem install --file /Gemfile.outputs \
&& find /usr/local/bundle/gems/ -newer /etc/gemrc -exec chown fluent:fluent {} \; \
&& apk del $BUILD_DEPS \
&& rm -rf /usr/local/bundle/cache/* && find /usr/local/bundle -name '*.o' -delete

USER fluent
28 changes: 28 additions & 0 deletions v1.16-ruby3.2/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

#source vars if file exists
DEFAULT=/etc/default/fluentd

if [ -r $DEFAULT ]; then
set -o allexport
. $DEFAULT
set +o allexport
fi

# If the user has supplied only arguments append them to `fluentd` command
if [ "${1#-}" != "$1" ]; then
set -- fluentd "$@"
fi

# If user does not supply config file or plugins, use the default
if [ "$1" = "fluentd" ]; then
if ! echo $@ | grep ' \-c' ; then
set -- "$@" -c /fluentd/etc/${FLUENTD_CONF}
fi

if ! echo $@ | grep ' \-p' ; then
set -- "$@" -p /fluentd/plugins
fi
fi

exec "$@"
17 changes: 17 additions & 0 deletions v1.16-ruby3.2/filters/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
source 'https://rubygems.org'

gem 'fluent-plugin-detect-exceptions', '0.0.15'
gem 'fluent-plugin-prometheus', '2.1.0'
gem 'fluent-plugin-dedot_filter', '1.0.0'
gem 'fluent-plugin-geoip', '1.3.2'
gem 'fluent-plugin-tag-normaliser', '0.1.2'
gem 'fluent-plugin-concat', '2.5.0'
gem 'fluent-plugin-parser-logfmt', '0.0.0'
gem 'fluent-plugin-record-modifier', '2.2.0'
gem 'fluent-plugin-kube-events-timestamp', '0.1.3'
gem 'fluent-plugin-throttle', '0.0.5'
gem 'fluent-plugin-rewrite-tag-filter', '2.4.0'
gem 'fluent-plugin-multi-format-parser', '1.1.0'
gem 'fluent-plugin-grok-parser', '2.6.2'
gem 'fluent-plugin-mysqlslowquery', '0.0.9'
gem 'fluent-plugin-ua-parser', '1.2.0'
101 changes: 101 additions & 0 deletions v1.16-ruby3.2/filters/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
GEM
remote: https://rubygems.org/
specs:
concurrent-ruby (1.2.2)
cool.io (1.8.0)
dig_rb (1.0.1)
fluent-config-regexp-type (1.0.0)
fluentd (> 1.0.0, < 2)
fluent-plugin-concat (2.5.0)
fluentd (>= 0.14.0, < 2)
fluent-plugin-dedot_filter (1.0.0)
fluentd (>= 0.14.0, < 2)
fluent-plugin-detect-exceptions (0.0.15)
fluentd (>= 0.10)
fluent-plugin-geoip (1.3.2)
dig_rb
fluentd (>= 0.14.8, < 2)
geoip-c
geoip2_c
fluent-plugin-grok-parser (2.6.2)
fluentd (>= 0.14.6, < 2)
fluent-plugin-kube-events-timestamp (0.1.3)
fluentd (>= 0.14.0, < 2)
fluent-plugin-multi-format-parser (1.1.0)
fluentd (>= 0.14.0, < 2)
fluent-plugin-mysqlslowquery (0.0.9)
fluentd (>= 0.12.0, < 2)
myslog (~> 0.0)
fluent-plugin-parser-logfmt (0.0.0)
fluentd (>= 1, < 2)
logfmt (~> 0.0.8)
fluent-plugin-prometheus (2.1.0)
fluentd (>= 1.9.1, < 2)
prometheus-client (>= 2.1.0)
fluent-plugin-record-modifier (2.2.0)
fluentd (>= 1.1, < 2)
fluent-plugin-rewrite-tag-filter (2.4.0)
fluent-config-regexp-type
fluentd (>= 0.14.2, < 2)
fluent-plugin-tag-normaliser (0.1.2)
fluentd (>= 0.14.10, < 2)
fluent-plugin-throttle (0.0.5)
fluentd (~> 1.1)
fluent-plugin-ua-parser (1.2.0)
fluentd (>= 0.14, < 2)
lru_redux (>= 1.0.0)
user_agent_parser (>= 2.2.0)
fluentd (1.16.3)
bundler
cool.io (>= 1.4.5, < 2.0.0)
http_parser.rb (>= 0.5.1, < 0.9.0)
msgpack (>= 1.3.1, < 2.0.0)
serverengine (>= 2.3.2, < 3.0.0)
sigdump (~> 0.2.5)
strptime (>= 0.2.4, < 1.0.0)
tzinfo (>= 1.0, < 3.0)
tzinfo-data (~> 1.0)
webrick (~> 1.4)
yajl-ruby (~> 1.0)
geoip-c (0.9.1)
geoip2_c (0.3.4)
http_parser.rb (0.8.0)
logfmt (0.0.10)
lru_redux (1.1.0)
msgpack (1.7.2)
myslog (0.1.1)
prometheus-client (4.2.1)
serverengine (2.3.2)
sigdump (~> 0.2.2)
sigdump (0.2.5)
strptime (0.2.5)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
tzinfo-data (1.2023.3)
tzinfo (>= 1.0.0)
user_agent_parser (2.16.0)
webrick (1.8.1)
yajl-ruby (1.4.3)

PLATFORMS
ruby

DEPENDENCIES
fluent-plugin-concat (= 2.5.0)
fluent-plugin-dedot_filter (= 1.0.0)
fluent-plugin-detect-exceptions (= 0.0.15)
fluent-plugin-geoip (= 1.3.2)
fluent-plugin-grok-parser (= 2.6.2)
fluent-plugin-kube-events-timestamp (= 0.1.3)
fluent-plugin-multi-format-parser (= 1.1.0)
fluent-plugin-mysqlslowquery (= 0.0.9)
fluent-plugin-parser-logfmt (= 0.0.0)
fluent-plugin-prometheus (= 2.1.0)
fluent-plugin-record-modifier (= 2.2.0)
fluent-plugin-rewrite-tag-filter (= 2.4.0)
fluent-plugin-tag-normaliser (= 0.1.2)
fluent-plugin-throttle (= 0.0.5)
fluent-plugin-ua-parser (= 1.2.0)

BUNDLED WITH
2.4.22
8 changes: 8 additions & 0 deletions v1.16-ruby3.2/fluent.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This is the root config file, which only includes components of the actual configuration

# Do not collect fluentd's own logs to avoid infinite loops.
<match fluent.**>
@type null
</match>

@include /fluentd/etc/conf.d/*.conf
23 changes: 23 additions & 0 deletions v1.16-ruby3.2/healthy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh -x

# Liveness probe is aimed to help in situations where fluentd
# silently hangs for no apparent reasons until manual restart.
# The idea of this probe is that if fluentd is not queueing or
# flushing chunks for 5 minutes, something is not right. If
# you want to change the fluentd configuration, reducing amount of
# logs fluentd collects, consider changing the threshold or turning
# liveness probe off completely.
# soiurce https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/fluentd-gcp/fluentd-gcp-ds.yaml#L58

BUFFER_PATH=${BUFFER_PATH};
LIVENESS_THRESHOLD_SECONDS=${LIVENESS_THRESHOLD_SECONDS:-300};

if [ ! -e ${BUFFER_PATH} ];
then
exit 1;
fi;
touch -d "@$(($(date +%s) - $LIVENESS_THRESHOLD_SECONDS))" /tmp/marker-liveness;
if [ -z "$(find ${BUFFER_PATH} -type d -newer /tmp/marker-liveness -print -quit)" ];
then
exit 1;
fi;
24 changes: 24 additions & 0 deletions v1.16-ruby3.2/outputs/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
source 'https://rubygems.org'

gem 'fluent-plugin-aliyun-oss', '0.0.1'
gem 'fluent-plugin-sumologic_output', '1.8.0'
gem 'fluent-plugin-kafka', '0.19.2'
gem 'fluent-plugin-grafana-loki', '1.2.20'
gem 'fluent-plugin-kinesis', '3.4.2'
gem 'fluent-plugin-splunk-hec', '1.3.3'
gem 'fluent-plugin-elasticsearch', '5.4.2'
gem 'fluent-plugin-newrelic', '1.2.2'
gem 'fluent-plugin-cloudwatch-logs', '0.14.3'
gem 'fluent-plugin-opensearch', '1.1.4'
gem 'fluent-plugin-logzio', '0.2.2'
gem 'fluent-plugin-datadog', '0.14.2'
gem 'fluent-plugin-redis', '0.3.5'
gem 'fluent-plugin-gelf-hs', '1.0.8'
gem 'fluent-plugin-sqs', '3.0.0'
gem 'fluent-plugin-mattermost', '0.2.2'
gem 'fluent-plugin-remote-syslog', '1.1.0'
gem 'fluent-plugin-webhdfs', '1.5.0'
gem 'fluent-plugin-vmware-loginsight', '1.4.2'
gem 'fluent-plugin-vmware-log-intelligence', '2.0.8'
#gem 'fluent-plugin-aws-elasticsearch-service', '2.4.1'
#gem 'fluent-plugin-logdna', '~> 0.4.0'
Loading

0 comments on commit 9f0811c

Please sign in to comment.