Heapster是容器集群监控和性能分析工具,天然的支持Kubernetes和CoreOS

heapster监控目前官网已经不更新,部署学习使用

heapster: 收集监控数据

influxdb:数据库,存储数据

grafana:web页面展示

1、heapster安装包下载

地址:https://github.com/kubernetes-retired/heapster/releases

把对应的tar包下载

解压包,在路径:heapster-1.5.4\heapster-1.5.4\deploy\kube-config\rbac下找到heapster-rbac.yaml
在路径heapster-1.5.4\heapster-1.5.4\deploy\kube-config\influxdb下找到grafana.yaml,heapster.yaml,influxdb.yaml

2、部署influxdb

新版本k8sapi变动,修改Deployment  apiVersion为apiVersion: apps/v1

镜像修改为国内镜像源:image: registry.aliyuncs.com/google_containers/heapster-influxdb-amd64:v1.5.2

增加selector选择器

[root@k8s-master1 test2]# cat influxdb.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: monitoring-influxdb
namespace: kube-system
spec:
replicas: 1
selector:
matchLabels:
task: monitoring
k8s-app: influxdb
template:
metadata:
labels:
task: monitoring
k8s-app: influxdb
spec:
containers:
- name: influxdb
image: registry.aliyuncs.com/google_containers/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: 8086
targetPort: 8086
selector:
k8s-app: influxdb 部署influxdb:
# kubectl apply -f influxdb.yaml

3、部署heapster

新版本k8sapi变动,修改Deployment  apiVersion为apiVersion: apps/v1

镜像修改为国内镜像源:image: registry.aliyuncs.com/google_containers/heapster-amd64:v1.5.4

增加selector选择器

source参数修改为:- --source=kubernetes:https://kubernetes.default?kubeletHttps=true&kubeletPort=10250&insecure=true

不修改会提示报错,kubectl  logs可以查询到对应报错信息

[root@k8s-master1 test2]# cat heapster.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: heapster
namespace: kube-system
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: heapster
namespace: kube-system
spec:
replicas: 1
selector:
matchLabels:
task: monitoring
k8s-app: heapster
template:
metadata:
labels:
task: monitoring
k8s-app: heapster
spec:
serviceAccountName: heapster
containers:
- name: heapster
image: registry.aliyuncs.com/google_containers/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: 80
targetPort: 8082
selector:
k8s-app: heapster

用户权限,默认的没有create权限
# kubectl apply -f heapster-rbac.yaml

重新导出yaml文件,修改rule角色权限

# kubectl get ClusterRole system:heapster -o yaml > heapster_modify.yaml

# kubectl apply -f  heapster_modify.yaml

部署heapster
#kubectl apply -f heapster.yaml

查询角色权限,verbs中有了create权限
[root@k8s-master1 test2]# kubectl describe ClusterRole system:heapster
Name: system:heapster
Labels: kubernetes.io/bootstrapping=rbac-defaults
Annotations: rbac.authorization.kubernetes.io/autoupdate: true
PolicyRule:
Resources Non-Resource URLs Resource Names Verbs
--------- ----------------- -------------- -----
events [] [] [create get list watch]
namespaces [] [] [create get list watch]
nodes/stats [] [] [create get list watch]
nodes [] [] [create get list watch]
pods [] [] [create get list watch]
deployments.extensions [] [] [get list watch]

4、部署grafana

新版本k8sapi变动,修改Deployment  apiVersion为apiVersion: apps/v1

镜像修改为国内镜像源:image: registry.aliyuncs.com/google_containers/heapster-grafana-amd64:v5.0.4

增加selector选择器

[root@k8s-master1 test2]# cat grafana.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: monitoring-grafana
namespace: kube-system
spec:
replicas: 1
selector:
matchLabels:
task: monitoring
k8s-app: grafana
template:
metadata:
labels:
task: monitoring
k8s-app: grafana
spec:
containers:
- name: grafana
image: registry.aliyuncs.com/google_containers/heapster-grafana-amd64:v5.0.4
ports:
- containerPort: 3000
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: "3000"
# 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: 80
targetPort: 3000
selector:
k8s-app: grafana
type: NodePort 部署grafana
# kubectl apply -f grafana.yaml

5、查询部署资源

[root@k8s-master1 test2]# kubectl get all -n kube-system | egrep 'heapster|monitor'
pod/heapster-7f6787db47-xjtg2 1/1 Running 2 17h
pod/monitoring-grafana-745bf97858-5484w 1/1 Running 2 18h
pod/monitoring-influxdb-77864d8b5-dlwwz 1/1 Running 2 18h
service/heapster ClusterIP 10.103.130.255 <none> 80/TCP 17h
service/monitoring-grafana NodePort 10.102.137.71 <none> 80:31526/TCP 18h
service/monitoring-influxdb ClusterIP 10.102.238.82 <none> 8086/TCP 18h
deployment.apps/heapster 1/1 1 1 17h
deployment.apps/monitoring-grafana 1/1 1 1 18h
deployment.apps/monitoring-influxdb 1/1 1 1 18h
replicaset.apps/heapster-7f6787db47 1 1 1 17h
replicaset.apps/monitoring-grafana-745bf97858 1 1 1 18h
replicaset.apps/monitoring-influxdb-77864d8b5 1 1 1 18h

6、可以使用top命令查询node,pod等资源监控数据。这个需要等一段时间才会有数据

[root@k8s-master1 test2]# kubectl top node
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
k8s-master1 125m 6% 1140Mi 29%
k8s-node1 39m 1% 587Mi 15%
k8s-node2 39m 1% 479Mi 12%

7、 结果展示,在dashboard页面可以看到资源监控数据

部署k8s的heapster监控的更多相关文章

  1. 部署k8s集群监控Heapster

    git clone https://github.com/kubernetes/heapster.gitkubectl apply -f heapster/deploy/kube-config/inf ...

  2. k8s实战之部署Prometheus+Grafana可视化监控告警平台

    写在前面 之前部署web网站的时候,架构图中有一环节是监控部分,并且搭建一套有效的监控平台对于运维来说非常之重要,只有这样才能更有效率的保证我们的服务器和服务的稳定运行,常见的开源监控软件有好几种,如 ...

  3. 从零开始入门 K8s | 可观测性:监控与日志

    作者 | 莫源  阿里巴巴技术专家 一.背景 监控和日志是大型分布式系统的重要基础设施,监控可以帮助开发者查看系统的运行状态,而日志可以协助问题的排查和诊断. 在 Kubernetes 中,监控和日志 ...

  4. k8s全栈监控之metrics-server和prometheus

    一.概述 使用metric-server收集数据给k8s集群内使用,如kubectl,hpa,scheduler等 使用prometheus-operator部署prometheus,存储监控数据 使 ...

  5. kubeadm构建k8s之Prometheus-operated监控(0.18.1)

    介绍: 大家好,k8s的搭建有许多方式,也有许多快速部署的,为了简化部署的复杂度,官方也提供了开源的kubeadm快速部署,最新1.10.x版本已经可以实现部署集群, 如果你对k8s的原理已经非常了解 ...

  6. 使用kubeadm部署k8s

    k8s组件 master,node master中包括apiserver,scheduler,controller.etcd apiserver:负责接收用户请求,并且保存至etcd中. schedu ...

  7. 部署K8S集群

    1.Kubernetes 1.1.概念 kubernetes(通常称为k8s)用于自动部署.扩展和管理容器化应用程序的开源系统.它旨在提供“跨主机集群的自动部署.扩展以及运行应用程序容器的平台”.支持 ...

  8. 二进制部署k8s

    一.二进制部署 k8s集群 1)参考文章 博客: https://blog.qikqiak.com 文章: https://www.qikqiak.com/post/manual-install-hi ...

  9. lvs+keepalived部署k8s v1.16.4高可用集群

    一.部署环境 1.1 主机列表 主机名 Centos版本 ip docker version flannel version Keepalived version 主机配置 备注 lvs-keepal ...

随机推荐

  1. 初步了解认识正则表达式(Regex)

    如果你感到这篇文章对您有所帮助,那请您给我一个免费的赞吧QWQ! 如果想要深入理解什么是正则表达式,请购买教材<形式语言与自动机>,相信学完它之后一定会让你更加理解正则表达式! 1.你的同 ...

  2. 【Pr】基础流程

    新建工程 1.打开Pr 2.点击"新建""项目" 3.在电脑磁盘上新建好项目想要存放的位置,比如Demo1,为了便于管理,我先新建了一个Demo文件夹,再在里边 ...

  3. 视图模板引擎——Vue【双向绑定】原理剖析

    首先我们来了解一下MVC.MVP.MVMM这三大架构模式在前端角度上的理解. MVC分别是 Model(模型).View(视图).Controller(控制器)三个模块.View(视图层)最主要完成前 ...

  4. NC14585 大吉大利,今晚吃鸡

    NC14585 大吉大利,今晚吃鸡 题目 题目描述 糖和抖m在玩个游戏,规定谁输了就要请谁吃顿大餐:抖m给糖a b c三个驻, 并在a柱上放置了数量为n的圆盘,圆盘的大小从上到下依次增大,现在要做的事 ...

  5. NC16618 [NOIP2008]排座椅

    NC16618 [NOIP2008]排座椅 题目 题目描述 上课的时候总有一些同学和前后左右的人交头接耳,这是令小学班主任十分头疼的一件事情.不过,班主任小雪发现了一些有趣的现象,当同学们的座次确定下 ...

  6. go-zero微服务实战系列(九、极致优化秒杀性能)

    上一篇文章中引入了消息队列对秒杀流量做削峰的处理,我们使用的是Kafka,看起来似乎工作的不错,但其实还是有很多隐患存在,如果这些隐患不优化处理掉,那么秒杀抢购活动开始后可能会出现消息堆积.消费延迟. ...

  7. HHL论文及代码理解(Generalizing A Person Retrieval Model Hetero- and Homogeneously ECCV 2018)

    行人再识别Re-ID面临两个特殊的问题: 1)源数据集和目标数据集类别完全不同 2)相机造成的图片差异 因为一般来说传统的域适应问题源域和目标域的类别是相同的,相机之间的不匹配也是造成行人再识别数据集 ...

  8. 【docker专栏1】docker解决的实际问题及应用场景

    Docker是一个开源的容器引擎,它轻巧,且易移植,"build once, configure once and run anywhere".使用go语言开发,并遵从apache ...

  9. 编程思想转换&体验Lambda的更优写法和Lambda标准格式

    编程思想转换做什么,而不是怎么做 我们真的希望创建一个匿名内部类对象吗?不,我们只是为了做这件事情而不得不创建一个对象. 我们真正希望做的事情是:将run方法体内的代码传递给Thread类知晓. 传递 ...

  10. HashSet集合介绍和哈希值

    HashSet集合介绍 ~java.util.Set接口 extends Collection 接口~Set接口的特点: 1.不允许存储重复的元素 2.没有索引,没有带索引的方法,也不能使用普通的fo ...