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. 笔记:Python的浅复制和深复制

    方法copy返回一个新字典,其包含的键-值对与原来的字典相同(这个方法执行的是浅复制,因为值本身是原件,而不是副本). >>> x = {"username": ...

  2. 【学术篇】51nod 1238 最小公倍数之和

    这是一道杜教筛的入(du)门(liu)题目... 题目大意 求 \[ \sum_{i=1}^n\sum_{j=1}^nlcm(i,j) \] 一看就是辣鸡反演一类的题目, 那就化式子呗.. \[ \s ...

  3. leetcood学习笔记-226- 翻转二叉树

    题目描述: 第一次提交: class Solution(object): def invertTree(self, root): """ :type root: Tree ...

  4. Typora使用入门

    使用sublime编写markdown语法不太方便,使用专门的markdown编辑软件会更方便一些! 1.typora常用快捷键 ctrl + /     切换编辑语法模式/预览模式 ctrl + 1 ...

  5. thinkphp 应用模式

    应用模式提供了对核心框架进行改造的机会,可以让你的应用适应更多的环境和不同的要求. 每个应用模式有自己的模式定义文件,用于配置当前模式需要加载的核心文件和配置文件,以及别名定义.行为扩展定义等等.根据 ...

  6. NX二次开发-UFUN获取当前所在的模块UF_ask_application_module

    NX9+VS2012 #include <uf.h> #include <NXOpen/UI.hxx> #include <NXOpen/MenuBar_MenuBarM ...

  7. [zz]winform 窗体关闭事件

    注册窗体关闭事件: 在Form1.Designer.cs 文件中添加: this.FormClosing += new System.Windows.Forms.FormClosingEventHan ...

  8. Firefox Developer Edition 是专为开发者设计

    Firefox Developer Edition 当前是基于 Firefox 35.0a2,这款全新的浏览器包括内建调试功能,集成类似于Firefox火狐工具适配器的专用工具,并在浏览器当中内建We ...

  9. 使用Pyppeteer进行gmail模拟登录

    import asyncio import time from pyppeteer import launch async def gmailLogin(username, password, url ...

  10. Python3中string内置参数

    说明: 使用ipython查看python3的内置函数 ,只需要输入字符串按两下tab键 capitalize():将字符串中第一个字符大写 casefold:将字符串中的所有大写字母转为小写 cen ...