This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Deployment

Choose a deployment method for your environment. Settings are described in Node Configuration and API Server Configuration.

Environment Deployment Method
Local evaluation or container runtime Docker and Compose
Kubernetes cluster DaemonSet and Helm
Linux host managed by systemd Binaries and RPM

1 - Container Deployment

Use Docker to run the collector or Compose to start the complete environment. Available image versions are listed in the image registry.

Docker

docker run --detach \
  --name huatuo-bamai \
  --restart unless-stopped \
  --privileged \
  --pid=host \
  --cgroupns=host \
  --network=host \
  --cpus=2 \
  --memory=2g \
  --volume /sys:/sys \
  --volume /proc:/proc \
  --volume /run:/run \
  huatuo/huatuo-bamai:latest

Note: The image’s default configuration does not connect to kubelet or Elasticsearch.

Set CPU and memory limits in production to prevent abnormal collection tasks from affecting host workloads. Docker enforces these limits through the container cgroup. Huatuo does not create its own cgroup by default; do not pass --enable-cgroup in Docker deployments.

Use the following commands to verify the limits and inspect actual usage:

docker inspect huatuo-bamai \
  --format 'NanoCPUs={{.HostConfig.NanoCpus}} Memory={{.HostConfig.Memory}}'
docker stats huatuo-bamai

These example values are a starting point. Adjust them for node capacity, collection tasks, and peak resource usage.

Docker Compose

Docker Compose provides a complete local environment in which you manage the collector, Elasticsearch, Prometheus, Grafana, and other components.

$ docker compose --project-directory ./build/docker up

See the installation guide to install Docker Compose.

Compose installs Business Charts (volkovlabs-echarts-panel) for the IO interval overview and profiling label filters. Install this plugin when using an existing Grafana instance.

Continuous profiling in the development stack

From the repository root, start the development stack with ES storage, API authentication, and Grafana data sources configured:

make compose-dev-up

Fixed credentials are for development only. When changing the ES password in build/docker/.env, update both service configurations under build/docker/devconf/ and the Grafana ES data source.

The collection script requires Bash, curl, and jq. Container modes also require kubectl, ip, crictl, an available Kubernetes node on the local host, and access to the gcc:14 image. IRQ requires python3, taskset, and timeout, without Kubernetes. After startup, select modes from another terminal at the repository root. Each task runs for 20 seconds:

# Default: profile on-CPU execution in a temporary container
./build/docker/run_test_cpu_profiling.sh
# Profile off-CPU waiting time in a container
./build/docker/run_test_cpu_profiling.sh --offcpu
# Profile host softirq counts
./build/docker/run_test_cpu_profiling.sh --irq
# Run all six modes sequentially
./build/docker/run_test_cpu_profiling.sh --oncpu --offcpu \
  --virtual-alloc --physical-alloc --physical-usage --irq

IRQ profiles the host; the other five modes profile containers. The script does not accept --with-host or --with-container. Mode flags can be combined in any order; repeated flags have no additional effect. The default is on-CPU. --virtual-alloc and --physical-alloc observe virtual address space and physical page allocation, respectively. --physical-usage observes live physical pages tracked during capture, not total process RSS. Container modes use separate workload Pods. IRQ generates loopback UDP traffic on one allowed CPU and profiles that CPU, producing one count window with irq_context, irq_type, irq_vector, and other labels. Node-side sampling limits apply: dropped_samples in raw.json records discarded samples, so flame graph counts do not represent the total number of interrupts. Both paths validate raw results and the Grafana flame graph.

Grafana lists the two allocation modes separately under Profile type as memory:virtual_alloc:bytes:space:bytes and memory:physical_alloc:bytes:space:bytes.

After completion, open the Grafana URL in the output to view the flame graph. The initial login is admin / admin. Results and diagnostics are saved to the reported output_dir under _output/profiling/run.XXXXXX/. The temporary container workload is removed on exit; collected results remain queryable. For label filtering, see View the Flame Graph.

The script targets the default development stack. For custom collection requests, see Profiling API.

To deploy and benchmark Redis or PostgreSQL and profile the service container:

./build/docker/run_test_redis_profiling.sh
./build/docker/run_test_postgres_profiling.sh
./build/docker/run_test_postgres_profiling.sh --offcpu
./build/docker/run_test_postgres_profiling.sh --oncpu --offcpu
./build/docker/run_test_postgres_profiling.sh --virtual-alloc --physical-alloc --physical-usage
./build/docker/run_test_postgres_profiling.sh --irq

Run make compose-dev-up before these scripts. They require curl, jq, kubectl, ip, crictl, a Kubernetes node on the local host, and access to its containerd runtime. They preload missing workload images with crictl. The runtime endpoint defaults to unix:///run/containerd/containerd.sock; override it with CONTAINER_RUNTIME_ENDPOINT. They use redis with redislabs/memtier_benchmark, or ubuntu/postgres:18-26.04_edge with pgbench from postgres:18.7-bookworm. The host needs no benchmark tools. Redis runs mixed reads and writes with a 30-second profile. Each PostgreSQL mode profiles for 60 seconds. CPU modes initialize temporary data and run read-only queries; memory modes reconnect and materialize queries to allocate, touch, and briefly retain memory. Tasks are created through the apiserver; the scripts stop the benchmark after task completion, then generate the flame graph link. Success exits with code 0; the JSON output contains the flame graph link in grafana_url and the results and benchmark log directory in output_dir. Failure exits with a nonzero code and grafana_url: null. Temporary services, data, and benchmark containers are removed on exit; the development stack and collected results remain available. Selecting multiple PostgreSQL modes returns a results array with a separate output_dir and grafana_url for each trial; any mode failing produces a nonzero exit code. PostgreSQL --irq keeps pgbench running and generates loopback UDP traffic while profiling host softirq activity. It requires python3, taskset, and timeout; results include host activity beyond PostgreSQL on the selected CPU. Off-CPU uses the same read-only pgbench workload and does not guarantee a particular wait reason.

After the trial, run make compose-dev-down to stop and remove the development stack.

2 - Cluster Deployment

Deploy the collector on Kubernetes nodes as a DaemonSet, using either manifests or Helm. The administration machine needs kubectl and access to the target cluster.

1. Deploy with Manifests

1.1 Download the Configuration

curl -L -o huatuo-bamai.conf https://github.com/ccfos/huatuo/raw/main/huatuo-bamai.conf

1.2 Edit the Configuration

Adjust the configuration for your environment, including the storage backend and Pod information source. See the configuration guide.

1.3 Create a ConfigMap

kubectl create configmap huatuo-bamai-config \
  --namespace default \
  --from-file=./huatuo-bamai.conf \
  --dry-run=client -o yaml |
kubectl apply -f -

1.4 Deploy the Collector

Download the DaemonSet manifest:

curl -L -o huatuo-daemonset.yaml \
  https://raw.githubusercontent.com/ccfos/huatuo/main/build/huatuo-daemonset.minimal.yaml

Before deploying to production, set resources for the huatuo container to the following baseline:

resources:
  limits:
    cpu: "2"
    memory: 2Gi
  requests:
    cpu: "2"
    memory: 2Gi

Apply the updated manifest:

kubectl apply -f ./huatuo-daemonset.yaml

requests reserve resources for scheduling. The kubelet writes limits to the Pod cgroup to enforce Huatuo’s CPU and memory limits. Huatuo does not create its own cgroup by default, so its processes remain in the kubepods hierarchy and can be reclaimed when containerd restarts or the Pod is deleted.

These values are a starting point. Equal requests and limits give the Pod Guaranteed QoS. [Runtime] takes effect only when --enable-cgroup is explicitly passed; do not pass this flag in Kubernetes deployments.

1.5 Verify the Deployment

kubectl rollout status daemonset/huatuo \
  --namespace default \
  --timeout=10m

kubectl get pods \
  --namespace default \
  --selector app=huatuo \
  --output wide

kubectl get daemonset huatuo \
  --namespace default \
  --output jsonpath='{.spec.template.spec.containers[?(@.name=="huatuo")].resources}'

After updating huatuo-bamai.conf, repeat section 1.3 to update the ConfigMap, then trigger a rolling update manually:

kubectl rollout restart daemonset/huatuo --namespace default

2. Deploy with Helm

The Helm chart is in build/charts/.

2.1 Check the Environment

The administration machine needs Helm, kubectl, and access to the target Kubernetes cluster.

(command -v helm || curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash) && helm version

TARGET_CONTEXT="$(kubectl config get-contexts -o name | sed -n '1p')"
kubectl --context "${TARGET_CONTEXT}" get nodes

Confirm that the target nodes are Ready.

2.2 Prepare the Configuration

Follow sections 1.1 and 1.2 to download and edit huatuo-bamai.conf.

2.3 Set Deployment Parameters

Create values-production.yaml:

image:
  repository: <registry-accessible-to-all-nodes>/huatuo-bamai
  tag: "<pinned-release-version>"
  pullPolicy: IfNotPresent

resources:
  limits:
    cpu: "2"
    memory: 2Gi
  requests:
    cpu: "2"
    memory: 2Gi

nodeSelector:
  kubernetes.io/os: linux

tolerations:
  - operator: Exists

hostPaths:
  proc: /proc
  sys: /sys
  run: /run
  var: /var
  etc: /etc
  data: /var/log/huatuo/huatuo-local

2.4 Validate the Helm Chart

helm lint ./build/charts \
  -f ./values-production.yaml \
  --set-file config.content=./huatuo-bamai.conf

helm template huatuo ./build/charts \
  --namespace huatuo \
  -f ./values-production.yaml \
  --set-file config.content=./huatuo-bamai.conf \
  >/dev/null

2.5 Deploy the Collector

helm upgrade --install huatuo ./build/charts \
  --kube-context "${TARGET_CONTEXT}" \
  --namespace huatuo \
  --create-namespace \
  -f ./values-production.yaml \
  --set-file config.content=./huatuo-bamai.conf \
  --atomic \
  --timeout 10m

2.6 Verify the Deployment

helm status huatuo \
  --kube-context "${TARGET_CONTEXT}" \
  --namespace huatuo

kubectl --context "${TARGET_CONTEXT}" \
  --namespace huatuo \
  get daemonset,configmap,pod --output wide

kubectl --context "${TARGET_CONTEXT}" \
  --namespace huatuo \
  rollout status daemonset/huatuo \
  --timeout=10m

Inspect the collector logs:

kubectl --context "${TARGET_CONTEXT}" \
  --namespace huatuo \
  logs \
  --selector app.kubernetes.io/name=huatuo \
  --prefix \
  --tail=100

2.7 Update and Roll Back

After changing the image version or huatuo-bamai.conf, rerun the command in section 2.5.

View the release history and roll back to a specific revision:

helm history huatuo \
  --kube-context "${TARGET_CONTEXT}" \
  --namespace huatuo

helm rollback huatuo <Revision> \
  --kube-context "${TARGET_CONTEXT}" \
  --namespace huatuo \
  --wait \
  --timeout 10m

3 - Host Deployment

This guide covers installing HUATUO from a tar archive or RPM and managing it with systemd. Check the resource limits before starting, then verify the service status after installation.

Tar Archive

HUATUO releases provide static Linux tar archives for amd64 and arm64. Each archive contains the huatuo-bamai and huatuo-apiserver binaries, configuration files, and BPF objects.

These commands apply to releases with assets named huatuo-bamai-<version>-static-linux-<arch>.tar.gz. This naming scheme starts with v2.2.0; archives for v2.0.0 and v2.1.0 have different names and cannot use these commands unchanged.

Set HUATUO_VERSION to the target release, such as v2.2.0:

HUATUO_VERSION="<release-version>"

1. Download the Archive

On x86_64 hosts, download the amd64 archive:

wget "https://github.com/ccfos/huatuo/releases/download/${HUATUO_VERSION}/huatuo-bamai-${HUATUO_VERSION}-static-linux-amd64.tar.gz"

On aarch64 hosts, download the arm64 archive:

wget "https://github.com/ccfos/huatuo/releases/download/${HUATUO_VERSION}/huatuo-bamai-${HUATUO_VERSION}-static-linux-arm64.tar.gz"

2. Install the Archive

Create the installation, log, and data directories:

sudo install -d -m 0755 /opt/huatuo-bamai /var/log/huatuo-bamai /var/lib/huatuo-bamai

amd64:

sudo tar -xzf "huatuo-bamai-${HUATUO_VERSION}-static-linux-amd64.tar.gz" --strip-components=1 --no-same-owner -C /opt/huatuo-bamai

arm64:

sudo tar -xzf "huatuo-bamai-${HUATUO_VERSION}-static-linux-arm64.tar.gz" --strip-components=1 --no-same-owner -C /opt/huatuo-bamai

3. Install Service Units

Download the service units from the corresponding source release:

sudo wget -O /etc/systemd/system/huatuo-bamai.service "https://raw.githubusercontent.com/ccfos/huatuo/${HUATUO_VERSION}/build/rpm/huatuo-bamai.service"
sudo wget -O /etc/systemd/system/huatuo-apiserver.service "https://raw.githubusercontent.com/ccfos/huatuo/${HUATUO_VERSION}/build/rpm/huatuo-apiserver.service"

4. Edit the Configuration

Edit /opt/huatuo-bamai/conf/huatuo-bamai.conf and /opt/huatuo-bamai/conf/huatuo-apiserver.conf for your environment. See the huatuo-bamai configuration and huatuo-apiserver configuration for field details.

Set resource limits with CPUQuota, MemoryMax, and TasksMax in the service unit. Configure [Runtime] only when running directly with --enable-cgroup.

5. Reload Service Configuration

Reload the systemd configuration:

sudo systemctl daemon-reload

6. Start the Services

Start the services and enable them at boot:

sudo systemctl enable --now huatuo-bamai huatuo-apiserver

RPM Package

The OpenCloudOS repository provides HUATUO v2.1.0 RPM packages for x86_64 and aarch64. These packages install the HUATUO files and systemd service units.

1. Download the RPM

Download the package for your host architecture:

x86_64:

wget https://mirrors.opencloudos.tech/epol/9/Everything/x86_64/os/Packages/huatuo-bamai-2.1.0-2.oc9.x86_64.rpm

aarch64:

wget https://mirrors.opencloudos.tech/epol/9/Everything/aarch64/os/Packages/huatuo-bamai-2.1.0-2.oc9.aarch64.rpm

2. Install the RPM

x86_64:

sudo dnf install ./huatuo-bamai-2.1.0-2.oc9.x86_64.rpm

aarch64:

sudo dnf install ./huatuo-bamai-2.1.0-2.oc9.aarch64.rpm

3. Edit the Configuration

Edit /etc/huatuo-bamai/huatuo-bamai.conf for your environment. See the huatuo-bamai configuration for field details.

Set resource limits with CPUQuota, MemoryMax, and TasksMax in the service unit. Configure [Runtime] only when running directly with --enable-cgroup.

4. Start the Service

The RPM installs huatuo-bamai.service. Start the service and enable it at boot:

sudo systemctl enable --now huatuo-bamai

See the RPM installation guide for the full instructions.

Resource Limits and Verification

Systemd manages resource limits and the process lifecycle for huatuo-bamai.service. The service unit does not enable Huatuo’s own cgroup by default. It uses these native settings:

[Service]
CPUAccounting=yes
CPUQuota=200%
MemoryAccounting=yes
MemoryMax=2G
TasksAccounting=yes
TasksMax=32768
KillMode=control-group

CPUQuota=200% allows up to 2 CPU cores; MemoryMax=2G limits service memory. Adjust these values for host capacity, collection tasks, and peak usage. Do not pass --enable-cgroup in systemd deployments, as it moves the process out of the service cgroup.

After starting the service, check its status and cgroup:

systemctl status huatuo-bamai --no-pager
systemd-cgls --unit huatuo-bamai.service