依赖于kubenets dns服务

图形化展示度量指标的实现需要集成k8s的另外一个Addons组件: Heapster 。
Heapster原生支持K8s(v1.0.6及以后版本)和 CoreOS ,并且支持多种存储后端,比如: InfluxDB 、 ElasticSearch 、 Kafka 。

镜像地址:

index.tenxcloud.com/jimmy/heapster-amd64:v1.3.0-beta.1
index.tenxcloud.com/jimmy/heapster-influxdb-amd64:v1.1.1
index.tenxcloud.com/jimmy/heapster-grafana-amd64:v4.0.2

安装Heapster

heapster-deployment.yaml

[root@k8s_master ui]# cat heapster-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: heapster
  namespace: kube-system
spec:
  replicas: 1
  template:
    metadata:
      labels:
        task: monitoring
        k8s-app: heapster
    spec:
      containers:
      - name: heapster
        image: index.tenxcloud.com/jimmy/heapster-amd64:v1.3.0-beta.1
        imagePullPolicy: IfNotPresent
        command:
        - /heapster
        - --source=kubernetes:http://192.168.132.148:8080?inClusterConfig=false
        - --sink=influxdb:http://monitoring-influxdb:8086

注意:修改- --source为自己的master apiserver访问地址 ,修改image地址(上面已经提供)

heapster-service.yaml

[root@k8s_master ui]# cat heapster-service.yaml
apiVersion: v1
kind: Service
metadata:
  labels:
    task: monitoring
    # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)
    # If you are NOT using this as an addon, you should comment out this line.
    kubernetes.io/cluster-service: 'true'
    kubernetes.io/name: Heapster
  name: heapster
  namespace: kube-system
spec:
  ports:
  - port: 80
    targetPort: 8082
  selector:
    k8s-app: heapster

创建deployment和service

#kubectl create -f heapster-deployment.yaml
#kubectl create -f heapster-service.yaml

配置Influxdb

influxdb 官方建议使用命令行或 HTTP API 接口来查询数据库,从 v1.1.0 版本开始默认关闭 admin UI,将在后续版本中移除 admin UI 插件。
开启镜像中 admin UI的办法如下:先导出镜像中的 influxdb 配置文件,开启插件后,再将配置文件内容写入 ConfigMap,最后挂载到镜像中,达到覆盖原始配置的目的。

$ #在镜像所在的宿主机上,导出镜像中的influxdb配置文件
$ docker run --rm --entrypoint 'cat' -ti heapster-influxdb-amd64:v1.1.1 /etc/config.toml >config.toml.orig
$ cp config.toml.orig config.toml
$ # 修改:启用 admin 接口
$ vim config.toml
修改第35行
< enabled = false
---
> enabled = true

$ #将修改后的config.toml拷贝到Master上,再将修改后的配置写入到ConfigMap对象中

$ kubectl create configmap influxdb-config --from-file=config.toml -n kube-system

$ # 将ConfigMap中的配置文件挂载到Pod中,达到覆盖原始配置的目的

influxdb-deployment.yaml文件

[root@k8s_master ui]# cat influxdb-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: monitoring-influxdb
  namespace: kube-system
spec:
  replicas: 1
  template:
    metadata:
      labels:
        task: monitoring
        k8s-app: influxdb
    spec:
      containers:
      - name: influxdb
        image: index.tenxcloud.com/jimmy/heapster-influxdb-amd64:v1.1.1
        volumeMounts:
        - mountPath: /data
          name: influxdb-storage
        - mountPath: /etc/
          name: influxdb-config
      volumes:
      - name: influxdb-config
        configMap:
          name: influxdb-config
      - name: influxdb-storage
        emptyDir: {}

influxdb-service.yaml

[root@k8s_master ui]# cat influxdb-service.yaml
apiVersion: v1
kind: Service
metadata:
  labels:
    task: monitoring
    # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)
    # If you are NOT using this as an addon, you should comment out this line.
    kubernetes.io/cluster-service: 'true'
    kubernetes.io/name: monitoring-influxdb
  name: monitoring-influxdb
  namespace: kube-system
spec:
  type: NodePort
  ports:
  - port: 8086
    targetPort: 8086
    name: http
  - port: 8083
    targetPort: 8083
    name: api
  selector:
    k8s-app: influxdb

创建deployment和service

#kubectl create -f influxdb-deployment.yaml
#kubectl create -f influxdb-service.yaml

安装grafana

grafana-deployment.yaml

[root@k8s_master ui]# cat grafana-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: monitoring-grafana
  namespace: kube-system
spec:
  replicas: 1
  template:
    metadata:
      labels:
        task: monitoring
        k8s-app: grafana
    spec:
      containers:
      - name: grafana
        image: index.tenxcloud.com/jimmy/heapster-grafana-amd64:v4.0.2
        ports:
          - containerPort: 3000
            protocol: TCP
        volumeMounts:
        - mountPath: /var
          name: grafana-storage
        env:
        - name: INFLUXDB_HOST
          value: monitoring-influxdb
        - name: GRAFANA_PORT
          value: "
          # The following env variables are required to make Grafana accessible via
          # the kubernetes api-server proxy. On production clusters, we recommend
          # removing these env variables, setup auth for grafana, and expose the grafana
          # service using a LoadBalancer or a public IP.
        - name: GF_AUTH_BASIC_ENABLED
          value: "false"
        - name: GF_AUTH_ANONYMOUS_ENABLED
          value: "true"
        - name: GF_AUTH_ANONYMOUS_ORG_ROLE
          value: Admin
        - name: GF_SERVER_ROOT_URL
          # If you're only using the API Server proxy, set this value instead:
          value: /api/v1/proxy/namespaces/kube-system/services/monitoring-grafana/
          #value: /
      volumes:
      - name: grafana-storage
        emptyDir: {}

grafana-service.yaml

[root@k8s_master ui]# cat grafana-service.yaml
apiVersion: v1
kind: Service
metadata:
  labels:
    # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)
    # If you are NOT using this as an addon, you should comment out this line.
    kubernetes.io/cluster-service: 'true'
    kubernetes.io/name: monitoring-grafana
  name: monitoring-grafana
  namespace: kube-system
spec:
  # In a production setup, we recommend accessing Grafana through an external Loadbalancer
  # or through a public IP.
  # type: LoadBalancer
  # You could also use NodePort to expose the service at a randomly-generated port
  # type: NodePort
  ports:
  - port: 80
    targetPort: 3000
  selector:
    k8s-app: grafana

创建deployment和service

#kubectl create -f grafana-deployment.yaml
#kubectl create -f grafana-service.yaml

获取所有pod

[root@k8s_master ui]#  kubectl get pod -n kube-system
NAME                                           READY     STATUS    RESTARTS   AGE
heapster-3275159538-fdvhf                      1/1       Running   0          5s
kubernetes-dashboard-latest-1381663337-0wwml   1/1       Running   1          19h
monitoring-grafana-2812960871-gbsdf            1/1       Running   1          16h
monitoring-influxdb-1975863524-nmbpk           1/1       Running   1          16h

打印日志

[root@k8s_master ui]# kubectl logs -f pods/heapster-3275159538-fdvhf -n kube-system

如果没有配置dns,Influxdb会报如下错误

访问验证:

http://192.168.132.148:8080/ui

 验证Influxdb

8086端口对应31878
访问:
http://192.168.132.148:8080/api/v1/proxy/namespaces/kube-system/services/monitoring-influxdb:8083/

这里的ip为部署influxdb的主机

查看状态

直接回车

通过 kube-apiserver 的非安全端口访问 influxdb 的 admin UI 界面:

[root@k8s_master ~]# kubectl cluster-info

注:这些地址均可在以上的deployment.yaml 里设置

grafan地址:

http://192.168.132.148:8080/api/v1/proxy/namespaces/kube-system/services/monitoring-grafana/dashboard/db/cluster

配置信息

建立Heapster Influxdb Grafana集群性能监控平台的更多相关文章

  1. cAdvisor0.24.1+InfluxDB0.13+Grafana4.0.2搭建Docker1.12.3 Swarm集群性能监控平台

    目录 [TOC] 1.基本概念 ​ 既然是对Docker的容器进行监控,我们就不自己单独搭建cAdvisor.InfluxDB.Grarana了,本文中这三个实例,主要以Docker容器方式运行. 本 ...

  2. 高可用Kubernetes集群-14. 部署Kubernetes集群性能监控平台

    参考文档: Github介绍:https://github.com/kubernetes/heapster Github yaml文件: https://github.com/kubernetes/h ...

  3. 搭建jmeter+influxdb+grafana压测实时监控平台(超详细,小白适用)

    1.前言 在使用jmeter做性能测试的时候,监控系统性能的时候,无论是使用插件还是报告生成,都没法实现实时监控.使用JMeter+Influxdb+Grafana可以实现实时监控. 本次环境搭建各软 ...

  4. .NET Core微服务之基于App.Metrics+InfluxDB+Grafana实现统一性能监控

    Tip: 此篇已加入.NET Core微服务基础系列文章索引 一.关于App.Metrics+InfluxDB+Grafana 1.1 App.Metrics App.Metrics是一款开源的支持. ...

  5. Linux服务器集群性能监控之Performance Co-Pilot(PCP)部署

    转载自:https://blog.csdn.net/w84268426/article/details/78431778 在部署PCP时,我用到了两台cent os 7虚拟机. 1.官方安装文档htt ...

  6. 详解k8s原生的集群监控方案(Heapster+InfluxDB+Grafana) - kubernetes

    1.浅析监控方案 heapster是一个监控计算.存储.网络等集群资源的工具,以k8s内置的cAdvisor作为数据源收集集群信息,并汇总出有价值的性能数据(Metrics):cpu.内存.netwo ...

  7. kubernetes 监控方案之:heapster+influxdb+grafana(十八)

    目录 一.Heapster 介绍 二.部署 三.使用 heapster 已经 deprecated 了:https://github.com/kubernetes/heapster,所以下面的演示主要 ...

  8. Docker系列——InfluxDB+Grafana+Jmeter性能监控平台搭建(一)

    在做性能测试的时候,重点关注点是各项性能指标,用Jmeter工具,查看指标数据,就是借助于聚合报告,但查看时也并不方便.那如何能更直观的查看各项数据呢?可以通过InfluxDB+Grafana+Jme ...

  9. Docker系列——InfluxDB+Grafana+Jmeter性能监控平台搭建(二)

    在上一篇博文中,主要是讲了InfluxDB的配置,博文链接:https://www.cnblogs.com/hong-fithing/p/14453695.html,今天来分享下Jmeter的配置. ...

随机推荐

  1. BZOJ3165[Heoi2013]Segment——李超线段树

    题目描述 要求在平面直角坐标系下维护两个操作: 1.在平面上加入一条线段.记第i条被插入的线段的标号为i. 2.给定一个数k,询问与直线 x = k相交的线段中,交点最靠上的线段的编号. 输入 第一行 ...

  2. POJ 1125-Stockbroker Grapevine-最短路

    裸最短路 /*--------------------------------------------------------------------------------------*/ // H ...

  3. 区间DP,数位DP

    dp(动态规划)顾名思义便是动态的一种规划,而这种规划往往会跟状态,状态转移方程,记忆化搜索扯上关系,当然DP也是各个OI考试的必考点和常考点,在毒瘤出题人的折磨下,出现了许许多多的动态规划,有线性, ...

  4. Marriage Match III HDU - 3277(二分权值 + 拆点 建边)

    题意: 只不过是hdu3081多加了k种选择 想一下,最多能玩x轮,是不是就是每个女生能最多选x个男生 现在题中的每个女生比3081多了k中选择   那就把女生拆点  i  i‘ i --> i ...

  5. 【BZOJ3999】【TJOI2015】旅游 树剖

    题目大意 给你一棵树,有\(n\)个点.有\(q\)个操作,每次要你从\(x\)到\(y\)的路径上选两个点,使得距离\(x\)比较远的点的点权\(-\)距离\(x\)比较近的点的点权最大,然后把这条 ...

  6. MT【287】余弦的线性组合

    (2017北大特优)在$\Delta ABC$中,$cos A+\sqrt{2}cos B+\sqrt{2}cos C$的最大值____ 解答 :2$cos A+\sqrt{2}cos B+\sqrt ...

  7. AES解密后多了\0

    AES加密解密之后发现多了几个空格,不知道原因.在调试时发现多了\0这种东西 不知道为什么会多这些.后来.replace("\0","")这样做了事

  8. [CQOI2017]老C的方块

    题目描述 https://www.lydsy.com/JudgeOnline/problem.php?id=4823 题解 观察那四种条件 有没有什么特点? 我们可以把蓝线两边的部分看做两个区域,这样 ...

  9. [Vani有约会]雨天的尾巴(树上差分+线段树合并)

    首先村落里的一共有n座房屋,并形成一个树状结构.然后救济粮分m次发放,每次选择两个房屋(x,y),然后对于x到y的路径上(含x和y)每座房子里发放一袋z类型的救济粮. 然后深绘里想知道,当所有的救济粮 ...

  10. 洛谷4451 整数的lqp拆分(生成函数)

    比较水的一题.居然是一道没看题解就会做的黑题…… 题目链接:洛谷 题目大意:定义一个长度为 $m$ 的正整数序列 $a$ 的价值为 $\prod f_{a_i}$.($f$ 是斐波那契数)对于每一个 ...