自宅のラズパイk8sクラスターにPrometheus Stackを生やしていく
Helm Chart Repositoryを追加
$ helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
$ helm repo update Hang tight while we grab the latest from your chart repositories... ...Successfully got an update from the "prometheus-community" chart repository Update Complete. ⎈Happy Helming!⎈
namespaceの作成
$ k create namespace monitoring namespace/monitoring created
helm installの実行
$ helm install kube-prometheus-stack prometheus-community/kube-prometheus-stack NAME: kube-prometheus-stack LAST DEPLOYED: Mon Jun 3 21:26:28 2024 NAMESPACE: monitoring STATUS: deployed REVISION: 1 NOTES: kube-prometheus-stack has been installed. Check its status by running: kubectl --namespace monitoring get pods -l "release=kube-prometheus-stack" Visit https://github.com/prometheus-operator/kube-prometheus for instructions on how to create & configure Alertmanager and Prometheus instances using the Operator.
起動確認
Pod
$ k get po NAME READY STATUS RESTARTS AGE alertmanager-kube-prometheus-stack-alertmanager-0 2/2 Running 0 49m kube-prometheus-stack-grafana-67997d8bd4-wnh9f 3/3 Running 0 49m kube-prometheus-stack-kube-state-metrics-657ddb7877-jcj26 1/1 Running 0 49m kube-prometheus-stack-operator-5975686646-bhk6m 1/1 Running 0 49m kube-prometheus-stack-prometheus-node-exporter-jc6qx 1/1 Running 0 49m kube-prometheus-stack-prometheus-node-exporter-n5hwh 1/1 Running 0 49m kube-prometheus-stack-prometheus-node-exporter-x6kz6 1/1 Running 0 49m prometheus-kube-prometheus-stack-prometheus-0 2/2 Running 0 49m
Grafanaへアクセス
自動生成されたServiceを使ってport-forward
する
$ k port-forward service/kube-prometheus-stack-grafana 8080:80 Forwarding from 127.0.0.1:8080 -> 3000 Forwarding from [::1]:8080 -> 3000 Handling connection for 8080 Handling connection for 8080
http://localhost:8080/login へアクセスしてログイン画面が出ることを確認
デフォルトで以下のログイン情報となっているのでログインしてみる
username | password |
---|---|
admin | prom-operator |
なんて簡単にできるんだ...(感動