[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.pswp.cn/news/281676.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/281676.shtml
英文地址,請注明出處:http://en.pswp.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 中的性能改進。你將看到哪種方法是實現特定功能最快的方…