日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

簡單4步,利用Prometheus Operator實(shí)現(xiàn)自定義指標(biāo)監(jiān)控

 可口可愛吧 2021-01-31

在過去的文章中,我們花了相當(dāng)大的篇幅來聊關(guān)于監(jiān)控的話題。這是因?yàn)楫?dāng)你正在管理Kubernetes集群時(shí),一切都會(huì)以極快的速度發(fā)生變化。因此有一個(gè)工具來監(jiān)控集群的健康狀態(tài)和資源指標(biāo)極為重要。

Rancher 2.5中,我們引入了基于Prometheus Operator的新版監(jiān)控,它可以提供Prometheus以及相關(guān)監(jiān)控組件的原生Kubernetes部署和管理。Prometheus Operator可以讓你監(jiān)控集群節(jié)點(diǎn)、Kubernetes組件和應(yīng)用程序工作負(fù)載的狀態(tài)和進(jìn)程。同時(shí),它還能夠通過Prometheus收集的指標(biāo)來定義告警并且創(chuàng)建自定義儀表盤,通過Grafana可以輕松地可視化收集到的指標(biāo)。你可以訪問下列鏈接獲取更多關(guān)于新版監(jiān)控組件的細(xì)節(jié):

新版本站長交易的監(jiān)控也采用prometheus-adapter,開發(fā)人員可以利用其基于自定義指標(biāo)和HPA擴(kuò)展他們的工作負(fù)載。

在本文中,我們將探索如何利用Prometheus Operator來抓取自定義指標(biāo)并利用這些指標(biāo)進(jìn)行高級工作負(fù)載管理。

安裝Prometheus

Rancher 2.5中安裝Prometheus極為簡單。僅需訪問Cluster Explorer -> Apps并安裝rancher-monitoring即可。

你需要了解以下默認(rèn)設(shè)置:

prometheus-adapter將會(huì)作為chart安裝的一部分啟用

ServiceMonitorNamespaceSelector 留為空,允許 Prometheus 在所有命名空間中收集 ServiceMonitors

部署工作負(fù)載

現(xiàn)在讓我們部署一個(gè)從應(yīng)用層暴露自定義指標(biāo)的示例工作負(fù)載。該工作負(fù)載暴露了一個(gè)簡單的應(yīng)用程序,該應(yīng)用程序已經(jīng)使用Prometheus client_golang庫進(jìn)行了檢測,并在/metric端點(diǎn)上提供了一些自定義指標(biāo)。

它有兩個(gè)指標(biāo):

http_requests_total

http_request_duration_seconds

以下manifest部署了工作負(fù)載、相關(guān)服務(wù)以及訪問該工作負(fù)載的ingress:

apiVersion: apps/v1kind: Deploymentmetadata:

  labels:

    app.kubernetes.io/name: prometheus-example-app

  name: prometheus-example-appspec:

  replicas: 1

  selector:

    matchLabels:

      app.kubernetes.io/name: prometheus-example-app

  template:

    metadata:

      labels:

        app.kubernetes.io/name: prometheus-example-app

    spec:

      containers:

      - name: prometheus-example-app

        image: gmehta3/demo-app:metrics

        ports:

        - name: web

          containerPort: 8080---apiVersion: v1kind: Servicemetadata:

  name: prometheus-example-app

  labels:

    app.kubernetes.io/name: prometheus-example-appspec:

  selector:

    app.kubernetes.io/name: prometheus-example-app

  ports:

    - protocol: TCP

      port: 8080

      targetPort: 8080

      name: web---apiVersion: networking.k8s.io/v1beta1kind: Ingressmetadata:

    name: prometheus-example-appspec:

    rules:

    - host: hpa.demo

      http:

        paths:

        - path: /

          backend:

            serviceName: prometheus-example-app

            servicePort: 8080

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多