K8S 클러스터 설치 프로 메테우스에서

이전 버전의는 Kubernetes는 heapster이 influxDB는 모니터링 시스템에 결합 grafana는 이제 더 많은 인기를 모니터링 도구는 프로 메테우스 있으며, 프로 메테우스 구글 내부 감시 경보 시스템은 오픈 소스 버전 제공

기존의 다른 모니터링 도구에 비해 프로 메테우스는 주로 다음과 같은 특징이 있습니다 :
일련의 데이터가 확인 된 다차원 데이터 모델 시간 메트릭 이름과 키 / 값 쌍가
유연한 쿼리 언어는
분산 스토리지에 의존하지 않습니다, 단지 로컬 디스크에 대한
시계열 데이터가 당겨 HTTP 서비스
또한 시계열 데이터를 추가 할 푸시 방식으로 지원
대상을 찾을 또한 정적 구성 또는 서비스 검색을 통해를 지원하는
그래픽 및 지원 대시 보드의 다양한

프로 메테우스는 여러 구성 요소로 구성하지만, 많은 구성 요소는 선택 사항입니다 :
프로 메테우스 서버 : 파지 지수 시계열 데이터의 저장
수출 : 그래서 노출 레벨 작업 캐치를
pushgateway : 푸시 방식은 인덱스 데이터 게이트웨이 밀어
alertmanager을 : 프로세스 경고 알림 구성 요소
애드혹 : 데이터 쿼리

1, 별도의 네임 스페이스를 만들

apiVersion: v1
kind: Namespace
metadata:
  name: kube-ops

도 2를 참조하면, 관리 정보는 ConfigMap 형의 형태 prometheus.yml

apiVersion: v1
kind: ConfigMap
metadata:
  name: prometheus-config
  namespace: kube-ops
data:
  prometheus.yml: |
    global:
      scrape_interval: 15s
      scrape_timeout: 15s
    scrape_configs:
    - job_name: 'prometheus'
      static_configs:
      - targets: ['localhost:9090']

Prometheus.yml 프로파일은 세 가지 모듈을 포함 글로벌 scrape_configs을 rule_files과
상기 전역 제어 글로벌 메테우스 서버 모듈 구성
rule_files 위치 규칙 모듈 여기서 개발이 구성에있어서, 새로운 시간 시리즈를 생성 메테우스로드 규칙 데이터 또는 경보 정보는, 현재 우리는 어떤 규칙 구성 할 필요가 없습니다
어떤 자원 프로 메테우스 모니터를 제어하는 데 사용 scrape_configs을.
시계열 데이터 프로 메테우스 서비스 자체를 수집,이 프로 메테우스라고 단일 작업에서 기본 구성에있다. 이 작업은 하나의 정적 목표 설정을 포함 : 로컬 호스트의 포트 9090에서 수신 대기.
/ 측정 경로 목표에 의해 수집 된 프로 메테우스 기본 통계. : 그래서,에 의해 그 일을의 URL 기본 HTTP를 : // localhost를 : 9090 / 통계 수집 통계를.
3, 구성 인증 RBAC

apiVersion: v1
kind: ServiceAccount
metadata:
  name: prometheus
  namespace: kube-ops
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: prometheus
rules:
- apiGroups:
  - ""
  resources:
  - nodes
  - services
  - endpoints
  - pods
  - nodes/proxy
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - ""
  resources:
  - configmaps
  - nodes/metrics
  verbs:
  - get
- nonResourceURLs:
  - /metrics
  verbs:
  - get
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: prometheus
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: prometheus
subjects:
- kind: ServiceAccount
  name: prometheus
  namespace: kube-ops

태양 광 PVC 지속성 4 구성 데이터

apiVersion: v1
kind: PersistentVolume
metadata:
  name: prometheus
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Recycle
  nfs:
    server: 192.168.1.244
    path: /data/k8s

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: prometheus
  namespace: kube-ops
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

5, 프로 메테우스에게 포드 자원 생성
$ 고정 표시기의 풀 파티 / 프로 메테우스를 : V2.4.3을

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: prometheus
  namespace: kube-ops
  labels:
    app: prometheus
spec:
  template:
    metadata:
      labels:
        app: prometheus
    spec:
      serviceAccountName: prometheus
      containers:
      - image: prom/prometheus:v2.4.3
        name: prometheus
        command:
        - "/bin/prometheus"
        args:
        - "--config.file=/etc/prometheus/prometheus.yml"
        - "--storage.tsdb.path=/prometheus"
        - "--storage.tsdb.retention=24h"
        - "--web.enable-admin-api"  # 控制对admin HTTP API的访问,其中包括删除时间序列等功能
        - "--web.enable-lifecycle"  # 支持热更新,直接执行localhost:9090/-/reload立即生效
        ports:
        - containerPort: 9090
          protocol: TCP
          name: http
        volumeMounts:
        - mountPath: "/prometheus"
          subPath: prometheus
          name: data
        - mountPath: "/etc/prometheus"
          name: config-volume
        resources:
          requests:
            cpu: 100m
            memory: 512Mi
          limits:
            cpu: 100m
            memory: 512Mi
      securityContext:
        runAsUser: 0
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: prometheus
      - configMap:
          name: prometheus-config
        name: config-volume

POD -n KUBE kubectl GET $ -OPS
프로 메테우스 - 77d968648-w5j6z 1/1 (53) 82D 실행
(6)의 SVC의 프로 메테우스 포드를 만들

apiVersion: v1
kind: Service
metadata:
  name: prometheus
  namespace: kube-ops
  labels:
    app: prometheus
spec:
  selector:
    app: prometheus
  type: NodePort
  ports:
    - name: web
      port: 9090
      targetPort: http

SVC -n KUBE kubectl GET $ -OPS
프로 메테우스 NodePort 10.102.197.83 <없음> 9090 : 32619 / TCP
http://192.168.1.243:32619는
디렉토리 상태 모니터링 상태 ---- 목표를 보려면 클릭하지

추천

출처blog.51cto.com/dongdong/2432228