Files
infrastructure/monitoring/prometheus/install.sh

48 lines
1.3 KiB
Bash
Raw Normal View History

#!/bin/bash
# Install Prometheus/Grafana Stack
set -e
NAMESPACE="monitoring"
RELEASE_NAME="prometheus"
echo "📊 Installing Prometheus/Grafana Stack..."
# Check if helm is installed
if ! command -v helm &> /dev/null; then
echo "❌ Helm not found. Please install Helm first."
exit 1
fi
# Check if kubectl is installed
if ! command -v kubectl &> /dev/null; then
echo "❌ kubectl not found. Please install kubectl first."
exit 1
fi
# Create namespace
echo "📦 Creating namespace: $NAMESPACE"
kubectl create namespace "$NAMESPACE" --dry-run=client -o yaml | kubectl apply -f -
# Add Prometheus Helm repo
echo "📥 Adding Prometheus Helm repository..."
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
# Install Prometheus Stack
echo "🚀 Installing Prometheus Stack..."
helm upgrade --install "$RELEASE_NAME" prometheus-community/kube-prometheus-stack \
--namespace "$NAMESPACE" \
--create-namespace \
--values values.yaml \
--wait
echo "✅ Prometheus/Grafana Stack installed successfully!"
echo ""
echo "📝 Access Grafana:"
echo " kubectl port-forward -n $NAMESPACE svc/$RELEASE_NAME-grafana 3000:80"
echo ""
echo "📝 Access Prometheus:"
echo " kubectl port-forward -n $NAMESPACE svc/$RELEASE_NAME-kube-prom-prometheus 9090:9090"