{"id":127866,"date":"2018-11-22T10:12:16","date_gmt":"2018-11-22T02:12:16","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=127866"},"modified":"2018-11-14T10:13:13","modified_gmt":"2018-11-14T02:13:13","slug":"kubernetes-krs","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/kubernetes-krs.html","title":{"rendered":"\u6536\u96c6 Kubernetes \u8d44\u6e90\u7edf\u8ba1\u6570\u636e\u7684\u65b0\u5de5\u5177"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u96f6\u914d\u7f6e\u5de5\u5177\u7b80\u5316\u4e86\u4fe1\u606f\u6536\u96c6\uff0c\u4f8b\u5982\u5728\u67d0\u4e2a\u547d\u540d\u7a7a\u95f4\u4e2d\u8fd0\u884c\u4e86\u591a\u5c11\u4e2a pod\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u6700\u8fd1\u6211\u5728\u7ebd\u7ea6\u7684 O'Reilly Velocity \u5c31 Kubernetes \u5e94\u7528\u6545\u969c\u6392\u9664\u7684\u4e3b\u9898\u53d1\u8868\u4e86\u6f14\u8bb2\uff0c\u5e76\u4e14\u5728\u79ef\u6781\u7684\u53cd\u9988\u548c\u8ba8\u8bba\u7684\u63a8\u52a8\u4e0b\uff0c\u6211\u51b3\u5b9a\u91cd\u65b0\u5ba1\u89c6\u8fd9\u4e2a\u9886\u57df\u7684\u5de5\u5177\u3002\u7ed3\u679c\uff0c\u9664\u4e86 kubernetes-incubator\/spartakus \u548c kubernetes\/kube-state-metrics \u4e4b\u5916\uff0c\u6211\u4eec\u8fd8\u6ca1\u6709\u592a\u591a\u7684\u8f7b\u91cf\u7ea7\u5de5\u5177\u6765\u6536\u96c6\u8d44\u6e90\u7edf\u8ba1\u6570\u636e\uff08\u4f8b\u5982\u547d\u540d\u7a7a\u95f4\u4e2d\u7684 pod \u6216\u670d\u52a1\u7684\u6570\u91cf\uff09\u3002\u6240\u4ee5\uff0c\u6211\u5728\u56de\u5bb6\u7684\u8def\u4e0a\u5f00\u59cb\u7f16\u5199\u4e00\u4e2a\u5c0f\u5de5\u5177 \u2014\u2014 \u521b\u9020\u6027\u5730\u547d\u540d\u4e3a krs\uff0c\u5b83\u662f Kubernetes Resource Stats \u7684\u7b80\u79f0 \uff0c\u5b83\u5141\u8bb8\u4f60\u6536\u96c6\u8fd9\u4e9b\u7edf\u8ba1\u6570\u636e\u3002<\/p>\n

\u4f60\u53ef\u4ee5\u901a\u8fc7\u4e24\u79cd\u65b9\u5f0f\u4f7f\u7528 mhausenblas\/krs\uff1a<\/p>\n

\u76f4\u63a5\u5728\u547d\u4ee4\u884c\uff08\u6709 Linux\u3001Windows \u548c MacOS \u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\uff09\uff0c\u4ee5\u53ca
\n\u5728\u96c6\u7fa4\u4e2d\u4f7f\u7528 launch.sh \u811a\u672c\u90e8\u7f72\uff0c\u8be5\u811a\u672c\u52a8\u6001\u521b\u5efa\u9002\u5f53\u7684\u57fa\u4e8e\u89d2\u8272\u7684\u8bbf\u95ee\u63a7\u5236\uff08RBAC\uff09 \u6743\u9650\u3002
\n\u63d0\u9192\u4f60\uff0c\u5b83\u8fd8\u5728\u65e9\u671f\uff0c\u5e76\u4e14\u8fd8\u5728\u5f00\u53d1\u4e2d\u3002\u4f46\u662f\uff0ckrs \u7684 0.1 \u7248\u672c\u63d0\u4f9b\u4ee5\u4e0b\u529f\u80fd\uff1a<\/p>\n

\u5728\u6bcf\u4e2a\u547d\u540d\u7a7a\u95f4\u7684\u57fa\u7840\u4e0a\uff0c\u5b83\u5b9a\u671f\u6536\u96c6\u8d44\u6e90\u7edf\u8ba1\u4fe1\u606f\uff08\u652f\u6301 pod\u3001\u90e8\u7f72\u548c\u670d\u52a1\uff09\u3002
\n\u5b83\u4ee5 OpenMetrics \u683c\u5f0f\u516c\u5f00\u8fd9\u4e9b\u7edf\u8ba1\u3002
\n\u5b83\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7\u4e8c\u8fdb\u5236\u6587\u4ef6\u4f7f\u7528\uff0c\u4e5f\u53ef\u4ee5\u5728\u5305\u542b\u6240\u6709\u4f9d\u8d56\u9879\u7684\u5bb9\u5668\u5316\u8bbe\u7f6e\u4e2d\u4f7f\u7528\u3002
\n\u76ee\u524d\uff0c\u4f60\u9700\u8981\u5b89\u88c5\u5e76\u914d\u7f6e kubectl\uff0c\u56e0\u4e3a krs \u4f9d\u8d56\u4e8e\u6267\u884c kubectl get all \u547d\u4ee4\u6765\u6536\u96c6\u7edf\u8ba1\u6570\u636e\u3002\uff08\u53e6\u4e00\u65b9\u9762\uff0c\u8c01\u4f1a\u4f7f\u7528 Kubernetes \u4f46\u6ca1\u6709\u5b89\u88c5 kubectl \u5462\uff1f\uff09<\/p>\n

\u4f7f\u7528 krs \u5f88\u7b80\u5355\u3002\u4e0b\u8f7d\u9002\u5408\u4f60\u5e73\u53f0\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u5e76\u6309\u5982\u4e0b\u65b9\u5f0f\u6267\u884c\uff1a<\/p>\n

$ krs thenamespacetowatch\r\n# HELP pods Number of pods in any state, for example running\r\n# TYPE pods gauge\r\npods{namespace=\"thenamespacetowatch\"} 13\r\n# HELP deployments Number of deployments\r\n# TYPE deployments gauge\r\ndeployments{namespace=\"thenamespacetowatch\"} 6\r\n# HELP services Number of services\r\n# TYPE services gauge\r\nservices{namespace=\"thenamespacetowatch\"} 4<\/pre>\n

\u8fd9\u5c06\u5728\u524d\u53f0\u542f\u52a8 krs\uff0c\u4ece\u540d\u79f0\u7a7a\u95f4 thenamespacetowatch \u6536\u96c6\u8d44\u6e90\u7edf\u8ba1\u4fe1\u606f\uff0c\u5e76\u5206\u522b\u5728\u6807\u51c6\u8f93\u51fa\u4e2d\u4ee5 OpenMetrics \u683c\u5f0f\u8f93\u51fa\u5b83\u4eec\uff0c\u4ee5\u4f9b\u4f60\u8fdb\u4e00\u6b65\u5904\u7406\u3002<\/p>\n

\"\"<\/p>\n

krs \u5b9e\u6218\u622a\u5c4f<\/p>\n

\u4e5f\u8bb8\u4f60\u4f1a\u95ee\uff0cMichael\uff0c\u4e3a\u4ec0\u4e48\u5b83\u4e0d\u80fd\u505a\u4e00\u4e9b\u6709\u7528\u7684\u4e8b\uff08\u4f8b\u5982\u5c06\u6307\u6807\u5b58\u50a8\u5728 S3 \u4e2d\uff09\uff1f\u56e0\u4e3a Unix \u54f2\u5b66\u3002<\/p>\n

\u5bf9\u4e8e\u90a3\u4e9b\u60f3\u77e5\u9053\u4ed6\u4eec\u662f\u5426\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 Prometheus \u6216 kubernetes\/kube-state-metrics \u6765\u5b8c\u6210\u8fd9\u9879\u4efb\u52a1\u7684\u4eba\uff1a\u662f\u7684\uff0c\u4f60\u53ef\u4ee5\uff0c\u4e3a\u4ec0\u4e48\u4e0d\u884c\u5462\uff1f krs \u7684\u91cd\u70b9\u662f\u4f5c\u4e3a\u5df2\u6709\u5de5\u5177\u7684\u8f7b\u91cf\u7ea7\u4e14\u6613\u4e8e\u4f7f\u7528\u7684\u66ff\u4ee3\u54c1 \u2014\u2014 \u751a\u81f3\u53ef\u80fd\u5728\u67d0\u4e9b\u65b9\u9762\u7565\u5fae\u4e92\u8865\u3002<\/p>\n

\u672c\u6587\u6700\u521d\u53d1\u8868\u5728 Medium \u7684 ITNext \u4e0a\uff0c\u5e76\u83b7\u5f97\u6388\u6743\u8f6c\u8f7d\u3002<\/p>\n


\n

via:\u00a0https:\/\/opensource.com\/article\/18\/11\/kubernetes-resource-statistics<\/a><\/p>\n

\u4f5c\u8005\uff1aMichael Hausenblas<\/a>\u00a0\u9009\u9898\uff1alujun9972<\/a>\u00a0\u8bd1\u8005\uff1ageekpi<\/a>\u00a0\u6821\u5bf9\uff1awxy<\/a><\/p>\n

\u672c\u6587\u7531\u00a0LCTT<\/a>\u00a0\u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd<\/a>\u00a0\u8363\u8a89\u63a8\u51fa<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6700\u8fd1\u6211\u5728\u7ebd\u7ea6\u7684 O’Reilly Velocity \u5c31 Kubernetes \u5e94\u7528\u6545\u969c\u6392\u9664\u7684\u4e3b\u9898\u53d1\u8868\u4e86\u6f14\u8bb2\uff0c\u5e76 […]<\/p>\n","protected":false},"author":1890,"featured_media":127870,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-127866","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/127866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1890"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=127866"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/127866\/revisions"}],"predecessor-version":[{"id":127880,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/127866\/revisions\/127880"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/127870"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=127866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=127866"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=127866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}