1.部署heapster

下载 heapster 相关 yaml 文件

[root@master dashboard]# wget https://raw.githubusercontent.com/kubernetes-retired/heapster/master/deploy/kube-config/influxdb/grafana.yaml
[root@master dashboard]# wget https://raw.githubusercontent.com/kubernetes-retired/heapster/master/deploy/kube-config/influxdb/influxdb.yaml
[root@master dashboard]# wget https://raw.githubusercontent.com/kubernetes-retired/heapster/master/deploy/kube-config/influxdb/heapster.yaml
[root@master dashboard]# wget https://raw.githubusercontent.com/kubernetes-retired/heapster/master/deploy/kube-config/rbac/heapster-rbac.yaml
[root@master dashboard]# cat heapster.yaml | grep image
image: k8s.gcr.io/heapster-amd64:v1.5.4
imagePullPolicy: IfNotPresent
[root@master dashboard]# cat grafana.yaml | grep image
image: k8s.gcr.io/heapster-grafana-amd64:v5.0.4
[root@master dashboard]# cat influxdb.yaml | grep image
image: k8s.gcr.io/heapster-influxdb-amd64:v1.5.2

1.1在node上pull和tag被墙的镜像

[root@master dashboard]# docker pull mirrorgooglecontainers/heapster-amd64:v1.5.4
[root@master dashboard]# docker pull mirrorgooglecontainers/heapster-grafana-amd64:v5.0.4
[root@master dashboard]# docker pull mirrorgooglecontainers/heapster-influxdb-amd64:v1.5.2 [root@master dashboard]# docker tag mirrorgooglecontainers/heapster-amd64:v1.5.4 k8s.gcr.io/heapster-amd64:v1.5.4
[root@master dashboard]# docker tag mirrorgooglecontainers/heapster-grafana-amd64:v5.0.4 k8s.gcr.io/heapster-grafana-amd64:v5.0.4
[root@master dashboard]# docker tag mirrorgooglecontainers/heapster-influxdb-amd64:v1.5.2 k8s.gcr.io/heapster-influxdb-amd64:v1.5.2
[root@master dashboard]# ls heapster/
grafana.yaml heapster-rbac.yaml heapster.yaml influxdb.yaml
[root@master dashboard]# kubectl apply -f ./heapster/
deployment.extensions/monitoring-grafana created
service/monitoring-grafana created
clusterrolebinding.rbac.authorization.k8s.io/heapster created
serviceaccount/heapster created
deployment.extensions/heapster created
service/heapster created
deployment.extensions/monitoring-influxdb created
service/monitoring-influxdb created
[root@master dashboard]# kubectl get pods -n kube-system -owide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
coredns-fb8b8dccf-bh4t2 / Running 14d 10.244.0.3 master <none> <none>
coredns-fb8b8dccf-rxkjw / Running 14d 10.244.0.2 master <none> <none>
etcd-master / Running 14d 10.0.1.195 master <none> <none>
heapster-5d4bf58946-bfvcz / Running 13m 10.244.2.28 node01 <none> <none>
kube-apiserver-master / Running 14d 10.0.1.195 master <none> <none>
kube-controller-manager-master / Running 14d 10.0.1.195 master <none> <none>
kube-flannel-ds-amd64- / Running 14d 10.0.1.229 node01 <none> <none>
kube-flannel-ds-amd64-nhvm5 / Running 14d 10.0.1.7 node02 <none> <none>
kube-flannel-ds-amd64-xwng8 / Running 14d 10.0.1.195 master <none> <none>
kube-proxy-2mk2h / Running 14d 10.0.1.195 master <none> <none>
kube-proxy-54x8x / Running 14d 10.0.1.7 node02 <none> <none>
kube-proxy-n9rdx / Running 14d 10.0.1.229 node01 <none> <none>
kube-scheduler-master / Running 14d 10.0.1.195 master <none> <none>
kubernetes-dashboard-769b74d4b4-kk6zx / Running 38m 10.244.2.27 node01 <none> <none>
monitoring-grafana-658976d65f-xgp6v / Running 13m 10.244.1.18 node02 <none> <none>
monitoring-influxdb-866db5f944-8tq74 / Running 13m 10.244.1.19 node02 <none> <none>
tiller-deploy-58f5d95b9c-x492l / Running 13d 10.244.2.3 node01 <none> <none>
traefik-ingress-controller-f9bg6 / Running 73m 10.244.1.16 node02 <none> <none>
traefik-ingress-controller-x6tjl / Running 73m 10.244.2.26 node01 <none> <none>
[root@master dashboard]# kubectl logs heapster-5d4bf58946-bfvcz -n kube-system
E0614 ::05.004107 manager.go:] Error in scraping containers from kubelet:10.0.1.195:: failed to get all container stats from Kubelet URL "http://10.0.1.195:10255/stats/container/": Post http://10.0.1.195:10255/stats/container/: dial tcp 10.0.1.195:10255: getsockopt: connection refused
W0614 ::25.000648 manager.go:] Failed to get all responses in time (got /)
E0614 ::05.022570 manager.go:] Error in scraping containers from kubelet:10.0.1.229:: failed to get all container stats from Kubelet URL "http://10.0.1.229:10255/stats/container/": Post http://10.0.1.229:10255/stats/container/: dial tcp 10.0.1.229:10255: getsockopt: connection refused
W0614 ::25.000593 manager.go:] Failed to get all responses in time (got /)

//上面还有报错

1.2修改heapster.yaml 文件

#### 修改如下部分 #####
因为 kubelet 启用了 https 所以如下配置需要增加 https 端口
- --source=kubernetes:https://kubernetes.default
修改为
- --source=kubernetes:https://kubernetes.default?kubeletHttps=true&kubeletPort=10250&insecure=true

1.3修改heapster-rbac.yaml文件

#### 修改为部分 #####
将 serviceAccount kube-system:heapster 与 ClusterRole system:kubelet-api-admin 绑定,授予它调用 kubelet API 的权限;
[root@master heapster]# cat heapster-rbac.yaml
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: heapster
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:heapster
subjects:
- kind: ServiceAccount
name: heapster
namespace: kube-system
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: heapster-kubelet-api
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:kubelet-api-admin
subjects:
- kind: ServiceAccount
name: heapster
namespace: kube-system

2创建应用

[root@master heapster]# kubectl apply -f ./
[root@master heapster]# kubectl logs heapster-5d9575b66b-t5zxt -n kube-system
I0614 ::09.353325 heapster.go:] /heapster --source=kubernetes:https://kubernetes.default?kubeletHttps=true&kubeletPort=10250&insecure=true --sink=influxdb:http://monitoring-influxdb.kube-system.svc:8086
I0614 ::09.353365 heapster.go:] Heapster version v1.5.4
I0614 ::09.353623 configs.go:] Using Kubernetes client with master "https://kubernetes.default" and version v1
I0614 ::09.353648 configs.go:] Using kubelet port
I0614 ::09.367340 influxdb.go:] created influxdb sink with options: host:monitoring-influxdb.kube-system.svc: user:root db:k8s
I0614 ::09.367368 heapster.go:] Starting with InfluxDB Sink
I0614 ::09.367374 heapster.go:] Starting with Metric Sink
I0614 ::09.375501 heapster.go:] Starting heapster on port
I0614 ::05.067815 influxdb.go:] Created database "k8s" on influxDB server at "monitoring-influxdb.kube-system.svc:8086"

3.查看监控节点

[root@master heapster]# kubectl top nodes
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
master 112m % 2464Mi %
node01 59m % 4356Mi %
node02 47m % 1644Mi %

4.访问

可以从kuberbetes-dashboard访问https://www.cnblogs.com/linyouyi/p/11001213.html

也可以把上面的应用单独暴露NodePort然后通过NodeIP:NodePort访问

更加详细玩转https://www.cnblogs.com/scode2/p/8810052.html

grafana.yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: monitoring-grafana
namespace: kube-system
spec:
replicas:
template:
metadata:
labels:
task: monitoring
k8s-app: grafana
spec:
containers:
- name: grafana
image: k8s.gcr.io/heapster-grafana-amd64:v5.0.4
ports:
- containerPort:
protocol: TCP
volumeMounts:
- mountPath: /etc/ssl/certs
name: ca-certificates
readOnly: true
- mountPath: /var
name: grafana-storage
env:
- name: INFLUXDB_HOST
value: monitoring-influxdb
- name: GF_SERVER_HTTP_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/namespaces/kube-system/services/monitoring-grafana/proxy
value: /
volumes:
- name: ca-certificates
hostPath:
path: /etc/ssl/certs
- name: grafana-storage
emptyDir: {}
---
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:
targetPort:
selector:
k8s-app: grafana

heapster-rbac.yaml

kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: heapster
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:heapster
subjects:
- kind: ServiceAccount
name: heapster
namespace: kube-system
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: heapster-kubelet-api
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:kubelet-api-admin
subjects:
- kind: ServiceAccount
name: heapster
namespace: kube-system

heapster.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
name: heapster
namespace: kube-system
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: heapster
namespace: kube-system
spec:
replicas:
template:
metadata:
labels:
task: monitoring
k8s-app: heapster
spec:
serviceAccountName: heapster
containers:
- name: heapster
image: k8s.gcr.io/heapster-amd64:v1.5.4
imagePullPolicy: IfNotPresent
command:
- /heapster
- --source=kubernetes:https://kubernetes.default?kubeletHttps=true&kubeletPort=10250&insecure=true
- --sink=influxdb:http://monitoring-influxdb.kube-system.svc:8086
---
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:
targetPort:
selector:
k8s-app: heapster

influxdb.yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: monitoring-influxdb
namespace: kube-system
spec:
replicas:
template:
metadata:
labels:
task: monitoring
k8s-app: influxdb
spec:
containers:
- name: influxdb
image: k8s.gcr.io/heapster-influxdb-amd64:v1.5.2
volumeMounts:
- mountPath: /data
name: influxdb-storage
volumes:
- name: influxdb-storage
emptyDir: {}
---
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:
ports:
- port:
targetPort:
selector:
k8s-app: influxdb

kubernetes监控和性能分析工具:heapster+influxdb+grafana的更多相关文章

  1. MySQL监控、性能分析——工具篇

    https://blog.csdn.net/leamonjxl/article/details/6431444 MySQL越来越被更多企业接受,随着企业发展,MySQL存储数据日益膨胀,MySQL的性 ...

  2. MySQL监控、性能分析——工具篇(转载)

    MySQL越来越被更多企业接受,随着企业发展,MySQL存储数据日益膨胀,MySQL的性能分析.监控预警.容量扩展议题越来越多.“工欲善其事,必先利其器”,那么我们如何在进行MySQL性能分析.监控预 ...

  3. java面试-JDK自带的JVM 监控和性能分析工具用过哪些?

    一.JDK的命令行工具 1.jps(JVM Process Status Tools):虚拟机进程状况工具 jps -l 2.jinfo(Configuration Info for java):Ja ...

  4. kubectl-trace 基于bpftrace 的kubernetes 集群性能分析工具

    kubectl-trace 是一个kubectl 的插件,我们可以使用基于bpftrace 的编程能力,来分析系统的性能问题, 强大,灵活,后边安装试用下 参考架构 参考资料 https://gith ...

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

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

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

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

  7. Java 性能分析工具 , 第 3 部分: Java Mission Control

    引言 本文为 Java 性能分析工具系列文章第三篇,这里将介绍如何使用 Java 任务控制器 Java Mission Control 深入分析 Java 应用程序的性能,为程序开发人员在使用 Jav ...

  8. Java 性能分析工具 , 第 2 部分:Java 内置监控工具

    引言 本文为 Java 性能分析工具系列文章第二篇,第一篇:操作系统工具.在本文中将介绍如何使用 Java 内置监控工具更加深入的了解 Java 应用程序和 JVM 本身.在 JDK 中有许多内置的工 ...

  9. Java 性能分析工具 , 第 1 部分: 操作系统工具

    引言 性能分析的前提是将应用程序内部的运行状况以及应用运行环境的状况以一种可视化的方式更加直接的展现出来,如何来达到这种可视化的展示呢?我们需要配合使用操作系统中集成的程序监控工具和 Java 中内置 ...

随机推荐

  1. 《代码大全2》读书笔记 Week3

    <代码大全2>第六.七章 作者在第六章中从抽象数据类型(Abstract Data Type)出发阐释类(class)的概念,给出创建类的原因以及创建高质量的常涉及的设计问题.抽象数据类型 ...

  2. 并发编程 --进、线程池、协程、IO模型

    内容目录: 1.socket服务端实现并发 2.进程池,线程池 3.协程 4.IO模型 1.socket服务端实现并发 # 客户端: import socket client = socket.soc ...

  3. 记录一次工作中jvm被linux杀死的调查

    首先,以后碰到任何jvm的错误,先看日志!!!!!!!! web项目在tomcat目录下的log里,或者自己设定的errorfile目录下.总之,找到一切可以运用的日志,比如crash日志,cored ...

  4. docker commit为什么不适合生成镜像?

    要知道,当我们运行一个容器的时候(如果不使用卷的话),我们做的任何文件修改都会被记录与容器存储层里.而Docker提供了一个docker commit 的命令,可以将容器的存储层保存下来成为镜像.换句 ...

  5. 了解GTIN小记

    GTIN为条形码,即"全球贸易项目代码"(Global Trade Item Number ) GTIN用作识别商品品项的全球性独一编码,是编码系统中应用最广泛的标识代码. GTI ...

  6. ES6-let cont 关键字

    ***let1. 作用: * 与var类似, 用于声明一个变量2. 特点: * 在块作用域内有效 * 不能重复声明 * 不会预处理, 不存在提升3. 应用: * 循环遍历加监听 * 使用let取代va ...

  7. hive的行列互转

    行转列 多行转多列 数据表 row2col col1 col2 col3 a c 1 a d 2 a e 3 b c 4 b d 5 b e 6 现在要将其转化为: col1 c d e a 1 2 ...

  8. NX二次开发-UFUN添加工程图投影视图UF_DRAW_add_orthographic_view

    NX9+VS2012 #include <uf.h> #include <uf_draw.h> #include <uf_obj.h> #include <u ...

  9. NX二次开发-NXOPEN设置工程图表格注释字体workPart->Fonts()->AddFont("chinesef_fs", NXOpen::FontCollection::TypeNx);

    NX9+VS2012 #include <uf.h> #include <uf_tabnot.h> #include <NXOpen/Part.hxx> #incl ...

  10. Linux命令(1):date

    查看时间: date "+%Y-%m-%d %H:%M:%S" 参数说明: %n : 下一行 %t : 跳格 %H : 小时(00..23) %I : 小时(01..12) %k ...