/
rustwizard
/
pgtrace
Обзор
Документация
Войти
/
rustwizard
/
pgtrace
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
deploy/ebpf-dev.yaml
171 строка
6 KB
Rust Wizard
feat: Grafana dashboard, Prometheus demo stack, and reusable Lima dev VM config
07 авг 2026, 13:14
Верифицирован
07 авг 2026, 13:14
998804c
Код
Авторство
О чём код?
# ebpf-dev.yaml — Lima VM for eBPF development on macOS (Go + Rust). # For Apple Silicon (M1/M2/M3/M4). Start: # limactl start --name=ebpf-dev deploy/ebpf-dev.yaml # limactl shell ebpf-dev # # Based on the working ~/work/ebpf/ebpf-dev.yaml, extended for pgtrace: # - portForwards: agent metrics (9092) and Postgres (5432) on host localhost # - golangci-lint (used by make lint) # - PostgreSQL + pgbench + pg_stat_statements with a role named after the # OS user ($USER) so the DSN postgres://$USER:$USER@localhost/pgbench works # on any machine cpus: 4 memory: "10GiB" disk: "30GiB" # Use native VZ instead of QEMU on Apple Silicon vmType: "vz" # If Rosetta is needed for x86 binaries inside the VM: # rosetta: # enabled: true # binfmt: true images: - location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img" arch: "aarch64" mounts: - location: "~" writable: true - location: "/tmp/lima" writable: true # Forward guest ports to host localhost so the Grafana/Prometheus demo on the # host can reach the agent (9092) and Postgres (5432) running in the VM. portForwards: - guestPort: 9092 hostPort: 9092 - guestPort: 5432 hostPort: 5432 provision: # 1. Base eBPF dependencies - mode: system script: | #!/bin/bash set -eux -o pipefail apt-get update -y apt-get install -y \ apt-transport-https ca-certificates curl git \ clang llvm jq \ linux-tools-common \ libelf-dev libcap-dev libpcap-dev libbfd-dev binutils-dev \ build-essential make cmake pkg-config \ bpfcc-tools python3-pip \ bpftrace KERNEL=$(uname -r) apt-get install -y "linux-tools-${KERNEL}" || \ apt-get install -y linux-tools-generic || \ echo "WARNING: linux-tools not found for ${KERNEL}" # 2. Debug symbols - mode: system script: | #!/bin/bash set -eux apt-get install -y ubuntu-dbgsym-keyring || true echo "deb http://ddebs.ubuntu.com $(lsb_release -cs) main restricted universe multiverse deb http://ddebs.ubuntu.com $(lsb_release -cs)-updates main restricted universe multiverse deb http://ddebs.ubuntu.com $(lsb_release -cs)-proposed main restricted universe multiverse" | \ tee -a /etc/apt/sources.list.d/ddebs.list apt-get update -y apt-get install -y bpftrace-dbgsym || true # 3. libbpf + headers - mode: system script: | #!/bin/bash set -eux -o pipefail apt-get install -y libbpf-dev ln -sf /usr/include/$(uname -m)-linux-gnu/asm /usr/include/asm || true # 4. bpftool built from source - mode: system script: | #!/bin/bash set -eux -o pipefail ln -sf /usr/lib/$(uname -m)-linux-gnu/libbfd.so /usr/lib/libbfd.so || true if ! command -v bpftool &> /dev/null; then git clone --recurse-submodules https://github.com/libbpf/bpftool.git /tmp/bpftool cd /tmp/bpftool git submodule update --init cd src make install rm -rf /tmp/bpftool fi # 5. Go - mode: system script: | #!/bin/bash set -eux -o pipefail add-apt-repository -y ppa:longsleep/golang-backports apt-get update -y apt-get install -y golang-go cat > /etc/profile.d/go.sh << 'EOF' export GOPATH=$HOME/go export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin EOF chmod 644 /etc/profile.d/go.sh # 6. Rust - mode: user script: | #!/bin/bash set -eux if ! command -v cargo &> /dev/null; then curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y fi . "$HOME/.cargo/env" rustup default stable rustup component add rust-src rustup target add aarch64-unknown-linux-musl cargo install cargo-generate 2>/dev/null || true # 7. kubectl - mode: system script: | #!/bin/bash set -eux -o pipefail if ! command -v kubectl &> /dev/null; then KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt) curl -LO "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/arm64/kubectl" install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl rm -f kubectl fi # 8. golangci-lint (used by make lint) - mode: user script: | #!/bin/bash set -eux export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest # 9. PostgreSQL + pg_stat_statements (shared_preload_libraries) - mode: system script: | #!/bin/bash set -eux -o pipefail apt-get install -y postgresql postgresql-contrib # pg_stat_statements must be loaded via shared_preload_libraries. # Apply it during provisioning and restart the cluster. sudo -u postgres psql -c "ALTER SYSTEM SET shared_preload_libraries = 'pg_stat_statements'" pg_ctlcluster $(ls /etc/postgresql | head -1) main restart # 10. Test role and database, named after the OS user ($USER in mode: user is # the Lima instance user, which matches the host user). The pgtrace agent # connects as postgres://$USER:$USER@localhost/pgbench. - mode: user script: | #!/bin/bash set -eux -o pipefail sudo -u postgres psql -tc "SELECT 1 FROM pg_roles WHERE rolname = '$USER'" | grep -q 1 || \ sudo -u postgres psql -c "CREATE ROLE \"$USER\" LOGIN SUPERUSER PASSWORD '$USER'" sudo -u postgres createdb -O "$USER" pgbench 2>/dev/null || true sudo -u postgres psql -d pgbench -c "CREATE EXTENSION IF NOT EXISTS pg_stat_statements" sudo -u postgres psql -d pgbench -c "GRANT ALL ON SCHEMA public TO \"$USER\""