From 6215089796b62ef08ad4650b47c72220672dd9ee Mon Sep 17 00:00:00 2001 From: Mik Vyatskov Date: Wed, 30 Nov 2016 11:41:54 +0100 Subject: [PATCH] Unify fluentd-gcp configurations --- .../fluentd-gcp/fluentd-gcp-image/Dockerfile | 12 +- .../fluentd-gcp/fluentd-gcp-image/Makefile | 17 +- ...oogle-fluentd-journal.conf => fluent.conf} | 8 - .../fluentd-gcp-image/google-fluentd.conf | 272 ------------------ .../fluentd-gcp/fluentd-gcp-image/run.sh | 29 ++ 5 files changed, 42 insertions(+), 296 deletions(-) rename cluster/addons/fluentd-gcp/fluentd-gcp-image/{google-fluentd-journal.conf => fluent.conf} (97%) delete mode 100644 cluster/addons/fluentd-gcp/fluentd-gcp-image/google-fluentd.conf create mode 100755 cluster/addons/fluentd-gcp/fluentd-gcp-image/run.sh diff --git a/cluster/addons/fluentd-gcp/fluentd-gcp-image/Dockerfile b/cluster/addons/fluentd-gcp/fluentd-gcp-image/Dockerfile index 203cc45288cd6..164cc1de5b26e 100644 --- a/cluster/addons/fluentd-gcp/fluentd-gcp-image/Dockerfile +++ b/cluster/addons/fluentd-gcp/fluentd-gcp-image/Dockerfile @@ -50,11 +50,11 @@ RUN apt-get -qq update && \ /opt/td-agent/embedded/share/postgresql \ /etc/td-agent/td-agent.conf -# Copy the Fluentd configuration files for logging Docker container logs. -# Either configuration file can be used by specifying `-c ` as a command -# line argument. -COPY google-fluentd.conf /etc/td-agent/td-agent.conf -COPY google-fluentd-journal.conf /etc/td-agent/td-agent-journal.conf +# Copy the Fluentd configuration file for logging Docker container logs. +COPY fluent.conf /etc/td-agent/td-agent.conf + +# Copy the entrypoint for the container +COPY run.sh /run.sh # Start Fluentd to pick up our config that watches Docker container logs. -CMD /usr/sbin/td-agent $FLUENTD_ARGS +CMD /run.sh $FLUENTD_ARGS diff --git a/cluster/addons/fluentd-gcp/fluentd-gcp-image/Makefile b/cluster/addons/fluentd-gcp/fluentd-gcp-image/Makefile index 703bb2de2a72e..400d8b2210632 100644 --- a/cluster/addons/fluentd-gcp/fluentd-gcp-image/Makefile +++ b/cluster/addons/fluentd-gcp/fluentd-gcp-image/Makefile @@ -13,23 +13,20 @@ # limitations under the License. # The build rule builds a Docker image that logs all Docker contains logs to -# Google Compute Platform using the Cloud Logging API. The push rule pushes -# the image to DockerHub. +# Google Compute Platform using the Cloud Logging API. # Procedure for change: # 1. Bump the tag number. -# 2. Create an image for the kubernetes user on Dockerhub and push there: make kbuild kpush -# 3. Temporarily adjust any config files etc. that reference gcr.io/google_containers/fluentd-gcp:$(TAG) -# to use kubernetes/fluentd-gcp:$(TAG) instead. -# 4. Test etc. -# 5. Issue PR. -# 6. When PR is approved make the gcr.io version of the image: make build push -# 7. Revert the referendes to kubernetes/fluentd-gcp:$(TAG) to gcr.io/google_containers/fluentd-gcp:$(TAG) +# 2. Push to the private repo and test using newer version +# 3. Issue PR. +# 4. Assuming permissions to do so, when PR is approved +# make the gcr.io version of the image: make build push +# 5. Issue PR with config files changes .PHONY: build push PREFIX=gcr.io/google_containers -TAG = 1.28 +TAG = 1.29 build: docker build -t $(PREFIX)/fluentd-gcp:$(TAG) . diff --git a/cluster/addons/fluentd-gcp/fluentd-gcp-image/google-fluentd-journal.conf b/cluster/addons/fluentd-gcp/fluentd-gcp-image/fluent.conf similarity index 97% rename from cluster/addons/fluentd-gcp/fluentd-gcp-image/google-fluentd-journal.conf rename to cluster/addons/fluentd-gcp/fluentd-gcp-image/fluent.conf index d3b7cdfc3c75c..3c6b01e89e880 100644 --- a/cluster/addons/fluentd-gcp/fluentd-gcp-image/google-fluentd-journal.conf +++ b/cluster/addons/fluentd-gcp/fluentd-gcp-image/fluent.conf @@ -5,9 +5,6 @@ # pod name and container name. These logs are then submitted to # Google Cloud Logging which assumes the installation of the cloud-logging plug-in. # -# This configuration is almost identical to google-fluentd.conf, with the one -# difference being that this collects systemd journal logs. -# # Example # ======= # A line in the Docker log file might like like this JSON: @@ -42,11 +39,6 @@ # the name of the Kubernetes container regardless of how many times the # Kubernetes pod has been restarted (resulting in a several Docker container IDs). -# Do not directly collect fluentd's own logs to avoid infinite loops. - - type null - - # Example: # {"log":"[info:2016-02-16T16:04:05.930-08:00] Some log text here\n","stream":"stdout","time":"2016-02-17T00:04:05.931087621Z"} diff --git a/cluster/addons/fluentd-gcp/fluentd-gcp-image/google-fluentd.conf b/cluster/addons/fluentd-gcp/fluentd-gcp-image/google-fluentd.conf deleted file mode 100644 index f5979201c1599..0000000000000 --- a/cluster/addons/fluentd-gcp/fluentd-gcp-image/google-fluentd.conf +++ /dev/null @@ -1,272 +0,0 @@ -# This configuration file for Fluentd / td-agent is used -# to watch changes to Docker log files that live in the -# directory /var/lib/docker/containers/ and are symbolically -# linked to from the /var/log directory using names that capture the -# pod name and container name. These logs are then submitted to -# Google Cloud Logging which assumes the installation of the cloud-logging plug-in. -# -# This configuration is almost identical to google-fluentd-journal.conf, with -# the one difference being that this doesn't try to collect systemd journal -# logs. -# -# Example -# ======= -# A line in the Docker log file might like like this JSON: -# -# {"log":"2014/09/25 21:15:03 Got request with path wombat\n", -# "stream":"stderr", -# "time":"2014-09-25T21:15:03.499185026Z"} -# -# The record reformer is used to write the tag to focus on the pod name -# and the Kubernetes container name. For example a Docker container's logs -# might be in the directory: -# /var/lib/docker/containers/997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b -# and in the file: -# 997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b-json.log -# where 997599971ee6... is the Docker ID of the running container. -# The Kubernetes kubelet makes a symbolic link to this file on the host machine -# in the /var/log/containers directory which includes the pod name and the Kubernetes -# container name: -# synthetic-logger-0.25lps-pod_default-synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log -# -> -# /var/lib/docker/containers/997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b/997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b-json.log -# The /var/log directory on the host is mapped to the /var/log directory in the container -# running this instance of Fluentd and we end up collecting the file: -# /var/log/containers/synthetic-logger-0.25lps-pod_default-synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log -# This results in the tag: -# var.log.containers.synthetic-logger-0.25lps-pod_default-synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log -# The record reformer is used is discard the var.log.containers prefix and -# the Docker container ID suffix and "kubernetes." is pre-pended giving the -# final tag which is ingested into Elasticsearch: -# kubernetes.synthetic-logger-0.25lps-pod_default-synth-lgr -# This makes it easier for users to search for logs by pod name or by -# the name of the Kubernetes container regardless of how many times the -# Kubernetes pod has been restarted (resulting in a several Docker container IDs). - -# Do not directly collect fluentd's own logs to avoid infinite loops. - - type null - - -# Example: -# {"log":"[info:2016-02-16T16:04:05.930-08:00] Some log text here\n","stream":"stdout","time":"2016-02-17T00:04:05.931087621Z"} - - type tail - format json - time_key time - path /var/log/containers/*.log - pos_file /var/log/gcp-containers.log.pos - time_format %Y-%m-%dT%H:%M:%S.%NZ - tag reform.* - read_from_head true - - - - type record_reformer - enable_ruby true - tag kubernetes.${tag_suffix[4].split('-')[0..-2].join('-')} - - -# Example: -# 2015-12-21 23:17:22,066 [salt.state ][INFO ] Completed state [net.ipv4.ip_forward] at time 23:17:22.066081 - - type tail - format /^(?