Merge pull request 'build: use image instead of local compile' (#4) from fanzu8/huatuo:master into master
This commit is contained in:
commit
808cbe922f
|
@ -0,0 +1,34 @@
|
||||||
|
FROM golang:1.22.4-alpine AS base
|
||||||
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
make \
|
||||||
|
clang15 \
|
||||||
|
libbpf-dev \
|
||||||
|
bpftool \
|
||||||
|
curl \
|
||||||
|
git
|
||||||
|
ENV PATH=$PATH:/usr/lib/llvm15/bin
|
||||||
|
|
||||||
|
|
||||||
|
FROM base AS build
|
||||||
|
ARG BUILD_PATH=${BUILD_PATH:-/go/huatuo-bamai}
|
||||||
|
ARG RUN_PATH=${RUN_PATH:-/home/huatuo-bamai}
|
||||||
|
WORKDIR ${BUILD_PATH}
|
||||||
|
COPY . .
|
||||||
|
RUN make && \
|
||||||
|
mkdir -p ${RUN_PATH}/bpf && \
|
||||||
|
mkdir -p ${RUN_PATH}/tracer && \
|
||||||
|
cp ${BUILD_PATH}/_output/bin/huatuo-bamai ${RUN_PATH}/huatuo-bamai && \
|
||||||
|
cp ${BUILD_PATH}/huatuo-bamai.conf ${RUN_PATH}/huatuo-bamai.conf && \
|
||||||
|
cp ${BUILD_PATH}/bpf/*.o ${RUN_PATH}/bpf/ && \
|
||||||
|
find ${BUILD_PATH}/cmd -type f -name "*.bin" -exec cp {} ${RUN_PATH}/tracer/ \;
|
||||||
|
# Comment following line if elasticsearch is needed and repalce the ES configs in huatuo-bamai.conf
|
||||||
|
RUN sed -i 's/"http:\/\/127.0.0.1:9200"/""/' ${RUN_PATH}/huatuo-bamai.conf
|
||||||
|
|
||||||
|
|
||||||
|
FROM alpine:3.22.0 AS run
|
||||||
|
ARG RUN_PATH=${RUN_PATH:-/home/huatuo-bamai}
|
||||||
|
RUN apk add --no-cache curl
|
||||||
|
COPY --from=build ${RUN_PATH} ${RUN_PATH}
|
||||||
|
WORKDIR ${RUN_PATH}
|
||||||
|
CMD ["./huatuo-bamai", "--region", "example", "--config", "huatuo-bamai.conf"]
|
24
README.md
24
README.md
|
@ -17,11 +17,27 @@
|
||||||
|
|
||||||
|
|
||||||
# 快速上手
|
# 快速上手
|
||||||
为用户开发者快速体验 HUATUO, 我们提供容器编译镜像的便捷方式,一键运行 docker compose 即可启动。该命令会启动 elasticsearch, prometheus, grafana 以及编译的 huatuo-bamai 组件。上述命令执行成功后,打开浏览器访问 http://localhost:3000 即可浏览监控大盘。
|
|
||||||
|
|
||||||
```bash
|
- **极速体验**
|
||||||
$ docker compose --project-directory ./build/docker up
|
如果你只关心底层原理,不关心存储、前端展示等,我们提供了编译好的镜像,已包含 HUATUO 底层运行的必要组件,直接运行即可:
|
||||||
```
|
```bash
|
||||||
|
$ docker run --privileged --network=host -v /sys:/sys -v /run:/run huatuo/huatuo-bamai:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
- **快速搭建**
|
||||||
|
如果你想更进一步了解 HUATUO 运行机制,架构设计等,可在本地很方便地搭建 HUATUO 完整运行的所有组件,我们提供容器镜像以及简单配置,方便用户开发者快速了解 HUATUO。
|
||||||
|

|
||||||
|
<div style="text-align: center; margin: 8px 0 20px 0; color: #777;">
|
||||||
|
<small>
|
||||||
|
HUATUO 组件运行示意图<br>
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
为快速搭建运行环境,我们提供一键运行的方式,该命令会启动 [elasticsearch](https://www.elastic.co), [prometheus](https://prometheus.io), [grafana](https://grafana.com) 以及 huatuo-bamai 组件。命令执行成功后,打开浏览器访问 [http://localhost:3000](http://localhost:3000) 即可浏览监控大盘。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ docker compose --project-directory ./build/docker up
|
||||||
|
```
|
||||||
|
|
||||||
# 软件架构
|
# 软件架构
|
||||||

|

|
||||||
|
|
26
README_EN.md
26
README_EN.md
|
@ -12,15 +12,25 @@ HuaTuo also integrates core technologies such as automated tracing, profiling, a
|
||||||
- **Smooth Transition** to Popular Observability Stacks: Provides standard data sources for Prometheus and Pyroscope, integrates with Kubernetes container resources, and automatically correlates Kubernetes labels/annotations with kernel event metrics, eliminating data silos, ensuring seamless integration and analysis across various data sources for comprehensive system monitoring.
|
- **Smooth Transition** to Popular Observability Stacks: Provides standard data sources for Prometheus and Pyroscope, integrates with Kubernetes container resources, and automatically correlates Kubernetes labels/annotations with kernel event metrics, eliminating data silos, ensuring seamless integration and analysis across various data sources for comprehensive system monitoring.
|
||||||
|
|
||||||
# Getting Started
|
# Getting Started
|
||||||
## run
|
- **Instant Experience**
|
||||||
HuaTuo provides a convenient way for quick getting started, all in one command as below:
|
If you only care about the underlying principles and not about storage backends or frontend display, we provide a pre-built image containing all necessary components for HUATO's core operation. Just run:
|
||||||
```bash
|
|
||||||
$ docker compose --project-directory ./build/docker up
|
|
||||||
```
|
|
||||||
Run it in the project root directory, then open [http://localhost:3000](http://localhost:3000) to view the panels on your browser.
|
|
||||||
|
|
||||||
The upper command starts three dependencies containers: [elasticsearch](https://www.elastic.co), [prometheus](https://prometheus.io), [grafana](https://grafana.com), then compiles and starts huatuo-bamai.
|
```bash
|
||||||
- Data related to event-driven operations, such as Autotracing and Events, are stored in elasticsearch
|
$ docker run --privileged --network=host -v /sys:/sys -v /run:/run huatuo/huatuo-bamai:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Quick Setup**
|
||||||
|
If you want to dive deeper into HUATO's operation mechanisms and architecture, you can easily set up all components locally. We provide container images and simple configurations for developers to quickly understand HUATO.
|
||||||
|

|
||||||
|
<div style="text-align: center; margin: 8px 0 20px 0; color: #777;">
|
||||||
|
<small>
|
||||||
|
HUATUO Component Workflow<br>
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
For a quick setup, we provide a one-command solution to launch [elasticsearch](https://www.elastic.co), [prometheus](https://prometheus.io), [grafana](https://grafana.com) and huatuo-bamai. Once executed, click [http://localhost:3000](http://localhost:3000) to view the monitoring dashboards on your browser.
|
||||||
|
|
||||||
|
- Data related to event-driven operations Autotracing and Events, are stored in elasticsearch
|
||||||
- Metrics-related data is actively collected and stored by prometheus
|
- Metrics-related data is actively collected and stored by prometheus
|
||||||
- elasticsearch data reporting port: 9200
|
- elasticsearch data reporting port: 9200
|
||||||
- prometheus data source port: 9090
|
- prometheus data source port: 9090
|
||||||
|
|
|
@ -14,6 +14,5 @@ PROMETHEUS_VERSION=v2.53.3 # LTS v2.53
|
||||||
# Grafana
|
# Grafana
|
||||||
GRAFANA_VERSION=11.0.0
|
GRAFANA_VERSION=11.0.0
|
||||||
|
|
||||||
# Compile and Run huatuo-bamai
|
# Run huatuo-bamai
|
||||||
BUILD_PATH=/go/huatuo-bamai
|
|
||||||
RUN_PATH=/home/huatuo-bamai
|
RUN_PATH=/home/huatuo-bamai
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
# https://hub.docker.com/_/golang/tags?name=1.22.4
|
|
||||||
FROM golang:1.22.4-alpine AS base
|
|
||||||
ARG RUN_PATH=${RUN_PATH:-/home/huatuo-bamai}
|
|
||||||
|
|
||||||
# Install dependencies for build
|
|
||||||
RUN apk add --no-cache \
|
|
||||||
make \
|
|
||||||
clang15 \
|
|
||||||
libbpf-dev \
|
|
||||||
bpftool \
|
|
||||||
curl
|
|
||||||
ENV PATH=$PATH:/usr/lib/llvm15/bin
|
|
||||||
WORKDIR ${RUN_PATH}
|
|
||||||
CMD ["./run.sh"]
|
|
|
@ -30,21 +30,20 @@ services:
|
||||||
- elasticsearch
|
- elasticsearch
|
||||||
|
|
||||||
huatuo-bamai:
|
huatuo-bamai:
|
||||||
build:
|
image: huatuo/huatuo-bamai:latest
|
||||||
context: ./../../ # compile required in Dockerfile
|
|
||||||
dockerfile: ./build/docker/Dockerfile
|
|
||||||
container_name: huatuo-bamai
|
container_name: huatuo-bamai
|
||||||
network_mode: host
|
network_mode: host
|
||||||
privileged: true
|
privileged: true
|
||||||
environment:
|
environment:
|
||||||
ELASTICSEARCH_HOST: ${ELASTICSEARCH_HOST:-}
|
ELASTICSEARCH_HOST: ${ELASTICSEARCH_HOST:-}
|
||||||
ELASTIC_PASSWORD: ${ELASTIC_PASSWORD:-}
|
ELASTIC_PASSWORD: ${ELASTIC_PASSWORD:-}
|
||||||
BUILD_PATH: ${BUILD_PATH:-}
|
|
||||||
RUN_PATH: ${RUN_PATH:-}
|
RUN_PATH: ${RUN_PATH:-}
|
||||||
volumes:
|
volumes:
|
||||||
- ../../:${BUILD_PATH}:rw # src
|
- /sys:/sys
|
||||||
- ./run.sh:${RUN_PATH}/run.sh:ro # run
|
- /run:/run
|
||||||
- /sys/kernel:/sys/kernel
|
- ../../huatuo-bamai.conf:${RUN_PATH}/huatuo-bamai.conf:rw
|
||||||
|
- ./run.sh:${RUN_PATH}/run.sh:ro
|
||||||
|
command: ["./run.sh"]
|
||||||
depends_on:
|
depends_on:
|
||||||
- elasticsearch
|
- elasticsearch
|
||||||
- prometheus
|
- prometheus
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
ELASTICSEARCH_HOST=${ELASTICSEARCH_HOST:-localhost}
|
ELASTICSEARCH_HOST=${ELASTICSEARCH_HOST:-localhost}
|
||||||
ELASTIC_PASSWORD=${ELASTIC_PASSWORD:-huatuo-bamai}
|
ELASTIC_PASSWORD=${ELASTIC_PASSWORD:-huatuo-bamai}
|
||||||
|
|
||||||
BUILD_PATH=${BUILD_PATH:-/go/huatuo-bamai}
|
|
||||||
RUN_PATH=${RUN_PATH:-/home/huatuo-bamai}
|
RUN_PATH=${RUN_PATH:-/home/huatuo-bamai}
|
||||||
|
|
||||||
# Wait for Elasticsearch to be ready
|
# Wait for Elasticsearch to be ready
|
||||||
|
@ -60,42 +59,6 @@ wait_for_elasticsearch() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Compile and copy huatuo-bamai, .conf, bpf.o, cmd-tools to run path
|
|
||||||
prepare_run_env() {
|
|
||||||
# compile huatuo-bamai
|
|
||||||
if [ ! -x "$BUILD_PATH/_output/bin/huatuo-bamai" ]; then
|
|
||||||
cd $BUILD_PATH && make clean
|
|
||||||
bpftool btf dump file /sys/kernel/btf/vmlinux format c > bpf/include/vmlinux.h || {
|
|
||||||
echo "Failed to dump vmlinux.h"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
make || {
|
|
||||||
echo "Failed to compile huatuo-bamai"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
# copy huatuo-bamai, .conf, bpf.o, cmd-tools to run path
|
|
||||||
cp $BUILD_PATH/_output/bin/huatuo-bamai $RUN_PATH/huatuo-bamai || {
|
|
||||||
echo "Failed to copy huatuo-bamai"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
cp $BUILD_PATH/huatuo-bamai.conf $RUN_PATH/huatuo-bamai.conf || {
|
|
||||||
echo "Failed to copy huatuo-bamai.conf"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
mkdir -p $RUN_PATH/bpf && cp $BUILD_PATH/bpf/*.o $RUN_PATH/bpf/ || {
|
|
||||||
echo "Failed to copy bpf files"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
mkdir -p $RUN_PATH/tracer && find $BUILD_PATH/cmd/ -type f -name "*.bin" -exec cp {} $RUN_PATH/tracer/ \; || {
|
|
||||||
echo "Failed to copy cmd-tools files"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Prepare run env for huatuo-bamai
|
|
||||||
prepare_run_env
|
|
||||||
echo "huatuo-bamai run env is ready."
|
|
||||||
|
|
||||||
wait_for_elasticsearch
|
wait_for_elasticsearch
|
||||||
sleep 5 # Waiting for initialization of Elasticsearch built-in users
|
sleep 5 # Waiting for initialization of Elasticsearch built-in users
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 111 KiB |
Binary file not shown.
After Width: | Height: | Size: 111 KiB |
Loading…
Reference in New Issue