fix: Correct Dockerfile lib path and add Helm dependency toggle

This commit includes two main changes:

1.  **Fix Dockerfile library path for amd64:**
    - I updated the `exporter/Dockerfile` to correctly determine the source path for `libiperf.so.0` when building for different architectures.
    - Specifically, for `TARGETARCH=amd64`, the path `/usr/lib/x86_64-linux-gnu/libiperf.so.0` is now used.
    - For `TARGETARCH=arm64`, the path `/usr/lib/aarch64-linux-gnu/libiperf.so.0` is used.
    - I achieved this by copying the library to a canonical temporary location in the builder stage based on `TARGETARCH`, and then copying it from this location into the final image. This resolves an issue where builds for `amd64` would fail to find the library.

2.  **Add Helm chart option to disable dependencies:**
    - I added a new option `dependencies.install` (default: `true`) to `charts/iperf3-monitor/values.yaml`.
    - This allows you to disable the installation of managed dependencies (i.e., Prometheus Operator via `kube-prometheus-stack` or `prometheus-operator` from TrueCharts) even if `serviceMonitor.enabled` is true.
    - I updated the `condition` for these dependencies in `charts/iperf3-monitor/Chart.yaml` to `dependencies.install, serviceMonitor.enabled, ...`.
    - This is useful for you if you manage your Prometheus Operator installation separately.
feat/add-arm64-support
google-labs-jules[bot] 2025-06-20 13:25:34 +00:00
parent a00629af7a
commit 2e019b16ff
3 changed files with 30 additions and 8 deletions

View File

@ -27,8 +27,8 @@ dependencies:
- name: kube-prometheus-stack # Example dependency if you package the whole stack
version: ">=30.0.0" # Specify a compatible version range
repository: https://prometheus-community.github.io/helm-charts
condition: "serviceMonitor.enabled, !dependencies.useTrueChartsPrometheusOperator"
condition: "dependencies.install, serviceMonitor.enabled, !dependencies.useTrueChartsPrometheusOperator"
- name: prometheus-operator
version: ">=8.11.1"
repository: "oci://tccr.io/truecharts"
condition: "serviceMonitor.enabled, dependencies.useTrueChartsPrometheusOperator"
condition: "dependencies.install, serviceMonitor.enabled, dependencies.useTrueChartsPrometheusOperator"

View File

@ -123,7 +123,14 @@ networkPolicy:
# Dependency Configuration
# -----------------------------------------------------------------------------
dependencies:
# -- Set to true to install Prometheus operator dependency if serviceMonitor.enabled is also true.
# -- Set to false to disable the installation of Prometheus operator dependency,
# -- regardless of serviceMonitor.enabled. This is useful if you have Prometheus
# -- Operator installed and managed separately in your cluster.
install: true
# -- Set to true to use the TrueCharts Prometheus Operator instead of kube-prometheus-stack.
# This chart's ServiceMonitor resources require a Prometheus Operator to be functional.
# If serviceMonitor.enabled is true, one of these two dependencies will be pulled based on this flag.
# If serviceMonitor.enabled is true and dependencies.install is true,
# one of these two dependencies will be pulled based on this flag.
useTrueChartsPrometheusOperator: false

View File

@ -1,6 +1,8 @@
# Stage 1: Build stage with dependencies
FROM python:3.9-slim as builder
# Declare TARGETARCH for use in this stage
ARG TARGETARCH
WORKDIR /app
# Install iperf3 and build dependencies
@ -8,6 +10,20 @@ RUN apt-get update && \
apt-get install -y --no-install-recommends gcc iperf3 libiperf-dev && \
rm -rf /var/lib/apt/lists/*
# Determine the correct libiperf source directory based on TARGETARCH
# and copy libiperf.so.0 to a canonical temporary location /tmp/lib/ within the builder stage.
RUN echo "Builder stage TARGETARCH: ${TARGETARCH}" && \
LIBIPERF_SRC_DIR_SEGMENT="" && \
if [ "${TARGETARCH}" = "amd64" ]; then \
LIBIPERF_SRC_DIR_SEGMENT="x86_64-linux-gnu"; \
elif [ "${TARGETARCH}" = "arm64" ]; then \
LIBIPERF_SRC_DIR_SEGMENT="aarch64-linux-gnu"; \
else \
echo "Unsupported TARGETARCH in builder: ${TARGETARCH}" && exit 1; \
fi && \
mkdir -p /tmp/lib && \
cp "/usr/lib/${LIBIPERF_SRC_DIR_SEGMENT}/libiperf.so.0" /tmp/lib/libiperf.so.0
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
@ -17,12 +33,11 @@ FROM python:3.9-slim
WORKDIR /app
# Declare TARGETARCH arg to be used in COPY instruction
ARG TARGETARCH
# Copy iperf3 binary and library from the builder stage
# Copy iperf3 binary from the builder stage
COPY --from=builder /usr/bin/iperf3 /usr/bin/iperf3
COPY --from=builder /usr/lib/${TARGETARCH}-linux-gnu/libiperf.so.0 /usr/lib/${TARGETARCH}-linux-gnu/libiperf.so.0
# Copy the prepared libiperf.so.0 from the builder's canonical temporary location
# into a standard library path in the final image.
COPY --from=builder /tmp/lib/libiperf.so.0 /usr/lib/libiperf.so.0
# Copy installed Python packages from the builder stage
COPY --from=builder /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages