-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
47 lines (35 loc) · 1.59 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
IMAGE_REGISTRY ?= ghcr.io
IMAGE_NAMESPACE ?= srodi
# add arch to the tag
ARCH=$(shell uname -m)
IMAGE_TAG ?= $(shell git describe --tags --always)-$(ARCH)
IMAGE := $(IMAGE_REGISTRY)/$(IMAGE_NAMESPACE)/ebpf-prometheus-metrics/latency:$(IMAGE_TAG)
export IMAGE
PLATFORM ?= $(if $(filter x86_64,$(ARCH)),linux/amd64,$(if $(filter arm64,$(ARCH)),linux/arm64,unsupported))
TARGETARCH ?= $(if $(filter x86_64,$(ARCH)),x86,$(if $(filter arm64,$(ARCH)),arm64,unsupported))
# Force make to always run these targets
.PHONY: all build load dump clean docker docker-run deploy delete prometheus
all: build
build: clean
docker buildx build --platform $(PLATFORM) --build-arg TARGETARCH=$(TARGETARCH) -t bpf-compile:$(TARGETARCH) -f docker/Dockerfile.builder . --output=type=local,dest=./
go build -o main main.go
load:
sudo bpftool prog load bpf/latency.o /sys/fs/bpf/latency autoattach
dump:
sudo bpftool map dump name latency_map
run: clean build
sudo ./main
clean:
sudo rm -f /sys/fs/bpf/latency
rm -f main bpf/latency.o
docker:
docker buildx build --platform $(PLATFORM) --build-arg TARGETARCH=$(TARGETARCH) -t $(IMAGE) -f docker/Dockerfile --push .
docker-run:
docker run --cap-add=SYS_ADMIN --cap-add=NET_ADMIN --cap-add=BPF --ulimit memlock=1073741824:1073741824 -p 2112:2112 $(IMAGE)
deploy:
envsubst < deploy/deploy.yaml | kubectl apply -f -
delete:
envsubst < deploy/deploy.yaml | kubectl delete -f -
prometheus:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm upgrade kube-prometheus-stack prometheus-community/kube-prometheus-stack --values deploy/prom-values.yaml