From 6a55c14f936861e6c7379e6b256832d948703bba Mon Sep 17 00:00:00 2001 From: Rock Baek Date: Fri, 21 Feb 2020 15:20:46 -0800 Subject: [PATCH 1/3] change plugin install --- .circleci/build_and_push_to_dockerhub.sh | 8 ++------ Rakefile | 3 +-- docker/Dockerfile | 14 +++++++------- docker/README.md | 2 +- docker/build.sh | 14 +------------- 5 files changed, 12 insertions(+), 29 deletions(-) diff --git a/.circleci/build_and_push_to_dockerhub.sh b/.circleci/build_and_push_to_dockerhub.sh index 4a9765c..29f6041 100755 --- a/.circleci/build_and_push_to_dockerhub.sh +++ b/.circleci/build_and_push_to_dockerhub.sh @@ -1,12 +1,8 @@ #!/usr/bin/env bash set -e -echo "Building docker image..." -cp /tmp/pkg/fluent-plugin-kubernetes-metrics-*.gem docker -echo "Copying licenses to be included in the docker image..." -mkdir docker/licenses -cp -rp LICENSE docker/licenses/ + VERSION=`cat VERSION` -docker build --build-arg VERSION=$VERSION --no-cache -t splunk/fluent-plugin-kubernetes-metrics:ci ./docker +docker build --build-arg VERSION=$VERSION --no-cache -t splunk/fluent-plugin-kubernetes-metrics:ci -f docker/Dockerfile . docker tag splunk/fluent-plugin-kubernetes-metrics:ci splunk/${DOCKERHUB_REPO_NAME}:${VERSION} docker tag splunk/fluent-plugin-kubernetes-metrics:ci splunk/${DOCKERHUB_REPO_NAME}:latest echo "Push docker image to splunk dockerhub..." diff --git a/Rakefile b/Rakefile index a1eb595..0a8e37e 100644 --- a/Rakefile +++ b/Rakefile @@ -23,7 +23,6 @@ namespace :docker do task :build, [:tag] => :build do |_t, args| raise 'Argument `tag` was not provided.' unless args.tag - cp Dir['pkg/fluent-plugin-kubernetes-metrics-*.gem'], 'docker/' - sh "docker build --build-arg VERSION=$(cat VERSION) --no-cache -t splunk/connect-for-kubernetes:#{args.tag} ./docker" + sh "docker build --build-arg VERSION=$(cat VERSION) --no-cache -t splunk/connect-for-kubernetes:#{args.tag} -f docker/Dockerfile ." end end diff --git a/docker/Dockerfile b/docker/Dockerfile index 811b812..288ce92 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -17,18 +17,18 @@ ENV FLUENT_USER fluent USER root -COPY *.gem /tmp/ -COPY licenses /licenses +COPY lib/fluent/plugin/*.rb /tmp/ +COPY LICENSE /licenses/ -COPY Gemfile* ./ +COPY docker/Gemfile* ./ RUN gem install bundler \ - && bundle install \ - && bundle exec gem install /tmp/*.gem + && bundle install RUN groupadd -r $FLUENT_USER && \ useradd -r -g $FLUENT_USER $FLUENT_USER && \ - mkdir -p /fluentd/log fluentd/etc /fluentd/plugins &&\ + mkdir -p /fluentd/log fluentd/etc /fluentd/plugins && \ + cp /tmp/*.rb /fluentd/plugins/ && \ chown -R $FLUENT_USER /fluentd && chgrp -R $FLUENT_USER /fluentd USER $FLUENT_USER -CMD exec fluentd -c /fluentd/etc/fluent.conf +CMD exec fluentd -p /fluentd/plugins -c /fluentd/etc/fluent.conf diff --git a/docker/README.md b/docker/README.md index 78cf954..728302c 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,4 +1,4 @@ # Docker Image for Splunk Connect for Kubernetes Fluentd with input plugin for k8s metrics # To Build -`docker build --build-arg VERSION=$(cat VERSION) --no-cache -t splunk/fluent-plugin-kubernetes-metrics:ci ./docker` \ No newline at end of file +`docker build --build-arg VERSION=$(cat VERSION) --no-cache -t splunk/splunk/k8s-metrics:local -f docker/Dockerfile .` \ No newline at end of file diff --git a/docker/build.sh b/docker/build.sh index 8ef4c2b..dd28b89 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -2,18 +2,6 @@ set -e TAG=$1 -# Install dependecies -gem install bundler -bundle update --bundler -bundle install - -# Build Gem -bundle exec rake build -t -v -cp pkg/fluent-plugin-kubernetes-metrics-*.gem docker - # Build Docker Image VERSION=`cat VERSION` -echo "Copying licenses to be included in the docker image..." -mkdir -p docker/licenses -cp -rp LICENSE docker/licenses/ -docker build --build-arg VERSION=$VERSION --no-cache -t splunk/k8s-metrics:$TAG ./docker +docker build --build-arg VERSION=$VERSION --no-cache -t splunk/k8s-metrics:$TAG -f docker/Dockerfile . From aa8a241eceaa9c2e426fd0d5f55e92522198bb74 Mon Sep 17 00:00:00 2001 From: Rock Baek Date: Mon, 24 Feb 2020 22:53:43 -0800 Subject: [PATCH 2/3] consistent build steps with other plugins --- .circleci/build_and_push_to_dockerhub.sh | 8 ++++++-- .gitignore | 1 + Rakefile | 2 +- docker/Dockerfile | 12 ++++++------ docker/Gemfile | 2 ++ docker/Gemfile.lock | 11 +++++++++++ docker/README.md | 2 +- docker/build.sh | 14 +++++++++++++- 8 files changed, 41 insertions(+), 11 deletions(-) diff --git a/.circleci/build_and_push_to_dockerhub.sh b/.circleci/build_and_push_to_dockerhub.sh index 29f6041..6b1582f 100755 --- a/.circleci/build_and_push_to_dockerhub.sh +++ b/.circleci/build_and_push_to_dockerhub.sh @@ -1,8 +1,12 @@ #!/usr/bin/env bash set -e - +echo "Building docker image..." +cp /tmp/pkg/fluent-plugin-kubernetes-objects-*.gem docker VERSION=`cat VERSION` -docker build --build-arg VERSION=$VERSION --no-cache -t splunk/fluent-plugin-kubernetes-metrics:ci -f docker/Dockerfile . +echo "Copying licenses to be included in the docker image..." +mkdir docker/licenses +cp -rp LICENSE docker/licenses/ +docker build --build-arg VERSION=$VERSION --no-cache -t splunk/fluent-plugin-kubernetes-metrics:ci ./docker docker tag splunk/fluent-plugin-kubernetes-metrics:ci splunk/${DOCKERHUB_REPO_NAME}:${VERSION} docker tag splunk/fluent-plugin-kubernetes-metrics:ci splunk/${DOCKERHUB_REPO_NAME}:latest echo "Push docker image to splunk dockerhub..." diff --git a/.gitignore b/.gitignore index a21f250..1f2a87d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ pkg coverage/ .idea/ docker/gems/ +docker/gem/ docker/licenses/ /.bundle/ docker/.bundle/ \ No newline at end of file diff --git a/Rakefile b/Rakefile index 0a8e37e..4793b50 100644 --- a/Rakefile +++ b/Rakefile @@ -23,6 +23,6 @@ namespace :docker do task :build, [:tag] => :build do |_t, args| raise 'Argument `tag` was not provided.' unless args.tag - sh "docker build --build-arg VERSION=$(cat VERSION) --no-cache -t splunk/connect-for-kubernetes:#{args.tag} -f docker/Dockerfile ." + sh "docker build --build-arg VERSION=$(cat VERSION) --no-cache -t splunk/connect-for-kubernetes:#{args.tag} ./docker" end end diff --git a/docker/Dockerfile b/docker/Dockerfile index 288ce92..c7049b0 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -17,18 +17,18 @@ ENV FLUENT_USER fluent USER root -COPY lib/fluent/plugin/*.rb /tmp/ -COPY LICENSE /licenses/ +COPY *.gem /tmp/ +COPY licenses /licenses -COPY docker/Gemfile* ./ +COPY Gemfile* ./ RUN gem install bundler \ + && gem unpack /tmp/*.gem --target gem \ && bundle install RUN groupadd -r $FLUENT_USER && \ useradd -r -g $FLUENT_USER $FLUENT_USER && \ - mkdir -p /fluentd/log fluentd/etc /fluentd/plugins && \ - cp /tmp/*.rb /fluentd/plugins/ && \ + mkdir -p /fluentd/log /fluentd/etc /fluentd/plugins && \ chown -R $FLUENT_USER /fluentd && chgrp -R $FLUENT_USER /fluentd USER $FLUENT_USER -CMD exec fluentd -p /fluentd/plugins -c /fluentd/etc/fluent.conf +CMD bundle exec fluentd -c /fluentd/etc/fluent.conf diff --git a/docker/Gemfile b/docker/Gemfile index 538f8f7..c19f4dd 100644 --- a/docker/Gemfile +++ b/docker/Gemfile @@ -15,3 +15,5 @@ gem 'kubeclient', '=4.6.0' gem 'http_parser.rb', '=0.5.3' gem "fluent-plugin-splunk-hec", "= 1.2.1" + +gem "fluent-plugin-kubernetes-metrics", path: "gem/" \ No newline at end of file diff --git a/docker/Gemfile.lock b/docker/Gemfile.lock index ba3807d..fee3f76 100644 --- a/docker/Gemfile.lock +++ b/docker/Gemfile.lock @@ -1,3 +1,13 @@ +PATH + remote: gem + specs: + fluent-plugin-kubernetes-metrics (1.1.3) + fluentd (~> 1.9.1) + http_parser.rb (= 0.5.3) + kubeclient (~> 4.6.0) + multi_json (~> 1.14.1) + oj (~> 3.10.2) + GEM remote: https://rubygems.org/ specs: @@ -152,6 +162,7 @@ PLATFORMS DEPENDENCIES bigdecimal (= 2.0.0) fluent-plugin-jq (= 0.5.1) + fluent-plugin-kubernetes-metrics! fluent-plugin-prometheus (= 1.7.0) fluent-plugin-record-modifier (= 2.1.0) fluent-plugin-splunk-hec (= 1.2.1) diff --git a/docker/README.md b/docker/README.md index 728302c..eb64953 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,4 +1,4 @@ # Docker Image for Splunk Connect for Kubernetes Fluentd with input plugin for k8s metrics # To Build -`docker build --build-arg VERSION=$(cat VERSION) --no-cache -t splunk/splunk/k8s-metrics:local -f docker/Dockerfile .` \ No newline at end of file +`docker build --build-arg VERSION=$(cat VERSION) -t splunk/splunk/k8s-metrics:local ./docker` \ No newline at end of file diff --git a/docker/build.sh b/docker/build.sh index dd28b89..0eee27a 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -2,6 +2,18 @@ set -e TAG=$1 +# Install dependecies +gem install bundler +bundle update --bundler +bundle install + +# Build Gem +bundle exec rake build -t -v +cp pkg/fluent-plugin-kubernetes-objects-*.gem docker + # Build Docker Image VERSION=`cat VERSION` -docker build --build-arg VERSION=$VERSION --no-cache -t splunk/k8s-metrics:$TAG -f docker/Dockerfile . +echo "Copying licenses to be included in the docker image..." +mkdir -p docker/licenses +cp -rp LICENSE docker/licenses/ +docker build --build-arg VERSION=$VERSION --no-cache -t splunk/k8s-metrics:$TAG ./docker \ No newline at end of file From 0eedd1a7fb485f4f747c60e37b343f80689f4c54 Mon Sep 17 00:00:00 2001 From: Rock Baek Date: Tue, 25 Feb 2020 00:05:21 -0800 Subject: [PATCH 3/3] change objects to metrics --- .circleci/build_and_push_to_dockerhub.sh | 2 +- CONTRIBUTORS.md | 2 +- docker/build.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/build_and_push_to_dockerhub.sh b/.circleci/build_and_push_to_dockerhub.sh index 6b1582f..3c12bd1 100755 --- a/.circleci/build_and_push_to_dockerhub.sh +++ b/.circleci/build_and_push_to_dockerhub.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e echo "Building docker image..." -cp /tmp/pkg/fluent-plugin-kubernetes-objects-*.gem docker +cp /tmp/pkg/fluent-plugin-kubernetes-metrics-*.gem docker VERSION=`cat VERSION` echo "Copying licenses to be included in the docker image..." mkdir docker/licenses diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 79507e8..2414ce1 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -2,7 +2,7 @@ Fluentd Plugin for Kubernetes Metrics is developed by Splunkers and the open-source community. -We thank all of our [contributors](https://github.com/splunk/fluent-plugin-kubernetes-objects/graphs/contributors)! +We thank all of our [contributors](https://github.com/splunk/fluent-plugin-kubernetes-metrics/graphs/contributors)! **For the detailed history of contributions** of a given file, try diff --git a/docker/build.sh b/docker/build.sh index 0eee27a..ce52ac0 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -9,7 +9,7 @@ bundle install # Build Gem bundle exec rake build -t -v -cp pkg/fluent-plugin-kubernetes-objects-*.gem docker +cp pkg/fluent-plugin-kubernetes-metrics-*.gem docker # Build Docker Image VERSION=`cat VERSION`