LoginSignup
3
4

More than 1 year has passed since last update.

Prometheus Operator インストール

Last updated at Posted at 2020-09-29

概要

  • k8sテスト環境構築
    Prometheus Operator インストール

構築目次

環境

  • Rancher: v2.6.3
  • kubernetes(Client): v1.22.4
  • kubernetes(Server): v1.22.4
  • kube-prometheus-stack Chart: v26.1.0
  • kube-prometheus-stack App: v0.53.1

前提条件

インストール

設定ファイル作成

  • 各componentのingressを設定
  • Grafanaのパスワードを設定
    ※PersistentVolumeのデフォルト設定は「emptyDir」
config.yaml
alertmanager:
  ingress:
    enabled: true
    ingressClassName: nginx
    hosts:
      - alertmanager.test.local
prometheus:
  ingress:
    enabled: true
    ingressClassName: nginx
    hosts:
      - prometheus.test.local
grafana:
  adminPassword: xxxxxxx
  ingress:
    enabled: true
    ingressClassName: nginx
    hosts:
      - grafana.test.local

prometheus operator インストール

## helmにインストール用repo追加とupdate ##
$ helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
$ helm repo update

## 確認 ##
$ helm search repo prometheus-community/kube-prometheus-stack
NAME                                        CHART VERSION   APP VERSION DESCRIPTION                                       
prometheus-community/kube-prometheus-stack  26.1.0          0.53.1      kube-prometheus-stack collects Kubernetes manif...

## namespace(monitoring) 作成 ##
$ kubectl create ns monitoring

## 「prometheus-community/kube-prometheus-stack」を指定名前(prometheus)で指定namespace(monitoring)にインストール
## 上記で作成した設定ファイル(config.yaml)を指定
$ helm install prometheus -n monitoring -f config.yaml prometheus-community/kube-prometheus-stack

## 確認 ##
$ kubectl get all -n monitoring
NAME                                                         READY   STATUS    RESTARTS   AGE
pod/alertmanager-prometheus-kube-prometheus-alertmanager-0   2/2     Running   0          37s
pod/prometheus-grafana-9c84cf568-fxmnv                       3/3     Running   0          46s
pod/prometheus-kube-prometheus-operator-7c64864bb7-xnxj8     1/1     Running   0          46s
pod/prometheus-kube-state-metrics-676876fdcc-5b78j           1/1     Running   0          46s
pod/prometheus-prometheus-kube-prometheus-prometheus-0       2/2     Running   0          37s
pod/prometheus-prometheus-node-exporter-vw7tw                1/1     Running   0          46s
pod/prometheus-prometheus-node-exporter-w62kt                1/1     Running   0          46s
pod/prometheus-prometheus-node-exporter-wbkrq                1/1     Running   0          46s

NAME                                              TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
service/alertmanager-operated                     ClusterIP   None            <none>        9093/TCP,9094/TCP,9094/UDP   38s
service/prometheus-grafana                        ClusterIP   10.43.109.80    <none>        80/TCP                       46s
service/prometheus-kube-prometheus-alertmanager   ClusterIP   10.43.158.119   <none>        9093/TCP                     46s
service/prometheus-kube-prometheus-operator       ClusterIP   10.43.131.158   <none>        443/TCP                      46s
service/prometheus-kube-prometheus-prometheus     ClusterIP   10.43.146.16    <none>        9090/TCP                     46s
service/prometheus-kube-state-metrics             ClusterIP   10.43.127.181   <none>        8080/TCP                     46s
service/prometheus-operated                       ClusterIP   None            <none>        9090/TCP                     37s
service/prometheus-prometheus-node-exporter       ClusterIP   10.43.240.65    <none>        9100/TCP                     46s

NAME                                                 DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
daemonset.apps/prometheus-prometheus-node-exporter   3         3         3       3            3           <none>          46s

NAME                                                  READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/prometheus-grafana                    1/1     1            1           46s
deployment.apps/prometheus-kube-prometheus-operator   1/1     1            1           46s
deployment.apps/prometheus-kube-state-metrics         1/1     1            1           46s

NAME                                                             DESIRED   CURRENT   READY   AGE
replicaset.apps/prometheus-grafana-9c84cf568                     1         1         1       46s
replicaset.apps/prometheus-kube-prometheus-operator-7c64864bb7   1         1         1       46s
replicaset.apps/prometheus-kube-state-metrics-676876fdcc         1         1         1       46s

NAME                                                                    READY   AGE
statefulset.apps/alertmanager-prometheus-kube-prometheus-alertmanager   1/1     38s
statefulset.apps/prometheus-prometheus-kube-prometheus-prometheus       1/1     37s

アクセス確認

  • hosts 設定追加
    Ingress用IPに「prometheus.test.local, grafana.test.local, alertmanager.test.local」に追加
$ cat /etc/hosts
........
192.168.245.111 prometheus.test.local grafana.test.local alertmanager.test.local
........

※ブラウザを開いてアクセス確認

3
4
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4