Skip to content

Commit

Permalink
Add support for cross arch for fluent-bit-plugin-loki image (grafana#…
Browse files Browse the repository at this point in the history
…10081)

Copied from grafana#9991 which has problems
running CI.

**What this PR does / why we need it**:
Currently the `fluent-bit-plugin-loki` image is only build and published
for amd64. With more use of arm-based processors, it would be good to
add support for those as well.

I've build the image using `docker buildx` on my M1 Mac and pushed it to
Dockerhub, should you wish to try it first:
https://hub.docker.com/r/ebosveld/fluent-bit-plugin-loki/

On AWS ECS Graviton based images it works well with the above mentioned
image.

I've also fixed grafana#9932 as it needed the full bullseye support.

**Which issue(s) this PR fixes**:
Fixes grafana#6738
Fixes grafana#9932

**Special notes for your reviewer**:

**Checklist**
- [x] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [ ] Documentation added
- [ ] Tests updated
- [ ] `CHANGELOG.md` updated
- [ ] If the change is worth mentioning in the release notes, add
`add-to-release-notes` label
- [ ] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/upgrading/_index.md`
- [ ] For Helm chart changes bump the Helm chart version in
`production/helm/loki/Chart.yaml` and update
`production/helm/loki/CHANGELOG.md` and
`production/helm/loki/README.md`. [Example
PR](grafana@d10549e)

---------

Signed-off-by: Michel Hollands <michel.hollands@gmail.com>
Co-authored-by: Edwin Bosveld <edwin.bosveld@persgroep.net>
Co-authored-by: Travis Patterson <travis.patterson@grafana.com>
Co-authored-by: Edwin Bosveld <ebosveld@users.noreply.github.com>
  • Loading branch information
4 people authored Jul 27, 2023
1 parent 5a7d678 commit d484d31
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 9 deletions.
15 changes: 10 additions & 5 deletions .drone/drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ local querytee() = pipeline('querytee-amd64') + arch_image('amd64', 'main') {
depends_on: ['check'],
};

local fluentbit() = pipeline('fluent-bit-amd64') + arch_image('amd64', 'main') {
local fluentbit(arch) = pipeline('fluent-bit-' + arch) + arch_image(arch) {
steps+: [
// dry run for everything that is not tag or main
clients_docker('amd64', 'fluent-bit') {
clients_docker(arch, 'fluent-bit') {
depends_on: ['image-tag'],
when: onPRs,
settings+: {
Expand All @@ -212,7 +212,7 @@ local fluentbit() = pipeline('fluent-bit-amd64') + arch_image('amd64', 'main') {
},
] + [
// publish for tag or main
clients_docker('amd64', 'fluent-bit') {
clients_docker(arch, 'fluent-bit') {
depends_on: ['image-tag'],
when: onTagOrMain,
settings+: {
Expand Down Expand Up @@ -417,6 +417,9 @@ local manifest(apps) = pipeline('manifest') {
] + [
'promtail-%s' % arch
for arch in archs
] + [
'fluent-bit-%s' % arch
for arch in archs
],
};

Expand Down Expand Up @@ -678,11 +681,13 @@ local manifest_ecr(apps, archs) = pipeline('manifest-ecr') {
lokioperator(arch)
for arch in archs
] + [
fluentbit(),
fluentbit(arch)
for arch in archs
] + [
fluentd(),
logstash(),
querytee(),
manifest(['promtail', 'loki', 'loki-canary']) {
manifest(['promtail', 'loki', 'loki-canary', 'fluent-bit']) {
trigger+: onTagOrMain,
},
manifest_operator('loki-operator') {
Expand Down
123 changes: 121 additions & 2 deletions .drone/drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,6 @@ steps:
- apk add --no-cache bash git
- git fetch origin --tags
- echo $(./tools/image-tag)-amd64 > .tags
- echo ",main" >> .tags
image: alpine
name: image-tag
- depends_on:
Expand Down Expand Up @@ -1014,6 +1013,110 @@ trigger:
depends_on:
- check
kind: pipeline
name: fluent-bit-arm64
platform:
arch: arm64
os: linux
steps:
- commands:
- apk add --no-cache bash git
- git fetch origin --tags
- echo $(./tools/image-tag)-arm64 > .tags
image: alpine
name: image-tag
- depends_on:
- image-tag
image: plugins/docker
name: build-fluent-bit-image
settings:
dockerfile: clients/cmd/fluent-bit/Dockerfile
dry_run: true
password:
from_secret: docker_password
repo: grafana/fluent-bit-plugin-loki
username:
from_secret: docker_username
when:
event:
- pull_request
- depends_on:
- image-tag
image: plugins/docker
name: publish-fluent-bit-image
settings:
dockerfile: clients/cmd/fluent-bit/Dockerfile
dry_run: false
password:
from_secret: docker_password
repo: grafana/fluent-bit-plugin-loki
username:
from_secret: docker_username
when:
event:
- push
- tag
trigger:
ref:
- refs/heads/main
- refs/heads/k???
- refs/tags/v*
- refs/pull/*/head
---
depends_on:
- check
kind: pipeline
name: fluent-bit-arm
platform:
arch: arm
os: linux
steps:
- commands:
- apk add --no-cache bash git
- git fetch origin --tags
- echo $(./tools/image-tag)-arm > .tags
image: alpine
name: image-tag
- depends_on:
- image-tag
image: plugins/docker:linux-arm
name: build-fluent-bit-image
settings:
dockerfile: clients/cmd/fluent-bit/Dockerfile
dry_run: true
password:
from_secret: docker_password
repo: grafana/fluent-bit-plugin-loki
username:
from_secret: docker_username
when:
event:
- pull_request
- depends_on:
- image-tag
image: plugins/docker:linux-arm
name: publish-fluent-bit-image
settings:
dockerfile: clients/cmd/fluent-bit/Dockerfile
dry_run: false
password:
from_secret: docker_password
repo: grafana/fluent-bit-plugin-loki
username:
from_secret: docker_username
when:
event:
- push
- tag
trigger:
ref:
- refs/heads/main
- refs/heads/k???
- refs/tags/v*
- refs/pull/*/head
---
depends_on:
- check
kind: pipeline
name: fluentd-amd64
platform:
arch: amd64
Expand Down Expand Up @@ -1177,6 +1280,9 @@ depends_on:
- promtail-amd64
- promtail-arm64
- promtail-arm
- fluent-bit-amd64
- fluent-bit-arm64
- fluent-bit-arm
kind: pipeline
name: manifest
steps:
Expand Down Expand Up @@ -1218,6 +1324,19 @@ steps:
target: loki-canary
username:
from_secret: docker_username
- depends_on:
- clone
- manifest-loki-canary
image: plugins/manifest:1.4.0
name: manifest-fluent-bit
settings:
ignore_missing: false
password:
from_secret: docker_password
spec: .drone/docker-manifest.tmpl
target: fluent-bit
username:
from_secret: docker_username
trigger:
event:
- push
Expand Down Expand Up @@ -1794,6 +1913,6 @@ kind: secret
name: gpg_private_key
---
kind: signature
hmac: 06e7ff691dfc5cb9a9fec614d23c781f698f8871d406b2d25e06e7761fb345d8
hmac: a1839eb5d43146ccc7793a2bb103396a4ca370582fed4736c24c4c9b7c4d55e3

...
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,10 @@ fluent-bit-plugin: ## build the fluent-bit plugin

fluent-bit-image: ## build the fluent-bit plugin docker image
$(SUDO) docker build -t $(IMAGE_PREFIX)/fluent-bit-plugin-loki:$(IMAGE_TAG) --build-arg LDFLAGS="-s -w $(GO_LDFLAGS)" -f clients/cmd/fluent-bit/Dockerfile .
fluent-bit-image-cross:
$(SUDO) $(BUILD_OCI) -t $(IMAGE_PREFIX)/fluent-bit-plugin-loki:$(IMAGE_TAG) --build-arg LDFLAGS="-s -w $(GO_LDFLAGS)" -f clients/cmd/fluent-bit/Dockerfile .

fluent-bit-push: ## push the fluent-bit plugin docker image
fluent-bit-push: fluent-bit-image-cross ## push the fluent-bit plugin docker image
$(SUDO) $(PUSH_OCI) $(IMAGE_PREFIX)/fluent-bit-plugin-loki:$(IMAGE_TAG)

fluent-bit-test: LOKI_URL ?= http://localhost:3100/loki/api/
Expand Down
2 changes: 1 addition & 1 deletion clients/cmd/fluent-bit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20.6@sha256:832f2f74baa3e2b00ace688cb2fa934dffeade39f5b4c0cc8b1cff8d3fb084a0 AS builder
FROM golang:1.20.6-bullseye AS builder

COPY . /src

Expand Down

0 comments on commit d484d31

Please sign in to comment.