{"id":11134,"date":"2023-12-29T17:12:53","date_gmt":"2023-12-29T09:12:53","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=11134"},"modified":"2023-12-29T17:12:52","modified_gmt":"2023-12-29T09:12:52","slug":"%e8%a7%a3%e5%86%b3-kubernetes-%e4%b8%ad-kubelet-%e6%8a%a5-failed-to-get-cgroup-failed-to-get-system-container-stats-%e9%94%99%e8%af%af","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=11134","title":{"rendered":"\u89e3\u51b3 Kubernetes \u4e2d Kubelet \u62a5 failed to get cgroup Failed to get system container stats \u9519\u8bef"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<hr \/>\n<p>kubelet \u4e2d\u4f1a\u53d1\u73b0\u6709\u4e0b\u9762\u8fd9\u6837\u7684\u62a5\u9519\uff1a<\/p>\n<pre><code>summary_sys_containers.go:47] Failed to get system container stats for \"\/system.slice\/kubelet.service\": failed to get cgroup stats for \"\/system.slice\/kubelet.service\": failed to get container info for \"\/system.slice\/kubelet.service\": unknown container \"\/system.slice\/kubelet.service<\/code><\/pre>\n<p>\u53ef\u80fd\u540e\u7eedkubelet\u8bb0\u5f55\u7684\u9519\u8bef\u4f1a\u53d8\u4e3a\uff1aCPUAccounting not enabled for pid<\/p>\n<pre><code>7\u6708 31 22:23:43 vqa41 kubelet[13757]: W0731 22:23:43.530498   13757 container_manager_linux.go:842] CPUAccounting not enabled for pid: 13757\n7\u6708 31 22:28:43 vqa41 kubelet[13757]: W0731 22:28:43.531162   13757 container_manager_linux.go:842] CPUAccounting not enabled for pid: 13757\n7\u6708 31 22:33:43 vqa41 kubelet[13757]: W0731 22:33:43.532605   13757 container_manager_linux.go:842] CPUAccounting not enabled for pid: 13757\n7\u6708 31 22:38:43 vqa41 kubelet[13757]: W0731 22:38:43.533253   13757 container_manager_linux.go:842] CPUAccounting not enabled for pid: 13757\n7\u6708 31 22:43:43 vqa41 kubelet[13757]: W0731 22:43:43.536079   13757 container_manager_linux.go:842] CPUAccounting not enabled for pid: 13757\n7\u6708 31 22:48:43 vqa41 kubelet[13757]: W0731 22:48:43.536546   13757 container_manager_linux.go:842] CPUAccounting not enabled for pid: 13757\n7\u6708 31 22:53:43 vqa41 kubelet[13757]: W0731 22:53:43.537916   13757 container_manager_linux.go:842] CPUAccounting not enabled for pid: 13757\n7\u6708 31 22:58:43 vqa41 kubelet[13757]: W0731 22:58:43.538449   13757 container_manager_linux.go:842] CPUAccounting not enabled for pid: 13757\n7\u6708 31 23:03:43 vqa41 kubelet[13757]: W0731 23:03:43.539382   13757 container_manager_linux.go:842] CPUAccounting not enabled for pid: 13757\n7\u6708 31 23:08:43 vqa41 kubelet[13757]: W0731 23:08:43.544078   13757 container_manager_linux.go:842] CPUAccounting not enabled for pid: 13757<\/code><\/pre>\n<p>\u4ee5\u53ca MemoryAccounting not enabled for pid<\/p>\n<pre><code>7\u6708 31 22:53:43 vqa41 kubelet[13757]: W0731 22:53:43.537925   13757 container_manager_linux.go:845] MemoryAccounting not enabled for pid: 13757\n7\u6708 31 22:58:43 vqa41 kubelet[13757]: W0731 22:58:43.538459   13757 container_manager_linux.go:845] MemoryAccounting not enabled for pid: 13757\n7\u6708 31 23:03:43 vqa41 kubelet[13757]: W0731 23:03:43.539393   13757 container_manager_linux.go:845] MemoryAccounting not enabled for pid: 13757\n7\u6708 31 23:08:43 vqa41 kubelet[13757]: W0731 23:08:43.544087   13757 container_manager_linux.go:845] MemoryAccounting not enabled for pid: 13757\n7\u6708 31 23:13:43 vqa41 kubelet[13757]: W0731 23:13:43.544813   13757 container_manager_linux.go:845] MemoryAccounting not enabled for pid: 13757\n7\u6708 31 23:18:43 vqa41 kubelet[13757]: W0731 23:18:43.546129   13757 container_manager_linux.go:845] MemoryAccounting not enabled for pid: 13757\n7\u6708 31 23:23:43 vqa41 kubelet[13757]: W0731 23:23:43.546597   13757 container_manager_linux.go:845] MemoryAccounting not enabled for pid: 13757\n7\u6708 31 23:28:43 vqa41 kubelet[13757]: W0731 23:28:43.550039   13757 container_manager_linux.go:845] MemoryAccounting not enabled for pid: 13757\n7\u6708 31 23:33:43 vqa41 kubelet[13757]: W0731 23:33:43.552043   13757 container_manager_linux.go:845] MemoryAccounting not enabled for pid: 13757<\/code><\/pre>\n<h3>\u89e3\u51b3\u65b9\u6848\u53ca\u5206\u6790<\/h3>\n<hr \/>\n<h4>\u95ee\u9898\u5206\u6790<\/h4>\n<p>\u53c2\u8003\u51e0\u4e2a Kubernetes Github \u4e0a\u7684 issue\uff1a<\/p>\n<p><a href=\"https:\/\/github.com\/kubernetes\/kubernetes\/issues\/56850\">https:\/\/github.com\/kubernetes\/kubernetes\/issues\/56850<\/a><br \/>\n<a href=\"https:\/\/github.com\/kubermatic\/machine-controller\/pull\/476\">https:\/\/github.com\/kubermatic\/machine-controller\/pull\/476<\/a><br \/>\n<a href=\"https:\/\/github.com\/kubernetes\/kubernetes\/issues\/56850#issuecomment-406241077\">https:\/\/github.com\/kubernetes\/kubernetes\/issues\/56850#issuecomment-406241077<\/a><br \/>\n\u4ece\u4e0a\u9762\u5404\u4e2a issue \u4e2d\uff0c\u8be5\u95ee\u9898\u53ea\u4f1a\u53d1\u751f\u5728 CentOS \u7cfb\u7edf\u4e0a\uff0c\u800c\u5f15\u8d77\u4e0a\u9762\u7684\u95ee\u9898\u7684\u539f\u56e0\u662f kubelet \u542f\u52a8\u65f6\uff0c\u4f1a\u6267\u884c\u8282\u70b9\u8d44\u6e90\u7edf\u8ba1\uff0c\u9700\u8981 systemd \u4e2d\u5f00\u542f\u5bf9\u5e94\u7684\u9009\u9879\uff0c\u5982\u4e0b\uff1a<\/p>\n<p>CPUAccounting\uff1a\u662f\u5426\u5f00\u542f\u8be5 unit \u7684 CPU \u4f7f\u7528\u7edf\u8ba1\uff0cbool \u7c7b\u578b\uff0c\u53ef\u914d\u7f6e true \u6216\u8005 false\u3002<br \/>\nMemoryAccounting\uff1a\u662f\u5426\u5f00\u542f\u8be5 unit \u7684 Memory \u4f7f\u7528\u7edf\u8ba1\uff0cbool \u7c7b\u578b\uff0c\u53ef\u914d\u7f6e true \u6216\u8005 false\u3002<br \/>\n\u5982\u679c\u4e0d\u8bbe\u7f6e\u8fd9\u4e24\u9879\uff0ckubelet \u662f\u65e0\u6cd5\u6267\u884c\u8be5\u7edf\u8ba1\u547d\u4ee4\uff0c\u5bfc\u81f4 kubelet \u4e00\u76f4\u62a5\u4e0a\u9762\u7684\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n<h4>\u89e3\u51b3\u65b9\u6848<\/h4>\n<p>\u89e3\u51b3\u4e0a\u9762\u95ee\u9898\u4e5f\u5f88\u7b80\u5355\uff0c\u76f4\u63a5\u7f16\u8f91 systemd \u4e2d\u7684 kubelet \u670d\u52a1\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0 CPU \u548c Memory \u914d\u7f6e\uff0c\u53ef\u4ee5\u6309\u4e0b\u9762\u64cd\u4f5c\u8fdb\u884c\u66f4\u6539\u3002<\/p>\n<p><strong>1.\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\u5e76\u6dfb\u52a0\u5bf9\u5e94\u914d\u7f6e\u9879<\/strong><br \/>\n\u7f16\u8f91 \/usr\/lib\/systemd\/system\/kubelet.service \u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4e0b\u9762\u914d\u7f6e\uff08\u9ed8\u8ba4\u6ca1\u6709\u8fd9\u4e2a\u914d\u7f6e\uff09\uff1a<\/p>\n<p>CPUAccounting=true<br \/>\nMemoryAccounting=true<br \/>\n\u914d\u7f6e\u4fe1\u606f<\/p>\n<pre><code class=\"language-shell\">\n[Unit]\nDescription=Kubernetes Kubelet\nAfter=docker.service docker.socket\nWants=docker.socket\n\n[Service]\nCPUAccounting=true\nMemoryAccounting=true\nExecStart=\/opt\/kubernetes\/bin\/kubelet \\\n    --logtostderr=false \\\n    --v=2 \\\n    --hostname-override=vqa45 \\\n    --log-dir=\/var\/log\/kubernetes\/kubelet \\\n    --log-file=\/var\/log\/kubernetes\/kubelet\/kubelet.log \\\n    --node-labels=master=true,worker=true \\\n    --node-ip=172.22.7.45 \\\n    --pod-infra-container-image=transwarp\/pause:tos-2.1.2 \\\n    --network-plugin=cni \\\n    --eviction-hard= \\\n    --bootstrap-kubeconfig=\/srv\/kubernetes\/bootstrap.kubeconfig \\\n    --feature-gates=SupportPodPidsLimit=false,SupportNodePidsLimit=false \\\n    --kubeconfig=\/srv\/kubernetes\/kubeconfig \\\n    --config=\/opt\/kubernetes\/kubelet-config.yaml \\\n    --tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256\n\nKillMode=process\nRestart=always\nRestartSec=15\n\n[Install]\nWantedBy=multi-user.target<\/code><\/pre>\n<p><strong>2.\u91cd\u542f Kubelet \u670d\u52a1<\/strong><br \/>\n\u91cd\u542f kubelet \u670d\u52a1\uff0c\u8ba9 kubelet \u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\u3002<\/p>\n<pre><code class=\"language-shell\"># systemctl daemon-reload && systemctl restart kubelet<\/code><\/pre>\n<p><strong>3.\u89c2\u5bdf kubelet \u65e5\u5fd7<\/strong><br \/>\n\u91cd\u542f\u5b8c kubelet \u540e\u7b49\u4e00\u6bb5\u65f6\u95f4\uff0c\u518d\u6b21\u89c2\u5bdf kubelet \u65e5\u5fd7\u4fe1\u606f\u3002<\/p>\n<h3>\u5176\u4ed6\u4fe1\u606f<\/h3>\n<p><strong>manager 933 \u4fee\u590d\u8be5\u95ee\u9898<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 kubelet \u4e2d\u4f1a\u53d1\u73b0\u6709\u4e0b\u9762\u8fd9\u6837\u7684\u62a5\u9519\uff1a summary_sys_containers.go:47 ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=11134\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[],"class_list":["post-11134","post","type-post","status-publish","format-standard","hentry","category-usage_issues"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/11134","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11134"}],"version-history":[{"count":2,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/11134\/revisions"}],"predecessor-version":[{"id":11576,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/11134\/revisions\/11576"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11134"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11134"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}