mirror of
https://github.com/carlosedp/cluster-monitoring.git
synced 2024-12-22 19:09:30 +01:00
43 lines
1.7 KiB
Plaintext
43 lines
1.7 KiB
Plaintext
|
#!/usr/bin/env bash
|
||
|
|
||
|
if [ -z "${KUBECONFIG}" ]; then
|
||
|
export KUBECONFIG=~/.kube/config
|
||
|
fi
|
||
|
|
||
|
# CAUTION - setting NAMESPACE will deploy most components to the given namespace
|
||
|
# however some are hardcoded to 'monitoring'. Only use if you have reviewed all manifests.
|
||
|
|
||
|
if [ -z "${NAMESPACE}" ]; then
|
||
|
NAMESPACE=monitoring
|
||
|
fi
|
||
|
|
||
|
kubectl create namespace "$NAMESPACE"
|
||
|
|
||
|
kctl() {
|
||
|
kubectl --namespace "$NAMESPACE" "$@"
|
||
|
}
|
||
|
|
||
|
kubectl apply -f manifests/k8s
|
||
|
|
||
|
kctl apply -f manifests/prometheus-operator
|
||
|
|
||
|
# Wait for CRDs to be ready.
|
||
|
printf "Waiting for Operator to register custom resource definitions..."
|
||
|
until kctl get customresourcedefinitions servicemonitors.monitoring.coreos.com > /dev/null 2>&1; do sleep 1; printf "."; done
|
||
|
until kctl get customresourcedefinitions prometheuses.monitoring.coreos.com > /dev/null 2>&1; do sleep 1; printf "."; done
|
||
|
until kctl get customresourcedefinitions alertmanagers.monitoring.coreos.com > /dev/null 2>&1; do sleep 1; printf "."; done
|
||
|
until kctl get servicemonitors.monitoring.coreos.com > /dev/null 2>&1; do sleep 1; printf "."; done
|
||
|
until kctl get prometheuses.monitoring.coreos.com > /dev/null 2>&1; do sleep 1; printf "."; done
|
||
|
until kctl get alertmanagers.monitoring.coreos.com > /dev/null 2>&1; do sleep 1; printf "."; done
|
||
|
echo "done!"
|
||
|
|
||
|
kctl apply -f manifests/node-exporter
|
||
|
kctl apply -f manifests/kube-state-metrics
|
||
|
kctl apply -f manifests/grafana/grafana-credentials.yaml
|
||
|
kctl apply -f manifests/grafana
|
||
|
find manifests/prometheus -type f ! -name prometheus-k8s-roles.yaml ! -name prometheus-k8s-role-bindings.yaml -exec kubectl --namespace "$NAMESPACE" apply -f {} \;
|
||
|
kubectl apply -f manifests/prometheus/prometheus-k8s-roles.yaml
|
||
|
kubectl apply -f manifests/prometheus/prometheus-k8s-role-bindings.yaml
|
||
|
kctl apply -f manifests/alertmanager/
|
||
|
|