部署Prometheus

操作步骤

  1. MindXDL-deploy仓库中获取“prometheus.yaml”文件,并执行以下命令获取镜像。

    docker pull prom/prometheus:v2.10.0

    1. 获取镜像前,请确保能够正常访问Docker Hub网站。
    2. 此处的prometheus.yaml已经默认包含获取npu-exporter metrics的相关的配置文件,用户可以根据需求自行修改相应的配置。

  2. 执行以下命令,给管理节点打标签。

    kubectl label nodes <管理节点Hostname> masterselector=dls-master-node --overwrite=true

  3. 执行以下命令,启动Prometheus服务。

    kubectl apply -f prometheus.yaml

    回显如下表示启动成功。

    [root@centos check_env]# kubectl apply -f promethues.yaml 
    clusterrole.rbac.authorization.k8s.io/prometheus created
    serviceaccount/prometheus created
    clusterrolebinding.rbac.authorization.k8s.io/prometheus created
    service/prometheus created
    deployment.apps/prometheus created
    configmap/prometheus-config created

  4. 查看Pod状态,Running状态表示服务正常。

    [root@centos check_env]# kubectl get pods --all-namespaces | grep prometheus
    kube-system      prometheus-58c69548b4-rhxsc                1/1     Running            0          6d14h

  5. 登录Prometheus服务。

    1. 打开浏览器。
    2. 在浏览器中输入“http://管理节点IP地址:端口号”并按“Enter”。

      在prometheus.yaml文件中找到nodePort字段,该字段的值为Prometheus服务的端口号,默认为30003。