1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關咨詢
      選擇下列產品馬上在線溝通
      服務時間:8:30-17:00
      你可能遇到了下面的問題
      關閉右側工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      在k8s集群中安裝prometheus

      在早期的版本中 Kubernetes 提供了 heapster、influxDB、grafana 的組合來監(jiān)控系統(tǒng),現(xiàn)在更加流行的監(jiān)控工具是 prometheus,prometheus 是 Google 內部監(jiān)控報警系統(tǒng)的開源版本

      成都創(chuàng)新互聯(lián)公司主營從化網(wǎng)站建設的網(wǎng)絡公司,主營網(wǎng)站建設方案,成都APP應用開發(fā),從化h5小程序定制開發(fā)搭建,從化網(wǎng)站營銷推廣歡迎從化等地區(qū)企業(yè)咨詢

      Kubernetes 集群的監(jiān)控方案目前主要有以下幾種方案:
      1、Heapster:Heapster 是一個集群范圍的監(jiān)控和數(shù)據(jù)聚合工具,以 Pod 的形式運行在集群中。
      2、metrics-server:metrics-server 也是一個集群范圍內的資源數(shù)據(jù)聚合工具,是 Heapster 的替代品,同樣的,metrics-server 也只是顯示數(shù)據(jù),并不提供數(shù)據(jù)存儲服務。
      3、cAdvisor:cAdvisor是Google開源的容器資源監(jiān)控和性能分析工具,它是專門為容器而生,本身也支持 Docker 容器,在 Kubernetes 中,我們不需要單獨去安裝,cAdvisor 作為 kubelet 內置的一部分程序可以直接使用。
      4、Kube-state-metrics:kube-state-metrics通過監(jiān)聽 API Server 生成有關資源對象的狀態(tài)指標,比如 Deployment、Node、Pod,需要注意的是 kube-state-metrics 只是簡單提供一個 metrics 數(shù)據(jù),并不會存儲這些指標數(shù)據(jù),所以我們可以使用 Prometheus 來抓取這些數(shù)據(jù)然后存儲。

      Prometheus 相比于其他傳統(tǒng)監(jiān)控工具主要有以下幾個特點:
      具有由 metric 名稱和鍵/值對標識的時間序列數(shù)據(jù)的多維數(shù)據(jù)模型
      有一個靈活的查詢語言
      不依賴分布式存儲,只和本地磁盤有關
      通過 HTTP 的服務拉取時間序列數(shù)據(jù)
      也支持推送的方式來添加時間序列數(shù)據(jù)
      還支持通過服務發(fā)現(xiàn)或靜態(tài)配置發(fā)現(xiàn)目標
      多種圖形和儀表板支持

      Prometheus 由多個組件組成,但是其中許多組件是可選的:
      Prometheus Server:用于抓取指標、存儲時間序列數(shù)據(jù)
      exporter:暴露指標讓任務來抓
      pushgateway:push 的方式將指標數(shù)據(jù)推送到該網(wǎng)關
      alertmanager:處理報警的報警組件
      adhoc:用于數(shù)據(jù)查詢

      1、創(chuàng)建獨立的命名空間

      apiVersion: v1
      kind: Namespace
      metadata:
        name: kube-ops

      2、以configmap的形式管理配置文件prometheus.yml

      apiVersion: v1
      kind: ConfigMap
      metadata:
        name: prometheus-config
        namespace: kube-ops
      data:
        prometheus.yml: |
          global:
            scrape_interval: 15s
            scrape_timeout: 15s
          scrape_configs:
          - job_name: 'prometheus'
            static_configs:
            - targets: ['localhost:9090']

      配置文件prometheus.yml中包含了3個模塊:global、rule_files 和 scrape_configs
      其中 global 模塊控制 Prometheus Server 的全局配置
      rule_files 模塊制定了規(guī)則所在的位置,prometheus 可以根據(jù)這個配置加載規(guī)則,用于生成新的時間序列數(shù)據(jù)或者報警信息,當前我們沒有配置任何規(guī)則
      scrape_configs 用于控制 prometheus 監(jiān)控哪些資源。
      在默認的配置里有一個單獨的 job,叫做prometheus,它采集 prometheus 服務本身的時間序列數(shù)據(jù)。這個 job 包含了一個單獨的、靜態(tài)配置的目標:監(jiān)聽 localhost 上的9090端口。
      prometheus 默認會通過目標的/metrics路徑采集 metrics。所以,默認的 job 通過 URL:http://localhost:9090/metrics采集 metrics。
      3、配置 rbac 認證

      apiVersion: v1
      kind: ServiceAccount
      metadata:
        name: prometheus
        namespace: kube-ops
      ---
      apiVersion: rbac.authorization.k8s.io/v1
      kind: ClusterRole
      metadata:
        name: prometheus
      rules:
      - apiGroups:
        - ""
        resources:
        - nodes
        - services
        - endpoints
        - pods
        - nodes/proxy
        verbs:
        - get
        - list
        - watch
      - apiGroups:
        - ""
        resources:
        - configmaps
        - nodes/metrics
        verbs:
        - get
      - nonResourceURLs:
        - /metrics
        verbs:
        - get
      ---
      apiVersion: rbac.authorization.k8s.io/v1beta1
      kind: ClusterRoleBinding
      metadata:
        name: prometheus
      roleRef:
        apiGroup: rbac.authorization.k8s.io
        kind: ClusterRole
        name: prometheus
      subjects:
      - kind: ServiceAccount
        name: prometheus
        namespace: kube-ops

      4、配置pv和pvc用于數(shù)據(jù)持久化

      apiVersion: v1
      kind: PersistentVolume
      metadata:
        name: prometheus
      spec:
        capacity:
          storage: 10Gi
        accessModes:
        - ReadWriteOnce
        persistentVolumeReclaimPolicy: Recycle
        nfs:
          server: 192.168.1.244
          path: /data/k8s
      
      ---
      apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        name: prometheus
        namespace: kube-ops
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 10Gi

      5、創(chuàng)建 prometheus 的 Pod 資源
      $ docker pull prom/prometheus:v2.4.3

      apiVersion: extensions/v1beta1
      kind: Deployment
      metadata:
        name: prometheus
        namespace: kube-ops
        labels:
          app: prometheus
      spec:
        template:
          metadata:
            labels:
              app: prometheus
          spec:
            serviceAccountName: prometheus
            containers:
            - image: prom/prometheus:v2.4.3
              name: prometheus
              command:
              - "/bin/prometheus"
              args:
              - "--config.file=/etc/prometheus/prometheus.yml"
              - "--storage.tsdb.path=/prometheus"
              - "--storage.tsdb.retention=24h"
              - "--web.enable-admin-api"  # 控制對admin HTTP API的訪問,其中包括刪除時間序列等功能
              - "--web.enable-lifecycle"  # 支持熱更新,直接執(zhí)行l(wèi)ocalhost:9090/-/reload立即生效
              ports:
              - containerPort: 9090
                protocol: TCP
                name: http
              volumeMounts:
              - mountPath: "/prometheus"
                subPath: prometheus
                name: data
              - mountPath: "/etc/prometheus"
                name: config-volume
              resources:
                requests:
                  cpu: 100m
                  memory: 512Mi
                limits:
                  cpu: 100m
                  memory: 512Mi
            securityContext:
              runAsUser: 0
            volumes:
            - name: data
              persistentVolumeClaim:
                claimName: prometheus
            - configMap:
                name: prometheus-config
              name: config-volume

      $ kubectl get pod -n kube-ops
      prometheus-77d968648-w5j6z 1/1 Running 53 82d
      6、創(chuàng)建prometheus pod的svc

      apiVersion: v1
      kind: Service
      metadata:
        name: prometheus
        namespace: kube-ops
        labels:
          app: prometheus
      spec:
        selector:
          app: prometheus
        type: NodePort
        ports:
          - name: web
            port: 9090
            targetPort: http

      $ kubectl get svc -n kube-ops
      prometheus NodePort 10.102.197.83 9090:32619/TCP
      http://192.168.1.243:32619
      點擊status----targets查看監(jiān)控目錄狀態(tài)


      當前標題:在k8s集群中安裝prometheus
      當前鏈接:http://ef60e0e.cn/article/ppgddj.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        海伦市| 方山县| 西华县| 亚东县| 定南县| 神农架林区| 武乡县| 仁布县| 鹤岗市| 沧源| 勐海县| 浦东新区| 托克逊县| 南部县| 浑源县| 庐江县| 景泰县| 凤翔县| 仪陇县| 崇阳县| 什邡市| 唐山市| 汉沽区| 锦州市| 瑞昌市| 扎鲁特旗| 寿宁县| 鹤山市| 元氏县| 兴国县| 黑龙江省| 旅游| 五寨县| 营山县| 阜新| 儋州市| 梁河县| 綦江县| 永新县| 石泉县| 牡丹江市|