温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

pushgateway on k8s是怎样部署yaml

发布时间:2021-12-16 09:48:37 来源:亿速云 阅读:266 作者:柒染 栏目:大数据

pushgateway on k8s是怎样部署yaml,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

pushgateway on k8s 部署yaml

prometheus pushgateway部署的yaml文件

  • pushgatewaydeployment文件内容

apiVersion: apps/v1beta2
kind: Deployment
metadata:
  namespace: kube-ops
  name:  pushgateway-ttt
  labels:
    app:  pushgateway-ttt
  annotations:
    prometheus.io/scrape: "true"
    prometheus.io/port: "8080"
spec:
  replicas: 1
  revisionHistoryLimit: 0
  selector:
    matchLabels:
      app:  pushgateway-ttt
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: "25%"
      maxUnavailable: "25%"
  template:
    metadata:
      name:  pushgateway-ttt
      labels:
        app:  pushgateway-ttt
    spec:
      containers:
        - name:  pushgateway-ttt
          image: prom/pushgateway:v0.7.0
          imagePullPolicy: IfNotPresent
          livenessProbe:
            initialDelaySeconds: 600
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 10
            httpGet:
              path: /
              port: 9091
          ports:
            - name: "app-port"
              containerPort: 9091
          resources:
            limits:
              memory: "1000Mi"
              cpu: 1
            requests:
              memory: "1000Mi"
              cpu: 1

prom/pushgateway可以在hub.docker.io查到dockerfile文件及部署说明,启动参数--persistence.file等都是放入spec.args中添加即可生效;
所有启动参数:

--web.listen-address default:9091
--web.telemetry-path  default:/metrics
--web.route-prefix default:""
--persistence.file default: ""
--persistence.interval default: 5m

参数说明地址

  • pushgatewayservice文件内容

apiVersion: v1
kind: Service
metadata:
  name: pushgateway-ttt
  namespace: kube-ops
  labels:
    app: pushgateway-ttt
spec:
  selector:
    app: pushgateway-ttt
  #type: NodePort
  ports:
    - name: pushgateway-ttt
      port: 9091
      targetPort: 9091
  • pushgatewayingress文件内容

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: pushgateway-ingress
  namespace: kube-ops
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: push-prometheus.ttt.mucang.cn
    http:
      paths:
      - path: /
        backend:
          serviceName: pushgateway-ttt
          servicePort: 9091

Prometheus中配置pushgatewaypull pushgateway数据配置

# prometheus配置文件中配置pull pushgateway组件配置
- job_name: 'pushgateway'
  scrape_interval: 60s
  metrics_path: /metrics
  static_configs:
  - targets: ["push-prometheus.xxx.xx.xx]
# prometheus的deployment配置文件配置环境变量,这样prometheus才会去pull pushgateway缓存的数据
# 所有推到pushgateway的数据都会在/metrics接口的体现

看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注亿速云行业资讯频道,感谢您对亿速云的支持。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI