[k8s]metricbeat的kubernetes模块kube-metric模块

正确姿势启动metricbeat

metricbeat.modules:
- module: systemmetricsets:- cpu- filesystem- memory- network- processenabled: trueperiod: 10sprocesses: ['.*']cpu_ticks: falseoutput.elasticsearch:hosts: ["http://192.168.x.x:9200"]setup.template.name: "metricbeat"
setup.template.fields: "fields.yml"
setup.template.overwrite: true
setup.template.settings:index.number_of_shards: 1index.number_of_replicas: 1setup.kibana.host: "192.168.x.x:5601"
setup.dashboards.enabled: true
./metricbeat -e -c metricbeat.yml -d "publish"

metricbeat的Kubernetes插件

metricbeat.modules:
# Node metrics, from kubelet:
- module: kubernetesmetricsets:- node- system- pod- container- volumeperiod: 10shosts: ["192.168.x.132:10255","192.168.x.133:10255"]# State metrics from kube-state-metrics service:  #这部分需要kube-state-metrics支撑(Nodes/deploy个数),因此集群里需要安装kube-state-metrics组件.默认情况下这里没有的话图中上半部分没有数据
- module: kubernetesenabled: false  ## 这里一定要是truemetricsets:- state_node- state_deployment- state_replicaset- state_pod- state_containerperiod: 10shosts: ["192.168.x.x:8080"]# Kubernetes events
- module: kubernetesenabled: falsemetricsets:- eventoutput.elasticsearch:hosts: ["http://192.168.x.x:9200"]

既然需要kube-state-metrics了,那就研究下吧.

监控思路

  • vm思路:遵从大道至简的原则
    806469-20171207162314331-1142235299.png

  • 容器监控思路:
    pod的:
    top cpu
    top mem

  • 别人家的监控-只能流口水了
    9e792b8fgy1fm8af8nnhjj20ui09zdgj.jpg

kube-state-metrics提供监控k8s集群的metric

kube-state-metrics本质上是提供了k8s集群的metric
部署参考:
https://github.com/kubernetes/kube-state-metrics

克隆代码: create这几个即可
9e792b8fgy1fm8aa5kkvsj209k05maa9.jpg

访问:
9e792b8fgy1fm8a95lc6oj20bd05k0sn.jpg

报错解决:
kubectl -n kube-system logs -f kube-state-metrics-215312065-1vzg2 -c kube-state-metrics
时候发现一些api错误

解决: 给apiserver启动添加这个参数: 它github上有说

--runtime-config=batch/v2alpha1=true

即目前完整的apiserver参数如下

 kube-apiserver     --service-cluster-ip-range=10.254.0.0/16     --etcd-servers=http://127.0.0.1:2379     --insecure-bind-address=0.0.0.0     --admission-control=ServiceAccount     --service-account-key-file=/root/ssl/ca.key --client-ca-file=/root/ssl/ca.crt    --tls-cert-file=/root/ssl/server.crt --tls-private-key-file=/root/ssl/server.key --allow-privileged=true --runtime-config=batch/v2alpha1=true --v=2

k8s插件监控集群效果图

9e792b8fgy1fm8c4o08brj21fp16lanm.jpg

vm监控效果图

806469-20171207173249909-192828741.png

贴上kube-metric的yaml

参考: https://github.com/kubernetes/kube-state-metrics

修改点:

  • deploy的api版本
  • svc为nodeport模式

  • 镜像拉取
docker pull lanny/gcr.io_google_containers_kube-state-metrics_v1.1.0
dokcer pull lanny/gcr.io_google_containers_addon-resizer_1.0
docker tag lanny/gcr.io_google_containers_kube-state-metrics_v1.1.0 gcr.io/google_containers/kube-state-metrics:v1.1.0 
docker tag lanny/gcr.io_google_containers_addon-resizer_1.0 gcr.io/google_containers/addon-resizer:1.0 
$ cat kube-state-metrics-deployment.yaml 
apiVersion: apps/v1beta1 # for versions before 1.8.0 use apps/v1beta1  ## 这里默认是v1beat1,我用的是1.7.8,因此apiVersion: apps/v1beta2是不适用的.
kind: Deployment
metadata:name: kube-state-metricsnamespace: kube-system
spec:selector:matchLabels:k8s-app: kube-state-metricsreplicas: 1template:metadata:labels:k8s-app: kube-state-metricsspec:serviceAccountName: kube-state-metricscontainers:- name: kube-state-metricsimage: quay.io/coreos/kube-state-metrics:v1.1.0ports:- name: http-metricscontainerPort: 8080readinessProbe:httpGet:path: /healthzport: 8080initialDelaySeconds: 5timeoutSeconds: 5- name: addon-resizerimage: gcr.io/google_containers/addon-resizer:1.0resources:limits:cpu: 100mmemory: 30Mirequests:cpu: 100mmemory: 30Mienv:- name: MY_POD_NAMEvalueFrom:fieldRef:fieldPath: metadata.name- name: MY_POD_NAMESPACEvalueFrom:fieldRef:fieldPath: metadata.namespacecommand:- /pod_nanny- --container=kube-state-metrics- --cpu=100m- --extra-cpu=1m- --memory=100Mi- --extra-memory=2Mi- --threshold=5- --deployment=kube-state-metrics
$ cat kube-state-metrics-service.yaml 
apiVersion: v1
kind: Service
metadata:name: kube-state-metricsnamespace: kube-systemlabels:k8s-app: kube-state-metricsannotations:prometheus.io/scrape: 'true'
spec:type: NodePort ## 这里需要改下,外界通过nodeport方式访问metric apiports:- name: http-metricsport: 8080targetPort: http-metricsprotocol: TCPselector:k8s-app: kube-state-metrics
$ cat kube-state-metrics-service-account.yaml 
apiVersion: v1
kind: ServiceAccount
metadata:name: kube-state-metricsnamespace: kube-system

转载于:https://www.cnblogs.com/iiiiher/p/7999761.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/281676.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

如何为 Task 添加超时功能

前言假设有如下代码,功能是首先从缓存获取数据,如果没有命中缓存,则直接从数据库获取:var data await GetFromCache(); if (data is null) {data await GetFromDB(); }对于获取缓存数据,我们需要限制一下GetFromCach…

php 随机指定位数,php生成一个可选位数的随机码

echo coding(6);function coding($num){$str_arr array(‘a‘,‘b‘,‘c‘,‘d‘,‘e‘,‘f‘,‘g‘,‘h‘,‘i‘,‘j‘,‘k‘,‘l‘,‘m‘,‘n‘,‘o‘,‘p‘,‘q‘,‘r‘,‘s‘,‘t‘,‘u‘,‘v‘,‘w‘,‘x‘,‘y‘,‘z‘,‘A‘,‘B‘,‘C‘,‘D‘,‘E‘,‘F‘,‘G‘,‘H‘…

Animate与transform的使用

Animate是用css给前端加载动画的效果&#xff1a; 网址&#xff1a;https://daneden.github.io/animate.css/ <!DOCTYPE html> <html lang"en"> <head><link rel"stylesheet" href"static/css/Animate.css"><meta ch…

angular中的cookies与cookieStore区别

设置cookie用put()方法: $cookies.put(key, value[, options]); $cookieStore.put(key, value); 例如设置一个cookie&#xff0c;名为“userName”&#xff0c;值为“yangmin”&#xff1a; //使用$cookies设置cookie $cookies.put(userName, yangmin); //使用$cookieStore设置…

ASP.NET Core 6框架揭秘实例演示[29]:搭建文件服务器

通过HTTP请求获取的Web资源很多都来源于存储在服务器磁盘上的静态文件。对于ASP.NET应用来说&#xff0c;如果将静态文件存储到约定的目录下&#xff0c;绝大部分文件类型都是可以通过Web的形式对外发布的。“Microsoft.AspNetCore.StaticFiles” 这个NuGet包中提供了三个用来处…

js 栈(进制转换)

<!DOCTYPE html>Documentposted 2017-12-07 19:33 mysure 阅读(...) 评论(...) 编辑 收藏 刷新评论刷新页面返回顶部转载于:https://www.cnblogs.com/ar13/p/8000718.html

流程展示 php,js实现动态的流程进度展示条

这次给大家带来js实现动态的流程进度展示条&#xff0c;js实现动态流程进度展示条的注意事项有哪些&#xff0c;下面就是实战案例&#xff0c;一起来看一下。一、设计思路分为以下几步(仅供参考)【竖线线】这个采用ul的list标签制作&#xff0c;保证了可随时添加&#xff0c;以…

【我们一起写框架】C#的AOP框架

原文:【我们一起写框架】C#的AOP框架前言 AOP&#xff0c;大家都是听过的&#xff0c;它是一种面向切面的设计模式。 不过AOP虽然是被称为设计模式&#xff0c;但我们应该很少能看到AOP设计的框架。为什么呢&#xff1f; 因为&#xff0c;AOP单独设计的框架几乎是无法使用的。普…

新浪微博授权认证过程

为什么80%的码农都做不了架构师&#xff1f;>>> 一、授权认证 1、请求用户授权Token URL&#xff1a; https://api.weibo.com/oauth2/authorize HTTP请求方式:GET/POST 请求参数 必选 类型及范围 说明 client_id true string 申请应用时分配的AppKey。 redire…

VisualStudio 使用 FastTunnel 辅助搭建远程调试环境

有时候需要远程调试一些用户问题&#xff0c;期望能使用本机的 Visual Studio 开发环境&#xff0c;调试远程的用户的设备上的应用。这时会遇到的一个问题是如何让本机的 Visual Studio 可以连接上远程的用户的设备&#xff0c;从而进行调试。本文将告诉大家如何采用 FastTunne…

深入理解null的原理

--null的原理 --oracle一直将null和空字符串’’<长度为0>同等对待<如’’ is null是true,’’null为false,如果声明a varchar2:’’,那么a is null为true,a’’为false>--1.null的运算 --算术表达式和null 运算总为null,实际上所有的操作符除了||连接操作符外&…

阻止中文输入法输入拼音的时候触发input事件

阻止中文输入法输入拼音的时候触发input事件 前言 最近看element-ui源码的时候看到el-input发现的。这个少见的事件。 compositionstart、compositionend事件&#xff08;MDN解释) compositionstart事件触发于一段文字的输入之前&#xff08;类似于 keydown 事件&#xff0c;但…

Python1

python介绍python是一种解释型的&#xff0c;面对对象的。带有动态语义的高级程序设计语言python简史1989年,Guido(龟叔)为ABC 语言写的一个插件。因Monty Python的喜剧团体的原因,故给这个语言起名为python。linux也是1989年诞生的,1991年正式发布linux1.0内核;1990年, 发布py…

ncut算法matlab实现,ncut_multiscale_1_6 经典的图像分割算法 的Matlab代码。 238万源代码下载- www.pudn.com...

文件名称: ncut_multiscale_1_6下载收藏√ [5 4 3 2 1 ]开发工具: matlab文件大小: 587 KB上传时间: 2015-04-17下载次数: 4提 供 者: HH详细说明&#xff1a;经典的图像分割算法NCut的Matlab代码。-Matlab code of classic image segmentation algorithm NCut .文件列表(…

使用.NET从零实现基于用户角色的访问权限控制

使用.NET从零实现基于用户角色的访问权限控制本文将介绍如何实现一个基于.NET RBAC 权限管理系统&#xff0c;如果您不想了解原理&#xff0c;可查看推送的另一篇文章关于Sang.AspNetCore.RoleBasedAuthorization[1] 库是使用介绍&#xff0c;直接使用该库即可。背景在设计系统…

数据归一化

数据归一化 数据的标准化是将数据按比例缩放&#xff0c;使之落入一个小的特定区间&#xff0c;一般为0到1之间。在某些比较和评价的指标处理中经常会用到&#xff0c;去除数据的单位限制&#xff0c;将其转化为无量纲的纯数值&#xff0c;便于不同单位或量级的指标能够进行比较…

vi is failed with error E382: Cannot write, 'buftype' option is set in Linux

在linux下生成jar文件遇到了编码问题&#xff0c;于是想vi t.jar&#xff0c;在保存是报错&#xff1a;E382: Cannot write, buftype option is set 解决方法&#xff1a; 可以用下面的命名查看buftype的设置&#xff0c;当buftypenofile时&#xff0c;不能保存文件&#xff0c…

列表生成式的使用

输入&#xff1a;[Hello, World, 18, Apple, None] 输出&#xff1a;[hello, world, apple] L [Hello, World, 18, Apple, None] print([w.lower() for w in L if isinstance(w, str)])# -- coding: utf-8 -- L [Hello, World, 18, Apple, None] L2 [] L2 [w.lower() for w…

matlab 12位 显示不出来,求助大神,为何不同机器运行MATLAB结果不同

求助&#xff1a;不同机器运行MATLAB结果不同我调用MATLAB优化工具箱的库函数fmincon&#xff0c;使用相同的初始解(可行解)&#xff0c;对同一个问题进行局部搜索(算法为序列二次规划&#xff0c;即SQP)&#xff0c;但在不同机器上得到的结果不同。一共有五台机器 (为了方便&a…

.NET性能系列文章一:.NET7的性能改进

这些方法在.NET7 中变得更快照片来自 CHUTTERSNAP[1] 的 Unsplash[2]欢迎阅读.NET 性能系列的第一章。这一系列的特点是对.NET 世界中许多不同的主题进行研究、比较性能。正如标题所说的那样&#xff0c;本章节在于.NET7 中的性能改进。你将看到哪种方法是实现特定功能最快的方…