Skip to main content

prometheus-operator


설치

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update prometheus-community \
&& helm search repo prometheus-community/kube-prometheus-stack -l | head -n 10
helm show values prometheus-community/kube-prometheus-stack \
--version 42.1.0 \
> prometheus-operator-values.yaml
prometheus-operator-values.yaml
namespaceOverride: monitoring

commonLabels:
cluster: "<cluster-name>"

defaultRules:
# Chart가 제공하는 기본 alert and record rules의 집합
# https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack/templates/prometheus/rules-1.14
create: false

alertmanager:
enabled: false

grafana:
enabled: false

kubeApiServer:
enabled: false

kubelet:
# -kubelet 설치, cAdvisor: 실행중인 컨테이너의 정보
enabled: true

kubeControllerManager:
enabled: false

coreDns:
enabled: false

kubeDns:
enabled: false

kubeEtcd:
enabled: false

kubeScheduler:
enabled: false

kubeProxy:
enabled: false

kubeStateMetrics:
# -kube-state-metrics 설치, k8s Resource의 metadata, spec 등의 정보
# https://github.com/kubernetes/kube-state-metrics/tree/master/docs
enabled: true

nodeExporter:
# -node-exporter 설치, Node의 Hardware, kernel 관련 정보
enabled: true

prometheusOperator:
# -operator 설치
enabled: true
tls:
enabled: false

admissionWebhooks:
# PrometheusRules의 형식이 올바른지 확인해주는 기능인데 control plane이 webhook 서비스에
# 접근할 수 있어야하는 문제가 있습니다.
enabled: false

prometheus:
enabled: false
helm upgrade prometheus-operator prometheus-community/kube-prometheus-stack \
--install \
--version 42.1.0 \
-n monitoring \
--history-max 3 \
-f prometheus-operator-values.yaml
kubectl label namespace monitoring prometheus=enabled
helm uninstall -n monitoring prometheus-operator

helm으로 삭제한 후 CRDs 삭제를 위해 아래 명령어를 실행해줍니다.

kubectl delete crd alertmanagerconfigs.monitoring.coreos.com
kubectl delete crd alertmanagers.monitoring.coreos.com
kubectl delete crd podmonitors.monitoring.coreos.com
kubectl delete crd probes.monitoring.coreos.com
kubectl delete crd prometheuses.monitoring.coreos.com
kubectl delete crd prometheusrules.monitoring.coreos.com
kubectl delete crd servicemonitors.monitoring.coreos.com
kubectl delete crd thanosrulers.monitoring.coreos.com