kolla/docker/fluentd/Dockerfile.j2
Mark Goddard c585ca5055 Use td-agent-gem to install fluentd monasca plugin on ubuntu
If monasca is enabled on ubuntu, we see the following error in fluentd:

[error]: config error file="/etc/td-agent/td-agent.conf"
error_class=Fluent::ConfigError error="Unknown output plugin 'monasca'.
Run 'gem search -rd fluent-plugin' to find plugins"

This is because we use 'fluent-gem install' to install the gem, which
works on CentOS but on Ubuntu it is necessary to use 'td-agent-gem
install'.

Change-Id: I515f9764ca93a41a871e520696193a9298856d08
Closes-Bug: #1830147
2019-05-29 14:41:52 +00:00

116 lines
3.9 KiB
Django/Jinja

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_package_type == 'rpm' %}
{{ 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',
'rubygem-fluent-plugin-elasticsearch',
'rubygem-fluent-plugin-grok-parser',
'rubygem-fluent-plugin-kubernetes_metadata_filter',
'rubygem-fluent-plugin-rewrite-tag-filter',
'rubygem-fluent-plugin-secure-forward'
] %}
{% elif base_package_type == 'deb' %}
{% set fluentd_packages = [
'g++',
'make',
'ruby',
'ruby-dev',
] %}
{% if base_arch == 'x86_64' %}
{{ macros.configure_user(name='td-agent', groups='mysql') }}
{% set fluentd_packages = fluentd_packages + [
'td-agent'
] %}
{% else %}
{{ macros.configure_user(name='fluentd', groups='mysql') }}
{% endif %}
{% endif %}
{{ macros.install_packages(fluentd_packages | customizable("packages")) }}
{% if base_package_type == 'deb' and base_arch != 'x86_64' %}
RUN /usr/bin/gem install fluentd --no-rdoc --no-ri
{% endif %}
# Distro specific files and operations
{% if base_package_type == 'rpm' %}
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_package_type == 'deb' %}
{% if base_arch == 'x86_64' %}
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
{% else %}
COPY rpm_fluentd_sudoers /etc/sudoers.d/kolla_fluentd_sudoers
RUN chmod 440 /etc/sudoers.d/kolla_fluentd_sudoers \
&& mkdir -p /etc/fluentd \
&& mkdir -p /var/run/fluentd \
&& chown -R fluentd: /etc/fluentd /var/run/fluentd
{% endif %}
{% endif %}
COPY extend_start.sh /usr/local/bin/kolla_extend_start
RUN chmod 755 /usr/local/bin/kolla_extend_start
{% block fluentd_plugins_install %}
{% if base_package_type == 'deb' %}
{% set fluentd_plugins = [
'fluent-plugin-elasticsearch',
'fluent-plugin-grep',
'fluent-plugin-grok-parser:2.1.4',
'fluent-plugin-kubernetes_metadata_filter',
'fluent-plugin-parser',
'fluent-plugin-rewrite-tag-filter:2.0.0',
'fluent-plugin-secure-forward',
] %}
{% endif %}
{{ macros.install_fluent_plugins(fluentd_plugins | customizable("plugins")) }}
# Build and install Fluentd output plugin for Monasca Log API
ARG monasca_output_plugin_tag=0.1.0
ARG monasca_output_plugin_url=https://github.com/monasca/fluentd-monasca/archive/$monasca_output_plugin_tag.tar.gz
ADD $monasca_output_plugin_url /tmp/fluentd-monasca.tar.gz
RUN tar -xvf /tmp/fluentd-monasca.tar.gz -C /tmp \
&& cd /tmp/fluentd-monasca-* \
&& gem build fluentd-monasca-output.gemspec \
&& gem install fluentd-monasca-output-*.gem \
&& {{ macros.install_fluent_plugins(['fluentd-monasca-output-*.gem'], chain=True) }} \
&& rm -rf /tmp/fluentd*
{% endblock %}
{% block fluentd_footer %}{% endblock %}
{% block footer %}{% endblock %}
{% if base_package_type == 'rpm' or (base_package_type == 'deb' and base_arch != 'x86_64') %}
USER fluentd
{% elif base_package_type == 'deb' and base_arch == 'x86_64' %}
USER td-agent
{% endif %}