aboutsummaryrefslogtreecommitdiff
path: root/docker/fluentd/Dockerfile.j2
blob: 132508014c82bdcd71112c041b4805dc6a2603ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
FROM {{ namespace }}/{{ image_prefix }}base:{{ tag }}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"

{% block fluentd_header %}{% endblock %}

{% import "macros.j2" as macros with context %}

{% if base_distro in ['centos', 'oraclelinux', 'rhel'] %}

    {{ macros.configure_user(name='fluentd', groups='mysql') }}
# TODO:remove hostname package as it should be installed by the
# fluentd dependencies.
# hostname package is installed by default on CentOS/RHEL but not on
# oraclelinux.

    {% set fluentd_packages = [
        'fluentd',
        'gcc-c++',
        'hostname',
        'make',
        'ruby-devel'
    ] %}

{% elif base_distro in ['debian', 'ubuntu'] %}
    {{ macros.configure_user(name='td-agent', groups='mysql') }}
    {% set fluentd_packages = [
        'g++',
        'make',
        'td-agent'
    ] %}

{% endif %}

{{ macros.install_packages(fluentd_packages | customizable("packages")) }}

# Distro specific files and operations
{% if base_distro in  ['centos', 'oraclelinux', 'rhel'] %}
COPY rpm_fluentd_sudoers /etc/sudoers.d/kolla_fluentd_sudoers
RUN chmod 440 /etc/sudoers.d/kolla_fluentd_sudoers \
    && mkdir -p /var/run/fluentd \
    && chown -R fluentd: /etc/fluentd /var/run/fluentd
{% elif base_distro in ['debian', 'ubuntu'] %}
COPY fluentd_sudoers /etc/sudoers.d/kolla_fluentd_sudoers
RUN chmod 440 /etc/sudoers.d/kolla_fluentd_sudoers \
    && sed -i -e "s/USER=td-agent/USER=root/" -e "s/GROUP=td-agent/GROUP=root/" /etc/init.d/td-agent \
    && rm -f /etc/td-agent/td-agent.conf \
    && chown -R td-agent: /etc/td-agent
{% endif %}


COPY extend_start.sh /usr/local/bin/kolla_extend_start
RUN chmod 755 /usr/local/bin/kolla_extend_start

{% block fluentd_plugins_install %}


{% set fluentd_plugins = [
    'fluent-plugin-parser',
    'fluent-plugin-kubernetes_metadata_filter',
    'fluent-plugin-grep',
    'fluent-plugin-secure-forward'
] %}

{% if base_distro in  ['centos', 'oraclelinux', 'rhel'] %}
    # NOTE: We use fluentd version is v12.0 so fluent-plugin-grok-parse version should be < 1.0.0.
    # https://github.com/fluent/fluent-plugin-grok-parser
    {% set fluentd_plugins = [
        'activesupport:4.2.9',
        'public_suffix:2.0.5',
        'fluent-plugin-elasticsearch:1.10.2',
        'fluent-plugin-grok-parser:0.3.1',
        'fluent-plugin-rewrite-tag-filter:1.6.0'
    ] + fluentd_plugins  %}
{% elif base_distro in ['debian', 'ubuntu'] %}
    {% set fluentd_plugins = [
        'fluent-plugin-elasticsearch',
        'fluent-plugin-grok-parser:2.1.4',
        'fluent-plugin-rewrite-tag-filter:2.0.0'
    ] + fluentd_plugins %}
{% endif %}

{{ macros.install_fluent_plugins(fluentd_plugins | customizable("plugins")) }}

{% endblock %}

{% block fluentd_footer %}{% endblock %}
{% block footer %}{% endblock %}

{% if base_distro in ['centos', 'oraclelinux', 'rhel'] %}
USER fluentd
{% elif base_distro in ['debian', 'ubuntu'] %}
USER td-agent
{% endif %}