From 9873607d36f974114da1177451761ee053e38d71 Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Fri, 29 May 2015 14:35:48 -0700 Subject: Install fluentd on nodes and master * Configure fluentd to aggragate container logs --- roles/fluentd_node/tasks/main.yml | 48 ++++++++++++++++++++++ roles/fluentd_node/templates/kubernetes.conf.j2 | 53 +++++++++++++++++++++++++ roles/fluentd_node/templates/td-agent.j2 | 2 + 3 files changed, 103 insertions(+) create mode 100644 roles/fluentd_node/tasks/main.yml create mode 100644 roles/fluentd_node/templates/kubernetes.conf.j2 create mode 100644 roles/fluentd_node/templates/td-agent.j2 (limited to 'roles/fluentd_node') diff --git a/roles/fluentd_node/tasks/main.yml b/roles/fluentd_node/tasks/main.yml new file mode 100644 index 000000000..951c5a229 --- /dev/null +++ b/roles/fluentd_node/tasks/main.yml @@ -0,0 +1,48 @@ +--- +# TODO: Update fluentd install and configuration when packaging is complete +- name: download and install td-agent + yum: + name: 'http://packages.treasuredata.com/2/redhat/7/x86_64/td-agent-2.2.0-0.x86_64.rpm' + state: present + +- name: install Kubernetes fluentd plugin + command: '/opt/td-agent/embedded/bin/gem install fluent-plugin-kubernetes' + +- name: Override td-agent configuration file + template: + src: td-agent.j2 + dest: /etc/sysconfig/td-agent + group: 'td-agent' + owner: 'td-agent' + mode: 0444 + +- name: Creates directories + file: + path: "{{ item }}" + state: directory + group: 'td-agent' + owner: 'td-agent' + mode: 0755 + with_items: ['/etc/td-agent/config.d', '/var/log/td-agent/tmp'] + +- name: Add include to td-agent configuration + lineinfile: + dest: '/etc/td-agent/td-agent.conf' + regexp: '^@include config.d' + line: '@include config.d/*.conf' + state: present + +- name: install Kubernetes fluentd configuration file + template: + src: kubernetes.conf.j2 + dest: /etc/td-agent/config.d/kubernetes.conf + group: 'td-agent' + owner: 'td-agent' + mode: 0444 + +- name: ensure td-agent is running + service: + name: 'td-agent' + state: started + enabled: yes + diff --git a/roles/fluentd_node/templates/kubernetes.conf.j2 b/roles/fluentd_node/templates/kubernetes.conf.j2 new file mode 100644 index 000000000..5f1eecb20 --- /dev/null +++ b/roles/fluentd_node/templates/kubernetes.conf.j2 @@ -0,0 +1,53 @@ + + type tail + path /var/lib/docker/containers/*/*-json.log + pos_file /var/log/td-agent/tmp/fluentd-docker.pos + time_format %Y-%m-%dT%H:%M:%S + tag docker.* + format json + read_from_head true + + + + type kubernetes + container_id ${tag_parts[5]} + tag docker.${name} + + + + type copy + + + type forward + send_timeout 60s + recover_wait 10s + heartbeat_interval 1s + phi_threshold 16 + hard_timeout 60s + log_level trace + require_ack_response true + heartbeat_type tcp + + + name {{groups['oo_first_master'][0]}} + host {{hostvars[groups['oo_first_master'][0]].openshift.common.hostname}} + port 24224 + weight 60 + + + + type file + path /var/log/td-agent/forward-failed + + + + + type file + path /var/log/td-agent/containers.log + time_slice_format %Y%m%d + time_slice_wait 10m + time_format %Y%m%dT%H%M%S%z + compress gzip + utc + + diff --git a/roles/fluentd_node/templates/td-agent.j2 b/roles/fluentd_node/templates/td-agent.j2 new file mode 100644 index 000000000..7245e11ec --- /dev/null +++ b/roles/fluentd_node/templates/td-agent.j2 @@ -0,0 +1,2 @@ +DAEMON_ARGS= +TD_AGENT_ARGS="/usr/sbin/td-agent --log /var/log/td-agent/td-agent.log --use-v1-config" -- cgit v1.2.3 From 5ecbe78c384a134620180a0a6e10a997acf4005e Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Mon, 1 Jun 2015 15:37:50 -0700 Subject: * Do not reinstall gem if it exists --- roles/fluentd_node/tasks/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'roles/fluentd_node') diff --git a/roles/fluentd_node/tasks/main.yml b/roles/fluentd_node/tasks/main.yml index 951c5a229..2526057cb 100644 --- a/roles/fluentd_node/tasks/main.yml +++ b/roles/fluentd_node/tasks/main.yml @@ -5,8 +5,14 @@ name: 'http://packages.treasuredata.com/2/redhat/7/x86_64/td-agent-2.2.0-0.x86_64.rpm' state: present +- name: Verify fluentd plugin installed + command: '/opt/td-agent/embedded/bin/gem query -i fluent-plugin-kubernetes' + register: _fluent_plugin_check + ignore_errors: yes + - name: install Kubernetes fluentd plugin command: '/opt/td-agent/embedded/bin/gem install fluent-plugin-kubernetes' + when: _fluent_plugin_check.rc == 1 - name: Override td-agent configuration file template: -- cgit v1.2.3