前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >02 Jul 2020 在ocp4上运行prometheus

02 Jul 2020 在ocp4上运行prometheus

作者头像
俊采
发布2023-10-17 10:39:45
1490
发布2023-10-17 10:39:45
举报
文章被收录于专栏:LEo的网络日志LEo的网络日志

prometheus部署yaml

代码语言:javascript
复制
apiVersion: apps/v1
kind: Deployment
metadata:
  name: prometheus-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: prometheus-server
  template:
    metadata:
      labels:
        app: prometheus-server
    spec:
      containers:
        - name: prometheus
          image: prom/prometheus
          args:
            - "--config.file=/etc/prometheus/prometheus.yml"
            - "--storage.tsdb.path=/prometheus/"
          ports:
            - containerPort: 9090
          volumeMounts:
            - name: prometheus-config-volume
              mountPath: /etc/prometheus/
            - name: prometheus-storage-volume
              mountPath: /prometheus/
      volumes:
        - name: prometheus-config-volume
          configMap:
            defaultMode: 420
            name: prometheus-server-conf

        - name: prometheus-storage-volume
          emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
  name: prometheus-service
  annotations:
      prometheus.io/scrape: 'true'
      prometheus.io/port:   '9090'
spec:
  selector:
    app: prometheus-server
  ports:
  - name: default
    protocol: TCP
    port: 80
    targetPort: 9090

---
apiVersion: route.openshift.io/v1
kind: Route
metadata:
  labels:
    app: prometheus-server
  name: prometheus-server-route
spec:
  host: prometheus-service-ssli.apps.soli-acm-hub.dev05.red-chesterfield.com
  port:
    targetPort: default
  to:
    kind: Service
    name: prometheus-service
    weight: 100
  wildcardPolicy: None
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: prometheus-server-conf
  labels:
    name: prometheus-server-conf
data:
  prometheus.yml: |-
    global:
      scrape_interval:     60s
      evaluation_interval: 15s

    scrape_configs:
      - job_name: 'ssli-prometheus'
        scrape_interval: 3s
        static_configs:
        - targets: ['localhost:9090']
  • deployment 创建相应的prometheus,并挂载了相应的存储路径和配置文件。
  • service 创建svc以便访问prometheus服务。
  • route 讲prometheus暴露,方便集群外访问,这里可以使用prometheus-service-ssli.apps.soli-acm-hub.dev05.red-chesterfield.com访问到prometheus ui。
  • configMap prometheus相关配置文件。

部署prometheus

代码语言:javascript
复制
$ k apply -f prometheus.yaml
deployment.apps/prometheus-deployment created
service/prometheus-service created
route.route.openshift.io/prometheus-server-route created
configmap/prometheus-server-conf created
$ k get all
NAME                                         READY   STATUS    RESTARTS   AGE
pod/prometheus-deployment-77cb49fb5d-vv7s8   1/1     Running   0          88s

NAME                         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE
service/prometheus-service   ClusterIP   172.30.170.118   <none>        80/TCP    88s

NAME                                    READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/prometheus-deployment   1/1     1            1           88s

NAME                                               DESIRED   CURRENT   READY   AGE
replicaset.apps/prometheus-deployment-77cb49fb5d   1         1         1       88s

NAME                                               HOST/PORT                                                              PATH   SERVICES             PORT      TERMINATION   WILDCARD
route.route.openshift.io/prometheus-server-route   prometheus-service-ssli.apps.soli-acm-hub.dev05.red-chesterfield.com          prometheus-service   default                 None
$ curl prometheus-service-ssli.apps.soli-acm-hub.dev05.red-chesterfield.com
<a href="/graph">Found</a>.

也可以通过浏览器访问prometheus ui: http://prometheus-service-ssli.apps.soli-acm-hub.dev05.red-chesterfield.com/graph

ref

  • https://linuxacademy.com/blog/kubernetes/running-prometheus-on-kubernetes/

LEo at 12:12

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • prometheus部署yaml
  • 部署prometheus
  • ref
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档