This commit is contained in:
2026-08-12 11:59:14 +02:00
parent 3c4cfc9703
commit c87a5d3e7f
111 changed files with 19381 additions and 0 deletions
@@ -0,0 +1,58 @@
metricLabel="[Metric]"
# Copies vmagent config file to the configured metric path.
function cmdMetricPreparation() {
printInfo "$metricLabel Preparation..."
mkdir -p -- "$(dirname -- "$metricVmagentPath")" || return 1
cp -f -- "$appAssetsPath/metric/vmagent.yml" "$metricVmagentPath/vmagent.yml"
printSuccess "$metricLabel Preparatory completed"
}
# Renders the Metric Kubernetes YAML manifest via Helm.
function cmdMetricYamlRender() {
printInfo "$metricLabel Render YAML | Helm"
local templateFile="templates/$metricKube.yaml"
[[ -f "$appAssetsPath/k3s/$templateFile" ]] || {
printDanger "$metricLabel Template YAML : File not found | $appAssetsPath/k3s/$templateFile"
return 1
}
printInfo "$metricLabel Template YAML : $appAssetsPath/k3s/$templateFile"
local varsFile
varsFile=$(mktemp "/tmp/$metricKube.vars.XXXXXX.yaml") || return 1
printInfo "$metricLabel Variables : $varsFile"
trap 'rm -f -- "$varsFile"' RETURN
cat > "$varsFile" <<EOF
metricHelm: true
namespace: $k3sNamespace
metric: $metricKube
metricApiUrl: $metricApiUrl
metricPromPath: $metricPromPath
metricVmagentPath: $metricVmagentPath
EOF
printInfo "$metricLabel Render file : $metricYaml"
mkdir -p -- "$(dirname -- "$metricYaml")" || return 1
fileBackup "$metricYaml"
helm template stack "$appAssetsPath/k3s" -f "$varsFile" --show-only "$templateFile" > "$metricYaml" || {
printDanger "$metricLabel Render failed"
return 1
}
printSuccess "$metricLabel Render completed"
}
# Installs Metric components into Kubernetes.
function cmdMetricInstall() {
cmdMetricPreparation || return 1
cmdMetricYamlRender || return 1
cmdK3sYamlApplyEx "$metricYaml"
}
# Uninstalls Metric Kubernetes resources.
function cmdMetricUninstall() {
"$k3sCmd" kubectl delete -f "$metricYaml"
}