pushgateway on k8s 部署yamlprometheus pushgateway部署的yaml文件pushgateway的deployment文件内容apiVersion: apps/v1beta2kind: Deploymentmetadata: 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: 1prom/pushgateway可以在hub.docker.io查到dockerfile文件及部署说明pushgateway的service文件内容apiVersion: v1kind: Servicemetadata: name: pushgateway-ttt namespace: kube-ops labels: app: pushgateway-tttspec: selector: app: pushgateway-ttt #type: NodePort ports: - name: pushgateway-ttt port: 9091 targetPort: 9091pushgateway的ingress文件内容apiVersion: extensions/v1beta1kind: Ingressmetadata: name: pushgateway-ingress namespace: kube-ops annotations: kubernetes.io/ingress.class: nginxspec: rules: - host: push-prometheus.ttt.mucang.cn http: paths: - path: / backend: serviceName: pushgateway-ttt servicePort: 9091在Prometheus中配置pushgateway及pull 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缓存的数据env: - name: PUSH_GATEWAY value: “http://push-prometheus.ttt.mucang.cn”