Skip to content

Commit

Permalink
chore(ci): build bpf in ci
Browse files Browse the repository at this point in the history
Signed-off-by: xiayu.lyt <xiayu.lyt@alibaba-inc.com>
  • Loading branch information
Lyt99 committed May 21, 2024
1 parent 66a4342 commit ba56fb4
Show file tree
Hide file tree
Showing 40 changed files with 26 additions and 1,569 deletions.
10 changes: 2 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
FROM docker.io/library/golang:1.22.1-alpine AS build

ARG ALPINE_MIRROR
ENV ALPINE_MIRROR=$ALPINE_MIRROR

RUN if [ ! -z "$ALPINE_MIRROR" ]; then sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories; fi && \
apk add gcc g++ linux-headers git make bash
FROM kubeskoop/ci-builder:latest AS build

WORKDIR /go/src/github.com/alibaba/kubeskoop/
RUN go env -w GOMODCACHE=/root/.cache/go-build
COPY go.mod go.sum /go/src/github.com/alibaba/kubeskoop/
RUN --mount=type=cache,target=/root/.cache/go-build go mod download

ADD . /go/src/github.com/alibaba/kubeskoop/
RUN --mount=type=cache,target=/root/.cache/go-build mkdir -p bin && make all
RUN --mount=type=cache,target=/root/.cache/go-build mkdir -p bin && make generate-bpf && make all

FROM --platform=linux/amd64 docker.io/library/node:20.9.0-alpine as build-ui
WORKDIR /webconsole
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ build-webconsole:

.PHONY: generate-bpf
generate-bpf:
TARGET=amd64 go generate ./pkg/exporter/probe/...
TARGET=arm64 go generate ./pkg/exporter/probe/...
go generate ./pkg/exporter/probe/...

.PHONY: generate-bpf-in-container
generate-bpf-in-container:
docker run -v $(PWD):/go/src/github.com/alibaba/kubeskoop --workdir /go/src/github.com/alibaba/kubeskoop kubeskoop/bpf-build:go121-clang17 make generate-bpf
docker run --rm -v $(PWD):/go/src/github.com/alibaba/kubeskoop --workdir /go/src/github.com/alibaba/kubeskoop kubeskoop/bpf-build:go121-clang17 make generate-bpf
9 changes: 9 additions & 0 deletions bpf/headers/vmlinux.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#if defined(__TARGET_ARCH_arm64)
#include "arm64/vmlinux.h"
#elif defined(__TARGET_ARCH_amd64)
#include "amd64/vmlinux.h"
#elif defined(__TARGET_ARCH_x86)
#include "amd64/vmlinux.h"
#else
#error "Unsupported architecture"
#endif
Binary file removed pkg/exporter/probe/flow/bpf_bpfeb.o
Binary file not shown.
141 changes: 0 additions & 141 deletions pkg/exporter/probe/flow/bpf_bpfel_arm64.go

This file was deleted.

Binary file removed pkg/exporter/probe/flow/bpf_bpfel_arm64.o
Binary file not shown.
2 changes: 1 addition & 1 deletion pkg/exporter/probe/flow/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"golang.org/x/sys/unix"
)

//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -target=${TARGET} -cc clang -cflags $BPF_CFLAGS bpf ../../../../bpf/flow.c -- -I../../../../bpf/headers -I../../../../bpf/headers/${TARGET} -D__TARGET_ARCH_${TARGET}
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -target=${GOARCH} -cc clang -cflags $BPF_CFLAGS bpf ../../../../bpf/flow.c -- -I../../../../bpf/headers -D__TARGET_ARCH_${GOARCH}

type direction int

Expand Down
144 changes: 0 additions & 144 deletions pkg/exporter/probe/tracebiolatency/bpf_bpfel_arm64.go

This file was deleted.

Binary file not shown.
2 changes: 1 addition & 1 deletion pkg/exporter/probe/tracebiolatency/tracebiolatency.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
log "github.com/sirupsen/logrus"
)

//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -target=${TARGET} -cc clang -cflags $BPF_CFLAGS -type insp_biolat_event_t bpf ../../../../bpf/tracebiolatency.c -- -I../../../../bpf/headers -I../../../../bpf/headers/${TARGET} -D__TARGET_ARCH_${TARGET}
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -target=${GOARCH} -cc clang -cflags $BPF_CFLAGS -type insp_biolat_event_t bpf ../../../../bpf/tracebiolatency.c -- -I../../../../bpf/headers -D__TARGET_ARCH_${GOARCH}
var (
probeName = "biolatency"
)
Expand Down
Binary file removed pkg/exporter/probe/tracekernel/bpf_bpfeb.o
Binary file not shown.
Loading

0 comments on commit ba56fb4

Please sign in to comment.