forked from fluent/fluentd-kubernetes-daemonset
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
445 lines (378 loc) · 15.6 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# This Makefile automates possible operations of this project.
#
# Images and description on Docker Hub will be automatically rebuilt on
# pushes to `master` branch of this repo and on updates of parent images.
#
# Note! Docker Hub `post_push` hook must be always up-to-date with values
# specified in current Makefile. To update it just use:
# make post-push-hook-all
#
# It's still possible to build, tag and push images manually. Just use:
# make release-all
IMAGE_NAME := fluent/fluentd-kubernetes
X86_IMAGES := \
v1.15/debian-azureblob:v1.15.1-debian-azureblob-amd64-1.1,v1.15-debian-azureblob-amd64-1 \
v1.15/debian-elasticsearch7:v1.15.1-debian-elasticsearch7-amd64-1.1,v1.15-debian-elasticsearch7-amd64-1,v1-debian-elasticsearch-amd64 \
v1.15/debian-elasticsearch6:v1.15.1-debian-elasticsearch6-amd64-1.1,v1.15-debian-elasticsearch6-amd64-1 \
v1.15/debian-opensearch:v1.15.1-debian-opensearch-amd64-1.1,v1.15-debian-opensearch-amd64-1 \
v1.15/debian-loggly:v1.15.1-debian-loggly-amd64-1.1,v1.15-debian-loggly-amd64-1 \
v1.15/debian-logentries:v1.15.1-debian-logentries-amd64-1.1,v1.15-debian-logentries-amd64-1 \
v1.15/debian-cloudwatch:v1.15.1-debian-cloudwatch-amd64-1.1,v1.15-debian-cloudwatch-amd64-1 \
v1.15/debian-stackdriver:v1.15.1-debian-stackdriver-amd64-1.1,v1.15-debian-stackdriver-amd64-1 \
v1.15/debian-s3:v1.15.1-debian-s3-amd64-1.1,v1.15-debian-s3-amd64-1 \
v1.15/debian-syslog:v1.15.1-debian-syslog-amd64-1.1,v1.15-debian-syslog-amd64-1 \
v1.15/debian-forward:v1.15.1-debian-forward-amd64-1.1,v1.15-debian-forward-amd64-1 \
v1.15/debian-gcs:v1.15.1-debian-gcs-amd64-1.1,v1.15-debian-gcs-amd64-1 \
v1.15/debian-graylog:v1.15.1-debian-graylog-amd64-1.1,v1.15-debian-graylog-amd64-1 \
v1.15/debian-papertrail:v1.15.1-debian-papertrail-amd64-1.1,v1.15-debian-papertrail-amd64-1 \
v1.15/debian-logzio:v1.15.1-debian-logzio-amd64-1.1,v1.15-debian-logzio-amd64-1 \
v1.15/debian-kafka:v1.15.1-debian-kafka-amd64-1.2,v1.15-debian-kafka-amd64-1 \
v1.15/debian-kafka2:v1.15.1-debian-kafka2-amd64-1.2,v1.15-debian-kafka2-amd64-1 \
v1.15/debian-kinesis:v1.15.1-debian-kinesis-amd64-1.1,v1.15-debian-kinesis-amd64-1
# <Dockerfile>:<version>,<tag1>,<tag2>,...
ARM64_IMAGES := \
v1.15/arm64/debian-azureblob:v1.15.1-debian-azureblob-arm64-1.1,v1.15-debian-azureblob-arm64-1 \
v1.15/arm64/debian-elasticsearch7:v1.15.1-debian-elasticsearch7-arm64-1.1,v1.15-debian-elasticsearch7-arm64-1,v1-debian-elasticsearch-arm64 \
v1.15/arm64/debian-elasticsearch6:v1.15.1-debian-elasticsearch6-arm64-1.1,v1.15-debian-elasticsearch6-arm64-1 \
v1.15/arm64/debian-opensearch:v1.15.1-debian-opensearch-arm64-1.1,v1.15-debian-opensearch-arm64-1 \
v1.15/arm64/debian-loggly:v1.15.1-debian-loggly-arm64-1.1,v1.15-debian-loggly-arm64-1 \
v1.15/arm64/debian-logentries:v1.15.1-debian-logentries-arm64-1.1,v1.15-debian-logentries-arm64-1 \
v1.15/arm64/debian-cloudwatch:v1.15.1-debian-cloudwatch-arm64-1.1,v1.15-debian-cloudwatch-arm64-1 \
v1.15/arm64/debian-stackdriver:v1.15.1-debian-stackdriver-arm64-1.1,v1.15-debian-stackdriver-arm64-1 \
v1.15/arm64/debian-s3:v1.15.1-debian-s3-arm64-1.1,v1.15-debian-s3-arm64-1 \
v1.15/arm64/debian-syslog:v1.15.1-debian-syslog-arm64-1.1,v1.15-debian-syslog-arm64-1 \
v1.15/arm64/debian-forward:v1.15.1-debian-forward-arm64-1.1,v1.15-debian-forward-arm64-1 \
v1.15/arm64/debian-gcs:v1.15.1-debian-gcs-arm64-1.1,v1.15-debian-gcs-arm64-1 \
v1.15/arm64/debian-graylog:v1.15.1-debian-graylog-arm64-1.1,v1.15-debian-graylog-arm64-1 \
v1.15/arm64/debian-papertrail:v1.15.1-debian-papertrail-arm64-1.1,v1.15-debian-papertrail-arm64-1 \
v1.15/arm64/debian-logzio:v1.15.1-debian-logzio-arm64-1.1,v1.15-debian-logzio-arm64-1 \
v1.15/arm64/debian-kafka:v1.15.1-debian-kafka-arm64-1.2,v1.15-debian-kafka-arm64-1 \
v1.15/arm64/debian-kafka2:v1.15.1-debian-kafka2-arm64-1.2,v1.15-debian-kafka2-arm64-1 \
v1.15/arm64/debian-kinesis:v1.15.1-debian-kinesis-arm64-1.1,v1.15-debian-kinesis-arm64-1
ALL_IMAGES := $(X86_IMAGES) $(ARM64_IMAGES)
comma := ,
empty :=
space := $(empty) $(empty)
# Default is first image from ALL_IMAGES list.
DOCKERFILE ?= $(word 1,$(subst :, ,$(word 1,$(ALL_IMAGES))))
TARGET ?= $(word 2,$(subst -, , $(DOCKERFILE)))
RUBY_VERSION = 3.1
# Gets the version value based on the directory the dockerfile is in.
FLUENTD_VERSION ?= $(word 1,$(subst /, ,$(DOCKERFILE)))
# Finds the image tags based on whatever DOCKERFILE is set to, even if the user
# has passed DOCKERFILE explicitly
#
# Gets the <version>,<tag1>,<tag2>,... from <Dockerfile>:<version>,<tag1>,<tag2>,...
TAGS ?= $(word 2,$(subst :, ,$(word 1,$(filter $(DOCKERFILE)%, $(ALL_IMAGES)))))
# Gets the <version> from <Dockerfile>:<version>,<tag1>,<tag2>,...
VERSION ?= $(word 1,$(subst $(comma), ,$(TAGS)))
no-cache ?= no
eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\
$(findstring $(2),$(1))),1)
## Docker image management
no-cache-arg = $(if $(call eq, $(no-cache), yes), --no-cache, $(empty))
# Build Docker image.
#
# Usage:
# make image [no-cache=(yes|no)] [DOCKERFILE=] [VERSION=]
image:
docker build $(no-cache-arg) -t $(IMAGE_NAME):$(VERSION) docker-image/$(DOCKERFILE)
parsed-tags = $(subst $(comma), $(space), $(TAGS))
# Tag Docker image with given tags.
#
# Usage:
# make tags [VERSION=] [TAGS=t1,t2,...]
tags:
(set -e ; $(foreach tag, $(parsed-tags), \
docker tag $(IMAGE_NAME):$(VERSION) $(IMAGE_NAME):$(tag) ; \
))
# Manually push Docker images to Docker Hub.
#
# Usage:
# make push [TAGS=t1,t2,...]
push:
(set -e ; $(foreach tag, $(parsed-tags), \
docker push $(IMAGE_NAME):$(tag) ; \
))
# Make manual release of Docker images to Docker Hub.
#
# Usage:
# make release [no-cache=(yes|no)] [DOCKERFILE=] [VERSION=] [TAGS=t1,t2,...]
release: | image tags push
# Make manual release of all supported Docker images to Docker Hub.
#
# Usage:
# make release-all [no-cache=(yes|no)]
release-all:
(set -e ; $(foreach img,$(ALL_IMAGES), \
make release no-cache=$(no-cache) \
DOCKERFILE=$(word 1,$(subst :, ,$(img))) \
VERSION=$(word 1,$(subst $(comma), ,\
$(word 2,$(subst :, ,$(img))))) \
TAGS=$(word 2,$(subst :, ,$(img))) ; \
))
## Template processing
# Generate Docker image sources.
#
# Usage:
# make src [DOCKERFILE=] [VERSION=] [TAGS=t1,t2,...]
src: dockerfile gemfile fluent.conf systemd.conf prometheus.conf kubernetes.conf plugins post-push-hook post-checkout-hook entrypoint.sh cluster-autoscaler.conf containers.conf docker.conf etcd.conf glbc.conf kube-apiserver-audit.conf kube-apiserver.conf kube-controller-manager.conf kube-proxy.conf kube-scheduler.conf kubelet.conf rescheduler.conf salt.conf startupscript.conf tail_container_parse.conf
# Generate sources for all supported Docker images.
#
# Usage:
# make src-all
src-all: README.md
(set -e ; $(foreach img,$(ALL_IMAGES), \
make src \
DOCKERFILE=$(word 1,$(subst :, ,$(img))) \
VERSION=$(word 1,$(subst $(comma), ,\
$(word 2,$(subst :, ,$(img))))) \
TAGS=$(word 2,$(subst :, ,$(img))) ; \
))
# Render the given erb template.
#
# Usage:
# make container-image-template [FILE=] [DOCKERFILE=] [VERSION=] [RUBY_VERSION=]
container-image-template:
mkdir -p docker-image/$(DOCKERFILE)/$(dir $(FILE))
docker run --rm -i -v $(PWD)/templates/$(FILE).erb:/$(basename $(FILE)).erb:ro \
ruby:alpine erb -U -T 1 \
dockerfile='$(DOCKERFILE)' \
version='$(VERSION)' \
ruby_version='$(RUBY_VERSION)' \
/$(basename $(FILE)).erb > docker-image/$(DOCKERFILE)/$(FILE)
# Execute the given TARGET for each images
#
# Usage:
# make each-image TARGET=
each-image:
(set -e ; $(foreach img,$(ALL_IMAGES), \
make $(TARGET) \
DOCKERFILE=$(word 1,$(subst :, ,$(img))) \
VERSION=$(word 1,$(subst $(comma), ,\
$(word 2,$(subst :, ,$(img))))) ; \
))
# Generate Dockerfile from template.
#
# Usage:
# make dockerfile [DOCKERFILE=] [VERSION=]
dockerfile:
make container-image-template FILE=Dockerfile
cp $(PWD)/templates/.dockerignore docker-image/$(DOCKERFILE)/.dockerignore
dockerfile-all:
make each-image TARGET=dockerfile
# Generate Gemfile and Gemfile.lock from template.
#
# Usage:
# make gemfile [DOCKERFILE=] [VERSION=]
gemfile:
make container-image-template FILE=Gemfile
docker run --rm -i -v $(PWD)/docker-image/$(DOCKERFILE)/Gemfile:/Gemfile:ro \
ruby:alpine sh -c "apk add --no-cache --quiet git && bundle lock --print --remove-platform x86_64-linux-musl --add-platform ruby" > docker-image/${DOCKERFILE}/Gemfile.lock
# Generate Gemfile and Gemfile.lock from template for all supported Docker images.
#
# Usage:
# make gemfile-all
gemfile-all:
make each-image TARGET=gemfile
# Generate entrypoint.sh from template.
#
# Usage:
# make entrypoint.sh [DOCKERFILE=] [VERSION=]
entrypoint.sh:
make container-image-template FILE=entrypoint.sh
chmod 755 docker-image/$(DOCKERFILE)/entrypoint.sh
# Generate entrypoint.sh from template for all supported Docker images.
#
# Usage:
# make entrypoint.sh-all
entrypoint.sh-all:
make each-image TARGET=entrypoint.sh
# Generate fluent.conf from template.
#
# Usage:
# make fluent.conf [DOCKERFILE=] [VERSION=]
fluent.conf:
make container-image-template FILE=conf/fluent.conf
fluent.conf-all:
make each-image TARGET=fluent.conf
# Generate kubernetes.conf from template.
#
# Usage:
# make kubernetes.conf [DOCKERFILE=] [VERSION=]
kubernetes.conf:
make container-image-template FILE=conf/kubernetes.conf
kubernetes.conf-all:
make each-image TARGET=kubernetes.conf
cluster-autoscaler.conf:
make container-image-template FILE=conf/kubernetes/cluster-autoscaler.conf
cluster-autoscaler.conf-all:
make each-image TARGET=cluster-autoscaler.conf
containers.conf:
make container-image-template FILE=conf/kubernetes/containers.conf
containers.conf-all:
make each-image TARGET=containers.conf
docker.conf:
make container-image-template FILE=conf/kubernetes/docker.conf
docker.conf-all:
make each-image TARGET=docker.conf
etcd.conf:
make container-image-template FILE=conf/kubernetes/etcd.conf
etcd.conf-all:
make each-image TARGET=etcd.conf
glbc.conf:
make container-image-template FILE=conf/kubernetes/glbc.conf
glbc.conf-all:
make each-image TARGET=glbc.conf
kube-apiserver-audit.conf:
make container-image-template FILE=conf/kubernetes/kube-apiserver-audit.conf
kube-apiserver-audit.conf-all:
make each-image TARGET=kube-apiserver-audit.conf
kube-apiserver.conf:
make container-image-template FILE=conf/kubernetes/kube-apiserver.conf
kube-apiserver.conf-all:
make each-image TARGET=kube-apiserver.conf
kube-controller-manager.conf:
make container-image-template FILE=conf/kubernetes/kube-controller-manager.conf
kube-controller-manager.conf-all:
make each-image TARGET=kube-controller-manager.conf
kubelet.conf:
make container-image-template FILE=conf/kubernetes/kubelet.conf
kubelet.conf-all:
make each-image TARGET=kubelet.conf
kube-proxy.conf:
make container-image-template FILE=conf/kubernetes/kube-proxy.conf
kube-proxy.conf-all:
make each-image TARGET=kube-proxy.conf
kube-scheduler.conf:
make container-image-template FILE=conf/kubernetes/kube-scheduler.conf
kube-scheduler.conf-all:
make each-image TARGET=kube-scheduler.conf
rescheduler.conf:
make container-image-template FILE=conf/kubernetes/rescheduler.conf
rescheduler.conf-all:
make each-image TARGET=rescheduler.conf
salt.conf:
make container-image-template FILE=conf/kubernetes/salt.conf
salt.conf-all:
make each-image TARGET=salt.conf
startupscript.conf:
make container-image-template FILE=conf/kubernetes/startupscript.conf
startupscript.conf-all:
make each-image TARGET=startupscript.conf
systemd.conf:
make container-image-template FILE=conf/systemd.conf
systemd.conf-all:
make each-image TARGET=systemd.conf
tail_container_parse.conf:
make container-image-template FILE=conf/tail_container_parse.conf
tail_container_parse.conf-all:
make each-image TARGET=tail_container_parse.conf
prometheus.conf:
make container-image-template FILE=conf/prometheus.conf
prometheus.conf-all:
make each-image TARGET=prometheus.conf
README.md: templates/README.md.erb
docker run --rm -i -v $(PWD)/templates/README.md.erb:/README.md.erb:ro \
ruby:alpine erb -U -T 1 \
all_images='$(ALL_IMAGES)' \
/README.md.erb > README.md
.github/dependabot.yml: templates/dependabot.yml.erb
erb $< > $@
# Generate plugins for version
#
# Usage:
# make plugins [DOCKERFILE=]
plugins:
mkdir -p docker-image/$(DOCKERFILE)/plugins
cp -R plugins/$(FLUENTD_VERSION)/shared/. docker-image/$(DOCKERFILE)/plugins/
cp -R plugins/$(FLUENTD_VERSION)/$(TARGET)/. docker-image/$(DOCKERFILE)/plugins/
# copy plugins required for all supported Docker images.
#
# Usage:
# make plugins-all
plugins-all:
(set -e ; $(foreach img,$(ALL_IMAGES), \
make plugins \
DOCKERFILE=$(word 1,$(subst :, ,$(img))) ; \
))
# Create `post_checkout` Docker Hub hook.
#
# When Docker Hub triggers automated build, the `post_checkout` hook is called
# after the Git repo is checked out. This can be used to set up prerequisites
# for, for example, cross-platform builds.
# See details:
# https://docs.docker.com/docker-cloud/builds/advanced/#build-hook-examples
#
# Usage:
# make post-checkout-hook [DOCKERFILE=]
post-checkout-hook:
if [ -n "$(findstring /arm64/,$(DOCKERFILE))" ]; then \
mkdir -p docker-image/$(DOCKERFILE)/hooks; \
docker run --rm -i -v $(PWD)/templates/post_checkout.erb:/post_checkout.erb:ro \
ruby:alpine erb -U \
dockerfile='$(DOCKERFILE)' \
/post_checkout.erb > docker-image/$(DOCKERFILE)/hooks/post_checkout ; \
fi
# Create `post_push` Docker Hub hook for all supported Docker images.
#
# Usage:
# make post-checkout-hook-all
post-checkout-hook-all:
make each-image TARGET=post-checkout-hook
# Create `post_push` Docker Hub hook.
#
# When Docker Hub triggers automated build all the tags defined in `post_push`
# hook will be assigned to built image. It allows to link the same image with
# different tags, and not to build identical image for each tag separately.
# See details:
# http://windsock.io/automated-docker-image-builds-with-multiple-tags
#
# Usage:
# make post-push-hook [DOCKERFILE=] [TAGS=t1,t2,...]
post-push-hook:
mkdir -p docker-image/$(DOCKERFILE)/hooks
docker run --rm -i -v $(PWD)/templates/post_push.erb:/post_push.erb:ro \
ruby:alpine erb -U \
image_tags='$(TAGS)' \
/post_push.erb > docker-image/$(DOCKERFILE)/hooks/post_push
# Create `post_push` Docker Hub hook for all supported Docker images.
#
# Usage:
# make post-push-hook-all
post-push-hook-all:
(set -e ; $(foreach img,$(ALL_IMAGES), \
make post-push-hook \
DOCKERFILE=$(word 1,$(subst :, ,$(img))) \
TAGS=$(word 2,$(subst :, ,$(img))) ; \
))
.PHONY: image tags push \
release release-all \
src src-all \
container-image-template each-image \
dockerfile dockerfile-all \
gemfile gemfile-all \
entrypoint.sh entrypoint.sh-all \
fluent.conf fluent.conf-all \
kubernetes.conf kubernetes.conf-all\
cluster-autoscaler.conf cluster-autoscaler.conf-all \
containers.conf containers.conf-all \
docker.conf docker.conf-all \
etcd.conf etcd.conf-all \
glbc.conf glbc.conf-all \
kube-apiserver-audit.conf kube-apiserver-audit.conf-all \
kube-apiserver.conf kube-apiserver.conf-all \
kube-controller-manager.conf kube-controller-manager.conf-all \
kubelet.conf kubelet.conf-all \
kube-proxy.conf kube-proxy.conf-all \
kube-scheduler.conf kube-scheduler.conf-all \
rescheduler.conf rescheduler.conf-all \
salt.conf salt.conf-all \
startupscript.conf startupscript.conf-all \
systemd.conf systemd.conf-all \
tail_container_parse.conf tail_container_parse.conf-all \
prometheus.conf prometheus.conf-all \
plugins plugins-all \
post-checkout-hook post-checkout-hook-all \
post-push-hook post-push-hook-all \
README.md