Quickstart: Deploy kube-prometheus on kubeadm
mainFollow these steps to perform a rapid installation of the kube-prometheus stack. This process installs the Prometheus Operator, node-exporter, kube-state-metrics, Grafana, Prometheus, and Alertmanager.
Prerequisites
- A running Kubernetes cluster deployed via
kubeadmwith the controller-manager and scheduler exposed (see configuration guide). - The
kube-prometheusrepository cloned locally.
Installation Steps
- Clone the repository and enter the directory.
- Create a dedicated namespace (e.g.,
monitoring). - Apply Prometheus Operator manifests and wait for CRDs to become available.
- Install
node-exporterandkube-state-metrics. - Deploy Grafana credentials and the Grafana instance.
- Deploy the
Prometheusobject along with its required roles and role-bindings. - Install
Alertmanager.
Default Access (via NodePorts)
- Prometheus UI: Port
30900 - Alertmanager UI: Port
30903 - Grafana: Port
30902(Default credentials:admin/admin)
Note: It is highly recommended to change default Grafana credentials for production and use proper service exposure methods instead of NodePorts.
# 1. Clone repository
git clone https://github.com/prometheus-operator/kube-prometheus
cd kube-prometheus/
# 2. Create namespace
export NAMESPACE='monitoring'
kubectl create namespace "$NAMESPACE"
# 3. Install Prometheus Operator
kubectl --namespace="$NAMESPACE" apply -f manifests/prometheus-operator
# Wait for CRDs
until kubectl --namespace="$NAMESPACE" get alertmanagers.monitoring.coreos.com > /dev/null 2>&1; do sleep 1; printf "."; done
# 4. Install exporters
kubectl --namespace="$NAMESPACE" apply -f manifests/node-exporter
kubectl --namespace="$NAMESPACE" apply -f manifests/kube-state-metrics
# 5. Install Grafana
kubectl --namespace="$NAMESPACE" apply -f manifests/grafana/grafana-credentials.yaml
kubectl --namespace="$NAMESPACE" apply -f manifests/grafana
# 6. Install Prometheus
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
# 7. Install Alertmanager
kubectl --namespace="$NAMESPACE" apply -f manifests/alertmanager