From 85f171290b57f7b579cdc01fba17bd1f741f54ec Mon Sep 17 00:00:00 2001 From: rcourtman Date: Thu, 22 Jan 2026 16:41:40 +0000 Subject: [PATCH] Support: Add Kubernetes monitoring options to agent installers - Added --kube-include-all-pods and --kube-include-all-deployments flags - Added --help support to install.sh - Moved root check in install.sh to allow viewing help as non-root --- scripts/install-container-agent.sh | 16 +++++++++ scripts/install.sh | 54 ++++++++++++++++++++++++++---- 2 files changed, 64 insertions(+), 6 deletions(-) diff --git a/scripts/install-container-agent.sh b/scripts/install-container-agent.sh index a9a143d88..a6828076a 100755 --- a/scripts/install-container-agent.sh +++ b/scripts/install-container-agent.sh @@ -146,6 +146,8 @@ NO_AUTO_UPDATE_FLAG="" DOWNLOAD_ARCH="" AGENT_PATH_OVERRIDE="" AGENT_PATH="" +KUBE_INCLUDE_ALL_PODS="false" +KUBE_INCLUDE_ALL_DEPLOYMENTS="false" PULSE_TARGETS_ENV="${PULSE_TARGETS:-}" PULSE_RUNTIME_ENV="$(trim "${PULSE_RUNTIME:-}")" @@ -175,6 +177,8 @@ Options: --rootless Force rootless install (user service). --system Force system-wide install (requires root). --agent-path Override binary installation path. + --kube-include-all-pods Include all non-succeeded pods. + --kube-include-all-deployments Include all deployments. --uninstall Remove existing installation. --purge Remove config files when uninstalling. --help Show this help message. @@ -239,6 +243,14 @@ while [[ $# -gt 0 ]]; do AGENT_PATH_OVERRIDE="${1#*=}" shift ;; + --kube-include-all-pods) + KUBE_INCLUDE_ALL_PODS="true" + shift + ;; + --kube-include-all-deployments) + KUBE_INCLUDE_ALL_DEPLOYMENTS="true" + shift + ;; --uninstall) UNINSTALL="true" shift @@ -674,6 +686,8 @@ write_rootful_env() { if [[ "$PRIMARY_INSECURE" == "true" ]]; then printf 'PULSE_INSECURE_SKIP_VERIFY=true\n' fi + printf 'PULSE_KUBE_INCLUDE_ALL_PODS=%q\n' "$KUBE_INCLUDE_ALL_PODS" + printf 'PULSE_KUBE_INCLUDE_ALL_DEPLOYMENTS=%q\n' "$KUBE_INCLUDE_ALL_DEPLOYMENTS" } > "$tmp" mv "$tmp" "$ROOTFUL_ENV_FILE" @@ -817,6 +831,8 @@ write_rootless_env() { if [[ "$PRIMARY_INSECURE" == "true" ]]; then printf 'PULSE_INSECURE_SKIP_VERIFY=true\n' fi + printf 'PULSE_KUBE_INCLUDE_ALL_PODS=%q\n' "$KUBE_INCLUDE_ALL_PODS" + printf 'PULSE_KUBE_INCLUDE_ALL_DEPLOYMENTS=%q\n' "$KUBE_INCLUDE_ALL_DEPLOYMENTS" } > "$tmp" mv "$tmp" "$ROOTLESS_ENV_FILE" diff --git a/scripts/install.sh b/scripts/install.sh index 658f31fb6..791a4c255 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -13,6 +13,8 @@ # --enable-kubernetes Force enable Kubernetes monitoring (default: auto-detect) # --kubeconfig Path to kubeconfig file (auto-detected if not specified) # --disable-kubernetes Disable Kubernetes monitoring even if detected +# --kube-include-all-pods Include all non-succeeded pods (default: false) +# --kube-include-all-deployments Include all deployments (default: false) # --enable-proxmox Force enable Proxmox integration (default: auto-detect) # --disable-proxmox Disable Proxmox integration even if detected # --interval Reporting interval (default: 30s) @@ -45,12 +47,6 @@ cleanup() { } trap cleanup EXIT -# --- Check Root --- -if [[ $EUID -ne 0 ]]; then - echo "This script must be run as root. Please use sudo." - exit 1 -fi - # --- Configuration --- AGENT_NAME="pulse-agent" BINARY_NAME="pulse-agent" @@ -78,6 +74,8 @@ INSECURE="false" AGENT_ID="" ENABLE_COMMANDS="false" KUBECONFIG_PATH="" # Path to kubeconfig file for Kubernetes monitoring +KUBE_INCLUDE_ALL_PODS="false" +KUBE_INCLUDE_ALL_DEPLOYMENTS="false" DISK_EXCLUDES=() # Array for multiple --disk-exclude values # Track if flags were explicitly set (to override auto-detection) @@ -99,6 +97,35 @@ fail() { exit 1 } +show_help() { + cat < Pulse server URL (e.g. http://pulse:7655) + --token Pulse API token + --interval Reporting interval (default: 30s) + --enable-host Enable host metrics (default: true) + --disable-host Disable host metrics + --enable-docker Force enable Docker monitoring + --enable-kubernetes Force enable Kubernetes monitoring + --kubeconfig Path to kubeconfig file + --kube-include-all-pods Include all non-succeeded pods + --kube-include-all-deployments Include all deployments + --enable-proxmox Force enable Proxmox integration + --agent-id Custom agent identifier + --disk-exclude Exclude mount point (repeatable) + --insecure Skip TLS verification + --enable-commands Enable AI command execution + --uninstall Remove the agent + --help, -h Show this help + +EOF +} + # --- SELinux Context Restoration --- # On SELinux-enforcing systems (Fedora, RHEL, CentOS), binaries in non-standard # locations need proper security contexts for systemd to execute them. @@ -240,6 +267,8 @@ build_exec_args() { if [[ -n "$PROXMOX_TYPE" ]]; then EXEC_ARGS="$EXEC_ARGS --proxmox-type ${PROXMOX_TYPE}"; fi if [[ "$INSECURE" == "true" ]]; then EXEC_ARGS="$EXEC_ARGS --insecure"; fi if [[ "$ENABLE_COMMANDS" == "true" ]]; then EXEC_ARGS="$EXEC_ARGS --enable-commands"; fi + if [[ "$KUBE_INCLUDE_ALL_PODS" == "true" ]]; then EXEC_ARGS="$EXEC_ARGS --kube-include-all-pods"; fi + if [[ "$KUBE_INCLUDE_ALL_DEPLOYMENTS" == "true" ]]; then EXEC_ARGS="$EXEC_ARGS --kube-include-all-deployments"; fi if [[ -n "$AGENT_ID" ]]; then EXEC_ARGS="$EXEC_ARGS --agent-id ${AGENT_ID}"; fi # Add disk exclude patterns (use ${arr[@]+"${arr[@]}"} for bash 3.2 compatibility with set -u) for pattern in ${DISK_EXCLUDES[@]+"${DISK_EXCLUDES[@]}"}; do @@ -264,6 +293,8 @@ build_exec_args_array() { if [[ -n "$PROXMOX_TYPE" ]]; then EXEC_ARGS_ARRAY+=(--proxmox-type "$PROXMOX_TYPE"); fi if [[ "$INSECURE" == "true" ]]; then EXEC_ARGS_ARRAY+=(--insecure); fi if [[ "$ENABLE_COMMANDS" == "true" ]]; then EXEC_ARGS_ARRAY+=(--enable-commands); fi + if [[ "$KUBE_INCLUDE_ALL_PODS" == "true" ]]; then EXEC_ARGS_ARRAY+=(--kube-include-all-pods); fi + if [[ "$KUBE_INCLUDE_ALL_DEPLOYMENTS" == "true" ]]; then EXEC_ARGS_ARRAY+=(--kube-include-all-deployments); fi if [[ -n "$AGENT_ID" ]]; then EXEC_ARGS_ARRAY+=(--agent-id "$AGENT_ID"); fi # Add disk exclude patterns (use ${arr[@]+"${arr[@]}"} for bash 3.2 compatibility with set -u) for pattern in ${DISK_EXCLUDES[@]+"${DISK_EXCLUDES[@]}"}; do @@ -274,6 +305,7 @@ build_exec_args_array() { # --- Parse Arguments --- while [[ $# -gt 0 ]]; do case $1 in + --help|-h) show_help; exit 0 ;; --url) PULSE_URL="$2"; shift 2 ;; --token) PULSE_TOKEN="$2"; shift 2 ;; --interval) INTERVAL="$2"; shift 2 ;; @@ -291,11 +323,19 @@ while [[ $# -gt 0 ]]; do --enable-commands) ENABLE_COMMANDS="true"; shift ;; --uninstall) UNINSTALL="true"; shift ;; --agent-id) AGENT_ID="$2"; shift 2 ;; + --kube-include-all-pods) KUBE_INCLUDE_ALL_PODS="true"; shift ;; + --kube-include-all-deployments) KUBE_INCLUDE_ALL_DEPLOYMENTS="true"; shift ;; --disk-exclude) DISK_EXCLUDES+=("$2"); shift 2 ;; *) fail "Unknown argument: $1" ;; esac done +# --- Check Root --- +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root. Please use sudo." + exit 1 +fi + # --- URL Normalization --- # Strip trailing slashes from PULSE_URL to prevent double-slash URLs # (e.g., http://host:7655//download/... which would match frontend routes) @@ -1122,6 +1162,8 @@ PULSE_INTERVAL=${INTERVAL} PULSE_ENABLE_HOST=${ENABLE_HOST} PULSE_ENABLE_DOCKER=${ENABLE_DOCKER} PULSE_ENABLE_KUBERNETES=${ENABLE_KUBERNETES} +PULSE_KUBE_INCLUDE_ALL_PODS=${KUBE_INCLUDE_ALL_PODS} +PULSE_KUBE_INCLUDE_ALL_DEPLOYMENTS=${KUBE_INCLUDE_ALL_DEPLOYMENTS} EOF chmod 600 "$TRUENAS_ENV_FILE"