Skip to content

Commit

Permalink
Docker Logging Driver (#663)
Browse files Browse the repository at this point in the history
* adds first version of docker driver

* without logrus and fixes some linter issue

* fix the driver and start a build system

* adds swarm label discovery

* Add documentation and more targets

* make the linter happy ❤️

* indent config.json

* with circleci steps for master and branch

* Review Feebacks
  • Loading branch information
cyriltovena committed Jun 13, 2019
1 parent 7cfce6e commit 2909fe5
Show file tree
Hide file tree
Showing 340 changed files with 36,723 additions and 8 deletions.
16 changes: 16 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ jobs:
make push-images
fi
- run:
name: Push Docker Plugin
command: |
if [ -n "$DOCKER_USER" ]; then
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS" &&
make push-plugin
fi
publish-master:
<<: *defaults
steps:
Expand All @@ -151,6 +159,14 @@ jobs:
command: |
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS" &&
make push-latest
- run:
name: Push Docker Plugin
command: |
if [ -n "$DOCKER_USER" ]; then
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS" &&
PLUGIN_TAG=master make push-plugin && PLUGIN_TAG=latest make push-plugin
fi
test-helm:
environment:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ cmd/loki/loki
cmd/promtail/promtail
cmd/loki/loki-debug
cmd/promtail/promtail-debug
cmd/docker-driver/docker-driver
/loki
/promtail
/logcli
dlv
dlv
rootfs/
183 changes: 180 additions & 3 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 25 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

.PHONY: all test clean images protos assets check_assets release-prepare release-perform
.DEFAULT_GOAL := all

Expand Down Expand Up @@ -32,7 +33,7 @@ GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
DONT_FIND := -name tools -prune -o -name vendor -prune -o -name .git -prune -o -name .cache -prune -o -name .pkg -prune -o

# Get a list of directories containing Dockerfiles
DOCKERFILES := $(shell find . $(DONT_FIND) -type f -name 'Dockerfile' -print)
DOCKERFILES := $(shell find . -name docker-driver -prune -o $(DONT_FIND) -type f -name 'Dockerfile' -print)
UPTODATE_FILES := $(patsubst %/Dockerfile,%/$(UPTODATE),$(DOCKERFILES))
DEBUG_DOCKERFILES := $(shell find . $(DONT_FIND) -type f -name 'Dockerfile.debug' -print)
DEBUG_UPTODATE_FILES := $(patsubst %/Dockerfile.debug,%/$(DEBUG_UPTODATE),$(DEBUG_DOCKERFILES))
Expand Down Expand Up @@ -90,7 +91,7 @@ vendor/github.com/cortexproject/cortex/pkg/ingester/client/cortex.pb.go: vendor/
vendor/github.com/cortexproject/cortex/pkg/chunk/storage/caching_index_client.pb.go: vendor/github.com/cortexproject/cortex/pkg/chunk/storage/caching_index_client.proto
pkg/promtail/server/server.go: assets
pkg/logql/expr.go: pkg/logql/expr.y
all: $(UPTODATE_FILES)
all: $(UPTODATE_FILES) build-plugin
test: $(PROTO_GOS) $(YACC_GOS)
debug: $(DEBUG_UPTODATE_FILES)
yacc: $(YACC_GOS)
Expand Down Expand Up @@ -289,4 +290,25 @@ helm-upgrade: helm


helm-clean:
-helm delete --purge loki-stack
-helm delete --purge loki-stack

PLUGIN_FOLDER = ./cmd/docker-driver
PLUGIN_TAG ?= $(IMAGE_TAG)

build-plugin: $(PLUGIN_FOLDER)/docker-driver
-docker plugin disable grafana/loki-docker-driver:$(IMAGE_TAG)
-docker plugin rm grafana/loki-docker-driver:$(IMAGE_TAG)
-rm -rf $(PLUGIN_FOLDER)/rootfs
mkdir $(PLUGIN_FOLDER)/rootfs
docker build -t rootfsimage $(PLUGIN_FOLDER)
ID=$$(docker create rootfsimage true) && \
(docker export $$ID | tar -x -C $(PLUGIN_FOLDER)/rootfs) && \
docker rm -vf $$ID
docker rmi rootfsimage -f
docker plugin create grafana/loki-docker-driver:$(PLUGIN_TAG) $(PLUGIN_FOLDER)

push-plugin: build-plugin
docker plugin push grafana/loki-docker-driver:$(PLUGIN_TAG)

enable-plugin:
docker plugin enable grafana/loki-docker-driver:$(PLUGIN_TAG)
Loading

0 comments on commit 2909fe5

Please sign in to comment.