Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions kcl/lib/steps/k8s/install_helm.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import azure_pipelines.ap.steps

# Install Helm v3 on the pipeline agent.
InstallHelm = lambda -> steps.Step {
steps.Bash {
bash = """\
set -euo pipefail
if ! command -v helm >/dev/null 2>&1; then
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
fi
helm version --short"""
displayName = "Install Helm"
}
}
26 changes: 26 additions & 0 deletions kcl/lib/steps/k8s/install_prometheus.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import azure_pipelines.ap.steps
import lib.steps.azure

# Install kube-prometheus-stack via Helm. Caller must run InstallHelm and azure.GetCredentials first, and check in a values.yaml.
InstallPrometheus = lambda serviceConnection: str, valuesFile: str, namespace: str = "monitoring", releaseName: str = "prometheus", chartVersion: str = "", waitTimeout: str = "10m" -> steps.Step {
script = """
set -euo pipefail

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts >/dev/null 2>&1 || true
helm repo update prometheus-community

VERSION_FLAG=""
if [ -n "${chartVersion}" ]; then
VERSION_FLAG="--version ${chartVersion}"
fi

helm upgrade --install "${releaseName}" prometheus-community/kube-prometheus-stack \\
--namespace "${namespace}" --create-namespace \\
--values "$(Pipeline.Workspace)/s/${valuesFile}" \\
--wait --atomic --timeout "${waitTimeout}" \\
\${VERSION_FLAG}

echo "==> Prometheus release '${releaseName}' is ready in namespace '${namespace}'"
"""
azure.AzCli(serviceConnection, "Install Prometheus", script)
}