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中添加便可生效;
全部啓動參數:nginx

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

參數說明地址git

  • 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接口的體現
相關文章
相關標籤/搜索