k8s-学习笔记6-prom监控

https://blog.stanley.wang/2019/01/18/%E5%AE%9E%E9%AA%8C%E6%96%87%E6%A1%A34%EF%BC%9Akubernetes%E9%9B%86%E7%BE%A4%E7%9A%84%E7%9B%91%E6%8E%A7%E5%92%8C%E6%97%A5%E5%BF%97%E5%88%86%E6%9E%90/

 

1 kube-state-metrics

https://quay.io/repository/coreos/kube-state-metrics?tab=tags

 

 

2 node-exporter

每个节点一个,使用ds部署

/proc /sys挂载进来,因为很多系统信息在这些目录里

hostNetWork: True,和宿主机共享网络名称空间,就是容器里监听的端口,实际上在宿主机上,容器自己没有ip。

 

3 cadvisor

下载官方文件,加了一个hostport。

https://github.com/google/cadvisor/tree/master/deploy/kubernetes

# cat base/daemonset.yaml 
apiVersion: apps/v1 # for Kubernetes versions before 1.9.0 use apps/v1beta2
kind: DaemonSet
metadata:
  name: cadvisor
  namespace: cadvisor
  annotations:
      seccomp.security.alpha.kubernetes.io/pod: 'docker/default'
spec:
  selector:
    matchLabels:
      name: cadvisor
  template:
    metadata:
      labels:
        name: cadvisor
    spec:
      serviceAccountName: cadvisor
      containers:
      - name: cadvisor
        image: google/cadvisor:v0.30.2
        imagePullPolicy: IfNotPresent
        resources:
          requests:
            memory: 200Mi
            cpu: 150m
          limits:
            memory: 2000Mi
            cpu: 300m
        volumeMounts:
        - name: rootfs
          mountPath: /rootfs
          readOnly: true
        - name: var-run
          mountPath: /var/run
          readOnly: true
        - name: sys
          mountPath: /sys
          readOnly: true
        - name: docker
          mountPath: /var/lib/docker
          readOnly: true
        - name: disk
          mountPath: /dev/disk
          readOnly: true
        ports:
          - name: http
            containerPort: 8080
            hostPort: 8090
            protocol: TCP
      automountServiceAccountToken: false
      terminationGracePeriodSeconds: 30
      volumes:
      - name: rootfs
        hostPath:
          path: /
      - name: var-run
        hostPath:
          path: /var/run
      - name: sys
        hostPath:
          path: /sys
      - name: docker
        hostPath:
          path: /var/lib/docker
      - name: disk
        hostPath:
          path: /dev/disk

  

kustomize base/kustomization.yaml | kubectl apply -f -

 

prom监控参数  

https://github.com/google/cadvisor/blob/master/docs/storage/prometheus.md

 

4 blackbox

 

5 prom

 

posted @ 2020-07-24 10:32  jabbok  阅读(549)  评论(0编辑  收藏  举报