diff --git a/contrib/logging/fluentd-gcp-image/Dockerfile b/contrib/logging/fluentd-gcp-image/Dockerfile index c7339a16dc4..10897f4ecf5 100644 --- a/contrib/logging/fluentd-gcp-image/Dockerfile +++ b/contrib/logging/fluentd-gcp-image/Dockerfile @@ -3,34 +3,32 @@ # and then cause them to be ingested using the Google Cloud # Logging API. This configuration assumes that the host performning # the collection is a VM that has been created with a logging.write -# scope. +# scope and that the Logging API has been enabled for the project +# in the Google Developer Console. FROM ubuntu:14.04 MAINTAINER Satnam Singh "satnam@google.com" -# Ensure there are enough file descriptors for running Fluentd. -RUN ulimit -n 65536 +# Disable prompts from apt. +ENV DEBIAN_FRONTEND noninteractive +ENV OPTS_APT -y --force-yes --no-install-recommends -# Install prerequisites. -RUN apt-get update && \ - apt-get install -y curl && \ - apt-get install -y -q libcurl4-openssl-dev make && \ +RUN apt-get -q update && \ + apt-get -y install apt-utils adduser && \ apt-get clean -# Install Fluentd. -RUN /usr/bin/curl -L http://toolbelt.treasuredata.com/sh/install-ubuntu-trusty-td-agent2.sh | sh +ADD google-fluentd_1.0.0-0_amd64.deb /etc/google-fluentd/pkg/google-fluentd_1.0.0-0_amd64.deb +RUN dpkg -i /etc/google-fluentd/pkg/google-fluentd_1.0.0-0_amd64.deb +RUN /opt/google-fluentd/embedded/bin/gem install google-api-client +ADD out_google_cloud.rb /etc/google-fluentd/plugin/out_google_cloud.rb +ADD agent.conf /etc/google-fluentd/google-fluentd.conf +COPY catch-all-inputs.tar.gz /tmp/catch-all-inputs.tar.gz +RUN tar -C /etc/google-fluentd -zxf /tmp/catch-all-inputs.tar.gz +RUN sed -i~ -e "s/\(USER\|GROUP\)=google-fluentd/\1=root/;" /etc/init.d/google-fluentd +RUN sed -i~ -e 's/ --use-v1-config//' /etc/init.d/google-fluentd -# Change the default user and group to root. -# Needed to allow access to /var/log/docker/... files. -RUN sed -i -e "s/USER=td-agent/USER=root/" -e "s/GROUP=td-agent/GROUP=root/" /etc/init.d/td-agent -# Supress use of V1 config. -RUN sed -i~ -e 's/ --use-v1-config//' /etc/init.d/td-agent +# Copy the Fluentd configuration file for logging Docker container logs. +COPY google-fluentd.conf /etc/google-fluentd/google-fluentd.conf -# Install GCP logging plug-in for Fluentd. -RUN gsutil cp gs://signals-agents/out_google_cloud.rb /etc/td-agent/plugin - -# Copy the Fluentd configuration file. -COPY td-agent.conf /etc/td-agent/td-agent.conf - -# Run Fluentd in the foreground. -ENTRYPOINT ["/usr/sbin/td-agent"] +# Start Fluentd to pick up our config that watches Docker container logs. +CMD /usr/sbin/google-fluentd > /var/log/google-fluentd.log \ No newline at end of file diff --git a/contrib/logging/fluentd-gcp-image/Makefile b/contrib/logging/fluentd-gcp-image/Makefile new file mode 100644 index 00000000000..0a1b2b842ca --- /dev/null +++ b/contrib/logging/fluentd-gcp-image/Makefile @@ -0,0 +1,13 @@ +# 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. +# Satnam Singh (satnam@google.com) + +.PHONY: build push + +build: + sudo docker build -t kubernetes/fluentd-gcp . + +push: + sudo docker push kubernetes/fluentd-gcp + diff --git a/contrib/logging/fluentd-gcp-image/build.sh b/contrib/logging/fluentd-gcp-image/build.sh deleted file mode 100644 index 7d162d3adc3..00000000000 --- a/contrib/logging/fluentd-gcp-image/build.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# Copyright 2014 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# Build the fluentd-gcp image. -sudo docker build -t kubernetes/fluentd-gcp . diff --git a/contrib/logging/fluentd-gcp-image/td-agent.conf b/contrib/logging/fluentd-gcp-image/google-fluentd.conf similarity index 95% rename from contrib/logging/fluentd-gcp-image/td-agent.conf rename to contrib/logging/fluentd-gcp-image/google-fluentd.conf index 765e6bac3ab..dd315cd1a8f 100644 --- a/contrib/logging/fluentd-gcp-image/td-agent.conf +++ b/contrib/logging/fluentd-gcp-image/google-fluentd.conf @@ -17,6 +17,7 @@ format none time_key time path /var/lib/docker/containers/*/*-json.log + pos_file /var/lib/docker/containers/containers.log.pos time_format %Y-%m-%dT%H:%M:%S tag docker.container.* diff --git a/contrib/logging/fluentd-gcp-image/push.sh b/contrib/logging/fluentd-gcp-image/push.sh deleted file mode 100755 index 611c2781b09..00000000000 --- a/contrib/logging/fluentd-gcp-image/push.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -# Copyright 2014 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -sudo docker push kubernetes/fluentd-gcp