• k8s安装promethus


    记录安装prometheus + grafana
    

    1.从github 下载prometheus

    git clone https://github.com/coreos/kube-prometheus.git
    cd kube-prometheus/manifests
    

    2.修改grafana-service.yaml文件,使用nodepode方式访问grafana

    vi grafana-service.yaml
    apiVersion: v1
    kind: Service
    metadata:
      labels:
        app: grafana
      name: grafana
      namespace: monitoring
    spec:
      type: NodePort   #新增
      ports:
      - name: http
        port: 3000
        targetPort: http
        nodePort: 30100  # 新增
      selector:
        app: grafana
    

    3.修改prometheus-service.yaml, 使用nodepode方式访问

    vi prometheus-service.yaml
    apiVersion: v1
    kind: Service
    metadata:
      labels:
        prometheus: k8s
      name: prometheus-k8s
      namespace: monitoring
    spec:
      type: NodePort  # 新增
      ports:
      - name: web
        port: 9090
        targetPort: web
        nodePort: 30200   # 新增
      selector:
        app: prometheus
        prometheus: k8s
      sessionAffinity: ClientIP
    

    4.修改alertmanager-service.yaml, 改为nodeport

    apiVersion: v1
    kind: Service
    metadata:
      labels:
        alertmanager: main
      name: alertmanager-main
      namespace: monitoring
    spec:
      type: NodePort
      ports:
      - name: web
        port: 9093
        targetPort: web
        nodePort: 30300
      selector:
        alertmanager: main
        app: alertmanager
      sessionAffinity: ClientIP
    

    5.部署

    该命令多运行几次
    kubectl apply -f manifests/
    

    6.查看pod是否正常运行

    kubectl get pod -n monitoring
    如果有镜像加载失败,需要手动加载
    

    7.手动加载镜像gcr.io-->registry.aliyuncs.com

    docker pull quay-mirror.qiniu.com/prometheus/alertmanager:v0.18.0
    docker tag quay-mirror.qiniu.com/prometheus/alertmanager:v0.18.0 quay.io/prometheus/alertmanager:v0.18.0
    
    docker pull quay-mirror.qiniu.com/prometheus/node-exporter:v0.18.1
    docker tag quay-mirror.qiniu.com/prometheus/node-exporter:v0.18.1 quay.io/prometheus/node-exporter:v0.18.1
    
    docker pull quay-mirror.qiniu.com/coreos/k8s-prometheus-adapter-amd64:v0.5.0
    docker tag quay-mirror.qiniu.com/coreos/k8s-prometheus-adapter-amd64:v0.5.0 quay.io/coreos/k8s-prometheus-adapter-amd64:v0.5.0
    
    docker pull quay-mirror.qiniu.com/prometheus/prometheus:v2.11.0
    docker tag quay-mirror.qiniu.com/prometheus/prometheus:v2.11.0 quay.io/prometheus/prometheus:v2.11.0
    
    docker pull quay-mirror.qiniu.com/coreos/prometheus-operator:v0.34.0
    docker tag quay-mirror.qiniu.com/coreos/prometheus-operator:v0.34.0 quay.io/coreos/prometheus-operator:v0.34.0
    

    8.再次查看pod是否正常运行

    kubectl get pod -n monitoring
    

    kubectl get svc --all-namespaces
    

    9.访问prometheus界面

    http://192.168.188.130:30200/
    sum by (pod_name)(rate(container_cpu_usage_seconds_total{image!="",pod_name!=""}[1m]))
    

    10.访问grafana

    http://192.168.188.130:30100/
    第一次登陆会要求修改密码
    admin/admin
    

    本文作者:温茶又折花

    本文链接: https://www.cnblogs.com/dyfblogs/p/14961480.html

    转载文章请注明作者和出处,谢谢!
  • 相关阅读:
    Fragment中获取Activity的Context (转)
    raw cannot be resolved or is not a field解决办法
    商业分析07_06分布情况分析
    商业分析07_04漏斗分析
    商业分析07_03数据涨跌异动如何处理
    商业分析07_02多维度拆解
    商业分析07_01对比分析
    商业分析07_00概述 数据分析
    商业分析06选择数据工具
    商业分析05如何选取数据指标
  • 原文地址:https://www.cnblogs.com/dyfblogs/p/14961480.html
Copyright © 2020-2023  润新知