{"id":14982,"date":"2023-09-25T14:31:05","date_gmt":"2023-09-25T06:31:05","guid":{"rendered":"https:\/\/blog.ywdevops.cn\/?p=14982"},"modified":"2023-09-25T14:47:13","modified_gmt":"2023-09-25T06:47:13","slug":"cgroup-2","status":"publish","type":"post","link":"https:\/\/blog.ywdevops.cn\/index.php\/2023\/09\/25\/cgroup-2\/","title":{"rendered":"k8s\u4e4bcgroup\u9a71\u52a8"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u5728 Linux \u4e0a\uff0c<a rel=\"noreferrer noopener\" href=\"https:\/\/kubernetes.io\/zh-cn\/docs\/reference\/glossary\/?all=true#term-cgroup\" target=\"_blank\">\u63a7\u5236\u7ec4\uff08CGroup\uff09<\/a>\u7528\u4e8e\u9650\u5236\u5206\u914d\u7ed9\u8fdb\u7a0b\u7684\u8d44\u6e90<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a rel=\"noreferrer noopener\" href=\"https:\/\/kubernetes.io\/docs\/reference\/generated\/kubelet\" target=\"_blank\">kubelet<\/a>\u00a0\u548c\u5e95\u5c42\u5bb9\u5668\u8fd0\u884c\u65f6\u90fd\u9700\u8981\u5bf9\u63a5\u63a7\u5236\u7ec4\u6765\u5f3a\u5236\u6267\u884c\u00a0<a href=\"https:\/\/kubernetes.io\/zh-cn\/docs\/concepts\/configuration\/manage-resources-containers\/\">\u4e3a Pod \u548c\u5bb9\u5668\u7ba1\u7406\u8d44\u6e90<\/a>\u00a0\u5e76\u4e3a\u8bf8\u5982 CPU\u3001\u5185\u5b58\u8fd9\u7c7b\u8d44\u6e90\u8bbe\u7f6e\u8bf7\u6c42\u548c\u9650\u5236\u3002\u82e5\u8981\u5bf9\u63a5\u63a7\u5236\u7ec4\uff0ckubelet \u548c\u5bb9\u5668\u8fd0\u884c\u65f6\u9700\u8981\u4f7f\u7528\u4e00\u4e2a\u00a0<strong>cgroup \u9a71\u52a8<\/strong>\u3002 <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\"><strong>\u5173\u952e\u7684\u4e00\u70b9\u662f kubelet \u548c\u5bb9\u5668\u8fd0\u884c\u65f6\u9700\u4f7f\u7528\u76f8\u540c\u7684 cgroup \u9a71\u52a8\u5e76\u4e14\u91c7\u7528\u76f8\u540c\u7684\u914d\u7f6e<\/strong><\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u7528\u7684 cgroup \u9a71\u52a8\u6709\u4e24\u4e2a\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>cgroupfs<\/li>\n\n\n\n<li>systemd<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">cgroupfs \u9a71\u52a8<\/mark><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>cgroupfs<\/code>\u00a0\u9a71\u52a8\u662f\u00a0<a href=\"https:\/\/kubernetes.io\/zh-cn\/docs\/reference\/config-api\/kubelet-config.v1beta1\">kubelet \u4e2d\u9ed8\u8ba4\u7684 cgroup \u9a71\u52a8<\/a>\u3002 \u5f53\u4f7f\u7528\u00a0<code>cgroupfs<\/code>\u00a0\u9a71\u52a8\u65f6\uff0c kubelet \u548c\u5bb9\u5668\u8fd0\u884c\u65f6\u5c06\u76f4\u63a5\u5bf9\u63a5 cgroup \u6587\u4ef6\u7cfb\u7edf\u6765\u914d\u7f6e cgroup<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u64cd\u4f5c\u7cfb\u7edf\u662f\u4f7f\u7528\u00a0<a href=\"https:\/\/www.freedesktop.org\/wiki\/Software\/systemd\/\">systemd<\/a>\u00a0\u6765\u521d\u59cb\u5316\u7cfb\u7edf\u65f6\uff0c\u00a0\u4e0d\u63a8\u8350\u4f7f\u7528\u00a0<code>cgroupfs<\/code>\u00a0\u9a71\u52a8\uff0c\u56e0\u4e3a systemd \u671f\u671b\u7cfb\u7edf\u4e0a\u53ea\u6709\u4e00\u4e2a cgroup \u7ba1\u7406\u5668\u3002 \u6b64\u5916\uff0c\u5982\u679c\u4f60\u4f7f\u7528\u00a0<a href=\"https:\/\/kubernetes.io\/zh-cn\/docs\/concepts\/architecture\/cgroups\">cgroup v2<\/a>\uff0c \u5219\u5e94\u7528\u00a0<code>systemd<\/code>\u00a0cgroup \u9a71\u52a8\u53d6\u4ee3\u00a0<code>cgroupfs<\/code><\/p>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">systemd\u9a71\u52a8<\/mark><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u67d0\u4e2a Linux \u7cfb\u7edf\u53d1\u884c\u7248\u4f7f\u7528\u00a0<a href=\"https:\/\/www.freedesktop.org\/wiki\/Software\/systemd\/\">systemd<\/a>\u00a0\u4f5c\u4e3a\u5176\u521d\u59cb\u5316\u7cfb\u7edf\u65f6\uff0c\u521d\u59cb\u5316\u8fdb\u7a0b\u4f1a\u751f\u6210\u5e76\u4f7f\u7528\u4e00\u4e2a root \u63a7\u5236\u7ec4\uff08<code>cgroup<\/code>\uff09\uff0c\u5e76\u5145\u5f53 cgroup \u7ba1\u7406\u5668<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">systemd \u4e0e cgroup \u96c6\u6210\u7d27\u5bc6\uff0c\u5e76\u5c06\u4e3a\u6bcf\u4e2a systemd \u5355\u5143\u5206\u914d\u4e00\u4e2a cgroup\u3002 \u56e0\u6b64\uff0c\u5982\u679c\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u4f7f\u7528\u00a0<code>systemd<\/code>\u00a0\u7528\u4f5c\u521d\u59cb\u5316\u7cfb\u7edf\uff0c\u540c\u65f6\u4f7f\u7528\u00a0<code>cgroupfs<\/code>\u00a0\u9a71\u52a8\uff0c\u5219\u7cfb\u7edf\u4e2d\u4f1a\u5b58\u5728\u4e24\u4e2a\u4e0d\u540c\u7684 cgroup \u7ba1\u7406\u5668<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u540c\u65f6\u5b58\u5728\u4e24\u4e2a cgroup \u7ba1\u7406\u5668\u5c06\u9020\u6210\u7cfb\u7edf\u4e2d\u9488\u5bf9\u53ef\u7528\u7684\u8d44\u6e90\u548c\u4f7f\u7528\u4e2d\u7684\u8d44\u6e90\u51fa\u73b0\u4e24\u4e2a\u89c6\u56fe\u3002\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c \u5c06 kubelet \u548c\u5bb9\u5668\u8fd0\u884c\u65f6\u914d\u7f6e\u4e3a\u4f7f\u7528\u00a0<code>cgroupfs<\/code>\u3001\u4f46\u4e3a\u5269\u4f59\u7684\u8fdb\u7a0b\u4f7f\u7528\u00a0<code>systemd<\/code>\u00a0\u7684\u90a3\u4e9b\u8282\u70b9\u5c06\u5728\u8d44\u6e90\u538b\u529b\u589e\u5927\u65f6\u53d8\u5f97\u4e0d\u7a33\u5b9a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u64cd\u4f5c\u7cfb\u7edf\u4f7f\u7528 systemd \u6765\u521d\u59cb\u5316\u7cfb\u7edf\u65f6\uff0c\u7f13\u89e3\u8fd9\u4e2a\u4e0d\u7a33\u5b9a\u95ee\u9898\u7684\u65b9\u6cd5\u662f\u9488\u5bf9 kubelet \u548c\u5bb9\u5668\u8fd0\u884c\u65f6\u5c06\u00a0<code>systemd<\/code>\u00a0\u7528\u4f5c cgroup \u9a71\u52a8<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8981\u5c06\u00a0<code>systemd<\/code>\u00a0\u8bbe\u7f6e\u4e3a cgroup \u9a71\u52a8\uff0c\u9700\u7f16\u8f91\u00a0<a href=\"https:\/\/kubernetes.io\/zh-cn\/docs\/tasks\/administer-cluster\/kubelet-config-file\/\"><code>KubeletConfiguration<\/code><\/a>\u00a0\u7684\u00a0<code>cgroupDriver<\/code>\u00a0\u9009\u9879\uff0c\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3a\u00a0<code>systemd<\/code>\uff0ckubeadm\u5b89\u88c5\u7684\u96c6\u7fa4\uff0ckubelet\u914d\u7f6e\u6587\u4ef6\u5728\/var\/lib\/kubelet\/config.yaml\uff0c\u4f8b\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apiVersion: kubelet.config.k8s.io\/v1beta1\r\nkind: KubeletConfiguration\r\n...\r\ncgroupDriver: systemd<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"692\" height=\"400\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/09\/7-7.png\" alt=\"\" class=\"wp-image-14991\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/09\/7-7.png 692w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/09\/7-7-300x173.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/09\/7-7-600x347.png 600w\" sizes=\"auto, (max-width: 692px) 100vw, 692px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8edocker\u914d\u7f6esystemd\u9a71\u52a8\uff0c\u9700\u8981\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\/etc\/docker\/daemon.json\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"698\" height=\"171\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/09\/6-7.png\" alt=\"\" class=\"wp-image-14990\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/09\/6-7.png 698w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/09\/6-7-300x73.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/09\/6-7-600x147.png 600w\" sizes=\"auto, (max-width: 698px) 100vw, 698px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5e38\u89c1\u7684\u4f7f\u7528systemd\u6765\u521d\u59cb\u5316\u7684\u7cfb\u7edf\u6709\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>centos7\u4ee5\u540e\uff0ccentos6\u4f7f\u7528\u7684init<\/li>\n\n\n\n<li>ubuntu<\/li>\n\n\n\n<li>Debian<\/li>\n\n\n\n<li>Fedora<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Linux \u4e0a\uff0c\u63a7\u5236\u7ec4\uff08CGroup\uff09\u7528\u4e8e\u9650\u5236\u5206\u914d\u7ed9\u8fdb\u7a0b\u7684\u8d44\u6e90 kubelet\u00a0\u548c\u5e95\u5c42\u5bb9\u5668\u8fd0\u884c\u65f6\u90fd\u9700\u8981\u5bf9\u63a5 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":14983,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,22],"tags":[],"class_list":["post-14982","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-server"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/14982","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/comments?post=14982"}],"version-history":[{"count":8,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/14982\/revisions"}],"predecessor-version":[{"id":14993,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/14982\/revisions\/14993"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media\/14983"}],"wp:attachment":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media?parent=14982"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/categories?post=14982"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/tags?post=14982"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}