Prometheus部署及应用(2)
Prometheus部署及应用(2)

Prometheus部署及应用(2)

helm部署kube-promethues

[root@k8s-Master-01 ~]#helm install prometheus -f ./kube-prometheus.yaml bitnami/kube-prometheus -n prom 
NAME: prometheus
LAST DEPLOYED: Sun Nov 27 14:30:50 2022
NAMESPACE: prom
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: kube-prometheus
CHART VERSION: 8.2.2
APP VERSION: 0.61.1

** Please be patient while the chart is being deployed **

Watch the Prometheus Operator Deployment status using the command:

    kubectl get deploy -w --namespace prom -l app.kubernetes.io/name=kube-prometheus-operator,app.kubernetes.io/instance=prometheus

Watch the Prometheus StatefulSet status using the command:

    kubectl get sts -w --namespace prom -l app.kubernetes.io/name=kube-prometheus-prometheus,app.kubernetes.io/instance=prometheus

Prometheus can be accessed via port "9090" on the following DNS name from within your cluster:

    prometheus-kube-prometheus-prometheus.prom.svc.cluster.local

To access Prometheus from outside the cluster execute the following commands:

  You should be able to access your new Prometheus installation through

  http://prometheus.shuhongcom

Watch the Alertmanager StatefulSet status using the command:

    kubectl get sts -w --namespace prom -l app.kubernetes.io/name=kube-prometheus-alertmanager,app.kubernetes.io/instance=prometheus

Alertmanager can be accessed via port "9093" on the following DNS name from within your cluster:

    prometheus-kube-prometheus-alertmanager.prom.svc.cluster.local

To access Alertmanager from outside the cluster execute the following commands:

  You should be able to access your new Prometheus installation through

  http://alertmanager.shuhong.com


[root@k8s-Master-01 ~]#kubectl get ingress -n prom
NAME                                      CLASS   HOSTS                      ADDRESS      PORTS   AGE
prometheus-kube-prometheus-alertmanager   nginx   alertmanager.shuhong.com   10.0.0.220   80      10m
prometheus-kube-prometheus-prometheus     nginx   prometheus.shuhong.com     10.0.0.220   80      10m
[root@k8s-Master-01 ~]#kubectl  get cm -n prom
NAME                                                           DATA   AGE
kube-root-ca.crt                                               1      20m
prometheus-kube-prometheus-blackbox-exporter                   1      14m
prometheus-kube-prometheus-operator                            1      14m
prometheus-prometheus-kube-prometheus-prometheus-rulefiles-0   0      11m
[root@k8s-Master-01 ~]#kubectl  get pods -n prom 
NAME                                                            READY   STATUS    RESTARTS   AGE
alertmanager-prometheus-kube-prometheus-alertmanager-0          2/2     Running   0          12m
alertmanager-prometheus-kube-prometheus-alertmanager-1          2/2     Running   0          12m
prometheus-kube-prometheus-blackbox-exporter-677f8dbc57-6f7sv   1/1     Running   0          14m
prometheus-kube-prometheus-operator-b66d587cf-5v982             1/1     Running   0          14m
prometheus-kube-state-metrics-6cfb9bb977-rhf52                  1/1     Running   0          14m
prometheus-node-exporter-gwmvg                                  1/1     Running   0          14m
prometheus-node-exporter-hpbh6                                  1/1     Running   0          14m
prometheus-node-exporter-q7n7w                                  1/1     Running   0          14m
prometheus-prometheus-kube-prometheus-prometheus-0              2/2     Running   0          12m
prometheus-prometheus-kube-prometheus-prometheus-1              2/2     Running   0          12m

部署prometheus-adapter

[root@k8s-Master-01 ~]#helm  repo add prometheus-community https://prometheus-community.github.io/helm-charts
"prometheus-community" has been added to your repositories

[root@k8s-Master-01 ~]#helm install prometheus-adapter -f ./prometheus-adapter.yaml  prometheus-community/prometheus-adapter -n prom
NAME: prometheus-adapter
LAST DEPLOYED: Sun Nov 27 15:31:24 2022
NAMESPACE: prom
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
prometheus-adapter has been deployed.
In a few minutes you should be able to list metrics using the following command(s):

  kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1