{"id":371,"date":"2025-07-27T09:53:27","date_gmt":"2025-07-27T01:53:27","guid":{"rendered":"https:\/\/www.vcidc.net\/blog\/?p=371"},"modified":"2025-07-27T09:53:27","modified_gmt":"2025-07-27T01:53:27","slug":"%e6%b7%b1%e5%85%a5%e4%ba%86%e8%a7%a3k3s%ef%bc%9a%e8%bd%bb%e9%87%8f%e7%ba%a7kubernetes%e5%8f%91%e8%a1%8c%e7%89%88%e7%9a%84%e5%8a%9f%e8%83%bd%e5%92%8c%e4%bc%98%e5%8a%bf","status":"publish","type":"post","link":"https:\/\/www.vcidc.net\/blog\/371.html","title":{"rendered":"\u6df1\u5165\u4e86\u89e3K3s\uff1a\u8f7b\u91cf\u7ea7Kubernetes\u53d1\u884c\u7248\u7684\u529f\u80fd\u548c\u4f18\u52bf"},"content":{"rendered":"<p><h3>\u4ec0\u4e48\u662fK3s\uff1f<\/h3>\n<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.vcidc.net\/blog\/wp-content\/uploads\/2025\/07\/m34G6.jpg\" alt=\"\u6df1\u5165\u4e86\u89e3K3s\uff1a\u8f7b\u91cf\u7ea7Kubernetes\u53d1\u884c\u7248\u7684\u529f\u80fd\u548c\u4f18\u52bf\" title=\"\u6df1\u5165\u4e86\u89e3K3s\uff1a\u8f7b\u91cf\u7ea7Kubernetes\u53d1\u884c\u7248\u7684\u529f\u80fd\u548c\u4f18\u52bf\"><\/p>\n<p><p>K3s \u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684 Kubernetes \u53d1\u884c\u7248\uff0c\u4e13\u4e3a\u8d44\u6e90\u53d7\u9650\u7684\u73af\u5883\u8bbe\u8ba1\uff0c\u5982\u7269\u8054\u7f51\u8bbe\u5907\u3001\u8fb9\u7f18\u8ba1\u7b97\u548c\u5fae\u670d\u52a1\u67b6\u6784\u3002\u5b83\u5305\u542b Kubernetes \u7684\u6838\u5fc3\u529f\u80fd\uff0c\u4f46\u4f53\u79ef\u66f4\u5c0f\uff0c\u6613\u4e8e\u90e8\u7f72\u548c\u7ba1\u7406\u3002<\/p>\n<\/p>\n<p><h3>K3s \u5305\u542b\u54ea\u4e9b\u5185\u5bb9\uff1f<\/h3>\n<\/p>\n<p><p>K3s \u5305\u542b\u4e86 Kubernetes \u7684\u6838\u5fc3\u7ec4\u4ef6\uff0c\u5982 API \u670d\u52a1\u5668\u3001\u63a7\u5236\u5668\u7ba1\u7406\u5668\u3001\u8c03\u5ea6\u5668\u3001etcd\u3001kubelet \u548c\u7f51\u7edc\u63d2\u4ef6\u3002\u5b83\u8fd8\u652f\u6301\u5bb9\u5668\u8fd0\u884c\u65f6\uff0c\u5982 containerd\u3001runc \u548c docker\u3002<\/p>\n<\/p>\n<p><h3>K3s \u5982\u4f55\u5de5\u4f5c\uff1f<\/h3>\n<\/p>\n<p><p>K3s \u901a\u8fc7\u4e00\u4e2a\u5355\u4e8c\u8fdb\u5236\u6587\u4ef6\u63d0\u4f9b Kubernetes \u96c6\u7fa4\u7ba1\u7406\u529f\u80fd\u3002\u5b83\u4f7f\u7528\u5e73\u9762\u6587\u4ef6\u7cfb\u7edf\u800c\u975e\u5206\u5e03\u5f0f\u5b58\u50a8\uff0c\u4f7f\u5f97\u90e8\u7f72\u548c\u7ba1\u7406\u66f4\u52a0\u7b80\u5355\u3002K3s \u8fd8\u652f\u6301\u591a\u79cd\u96c6\u7fa4\u6a21\u5f0f\uff0c\u5305\u62ec\u5355\u8282\u70b9\u3001\u9ad8\u53ef\u7528\u548c\u96c6\u7fa4\u7ba1\u7406\u5668\u6a21\u5f0f\u3002<\/p>\n<\/p>\n<p><h3>\u4e3a\u4ec0\u4e48\u63a8\u8350\u4f7f\u7528K3s\uff1f<\/h3>\n<\/p>\n<p><p>\u63a8\u8350\u4f7f\u7528 K3s \u7684\u539f\u56e0\u6709\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4f53\u79ef\u5c0f\uff1aK3s \u7684\u4f53\u79ef\u4ec5\u4e3a\u4f20\u7edf Kubernetes \u7684 1\/10\uff0c\u975e\u5e38\u9002\u5408\u8d44\u6e90\u53d7\u9650\u7684\u73af\u5883\u3002<\/li>\n<li>\u6613\u4e8e\u90e8\u7f72\uff1aK3s \u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684\u547d\u4ee4\u884c\u53c2\u6570\u8fdb\u884c\u90e8\u7f72\uff0c\u65e0\u9700\u590d\u6742\u7684\u914d\u7f6e\u3002<\/li>\n<li>\u6613\u4e8e\u7ba1\u7406\uff1aK3s \u63d0\u4f9b\u4e86\u6613\u4e8e\u4f7f\u7528\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u7b80\u5316\u4e86\u96c6\u7fa4\u7684\u7ba1\u7406\u548c\u7ef4\u62a4\u3002<\/li>\n<li>\u517c\u5bb9\u6027\uff1aK3s \u5b8c\u5168\u517c\u5bb9 Kubernetes API\uff0c\u53ef\u4ee5\u65e0\u7f1d\u8fc1\u79fb\u73b0\u6709\u7684 Kubernetes \u5e94\u7528\u3002<\/li>\n<\/ul>\n<p><h3>\u5982\u4f55\u5b89\u88c5K3s\uff1f<\/h3>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528 <code>curl<\/code> \u547d\u4ee4\u5b89\u88c5 K3s \u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code>curl -sfL https:\/\/get.k3s.io | sh -<\/p>\r\n<p><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u96c6\u7fa4\u72b6\u6001\uff1a<\/p>\n<\/p>\n<p><pre><code>k3s kubectl get nodes<\/p>\r\n<p><\/pre>\n<\/p>\n<p><h3>\u5982\u4f55\u5347\u7ea7K3s\uff1f<\/h3>\n<\/p>\n<p><p>\u5347\u7ea7 K3s \u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u91cd\u65b0\u8fd0\u884c\u5b89\u88c5\u547d\u4ee4\u5373\u53ef\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u5347\u7ea7 K3s \u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code>curl -sfL https:\/\/get.k3s.io | K3S_URL=https:\/\/your-k3s-server:6443 sh -<\/p>\r\n<p><\/pre>\n<\/p>\n<p><p>\u8bf7\u6ce8\u610f\uff0c\u5728\u5347\u7ea7\u8fc7\u7a0b\u4e2d\uff0c\u96c6\u7fa4\u53ef\u80fd\u4f1a\u77ed\u6682\u4e2d\u65ad\u670d\u52a1\u3002<\/p>\n<\/p>\n<p><h3>\u5982\u4f55\u4f7f\u7528K3s\u90e8\u7f72\u5e94\u7528\uff1f<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528 K3s \u90e8\u7f72\u5e94\u7528\u4e0e\u4f7f\u7528\u4f20\u7edf Kubernetes \u96c6\u7fa4\u7c7b\u4f3c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528 <code>kubectl<\/code> \u547d\u4ee4\u90e8\u7f72 Nginx \u5e94\u7528\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code>kubectl create deployment nginx --image=nginx:latest<\/p>\r\n<p><\/pre>\n<\/p>\n<p><p>\u90e8\u7f72\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u5e94\u7528\u72b6\u6001\uff1a<\/p>\n<\/p>\n<p><pre><code>kubectl get pods<\/p>\r\n<p><\/pre>\n<\/p>\n<p><h3><b>\u5982\u4f55\u786e\u4fddK3s\u96c6\u7fa4\u7684\u5b89\u5168\u6027\uff1f<\/b><\/h3>\n<\/p>\n<p><p>\u786e\u4fdd K3s \u96c6\u7fa4\u7684\u5b89\u5168\u6027\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u63aa\u65bd\u5b9e\u73b0\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528 HTTPS \u8fdb\u884c\u901a\u4fe1\u3002<\/li>\n<li>\u914d\u7f6e\u7f51\u7edc\u7b56\u7565\uff0c\u9650\u5236\u96c6\u7fa4\u5185\u90e8\u548c\u5916\u90e8\u7684\u8bbf\u95ee\u3002<\/li>\n<li>\u5b9a\u671f\u66f4\u65b0 K3s \u548c\u76f8\u5173\u7ec4\u4ef6\u7684\u7248\u672c\u3002<\/li>\n<li>\u4f7f\u7528 RBAC\uff08\u57fa\u4e8e\u89d2\u8272\u7684\u8bbf\u95ee\u63a7\u5236\uff09\u6765\u9650\u5236\u7528\u6237\u6743\u9650\u3002<\/li>\n<\/ul>\n<p><h3><b>K3s \u652f\u6301\u54ea\u4e9b\u7f51\u7edc\u63d2\u4ef6\uff1f<\/b><\/h3>\n<\/p>\n<p><p>K3s \u652f\u6301\u591a\u79cd\u7f51\u7edc\u63d2\u4ef6\uff0c\u5305\u62ec Calico\u3001Flannel \u548c Weave\u3002\u9009\u62e9\u5408\u9002\u7684\u7f51\u7edc\u63d2\u4ef6\u53d6\u51b3\u4e8e\u60a8\u7684\u5177\u4f53\u9700\u6c42\u548c\u96c6\u7fa4\u73af\u5883\u3002<\/p>\n<\/p>\n<p><h3><b>\u5982\u4f55\u5907\u4efd\u548c\u6062\u590dK3s\u96c6\u7fa4\uff1f<\/b><\/h3>\n<\/p>\n<p><p>\u5907\u4efd K3s \u96c6\u7fa4\u53ef\u4ee5\u901a\u8fc7\u5907\u4efd etcd \u6570\u636e\u5e93\u6765\u5b9e\u73b0\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528 <code>etcdctl<\/code> \u547d\u4ee4\u5907\u4efd etcd \u6570\u636e\u5e93\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code>etcdctl backup --data-dir=\/var\/lib\/rancher\/k3s\/data --output=k3s_backup.db<\/p>\r\n<p><\/pre>\n<\/p>\n<p><p>\u6062\u590d K3s \u96c6\u7fa4\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code>etcdctl restore --data-dir=\/var\/lib\/rancher\/k3s\/data --from=k3s_backup.db<\/p>\r\n<p><\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ec0\u4e48\u662fK3s\uff1f K3s \u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684 Kubernetes \u53d1\u884c\u7248\uff0c\u4e13\u4e3a\u8d44\u6e90\u53d7\u9650\u7684\u73af\u5883\u8bbe\u8ba1\uff0c\u5982\u7269\u8054\u7f51\u8bbe\u5907\u3001\u8fb9\u7f18\u8ba1\u7b97\u548c\u5fae\u670d\u52a1\u67b6\u6784\u3002\u5b83\u5305\u542b Kubernetes \u7684\u6838\u5fc3\u529f\u80fd\uff0c\u4f46\u4f53\u79ef\u66f4\u5c0f\uff0c\u6613\u4e8e\u90e8\u7f72\u548c\u7ba1\u7406\u3002 K3s \u5305\u542b\u54ea\u4e9b\u5185\u5bb9\uff1f K3s \u5305\u542b\u4e86&#8230;<\/p>\n","protected":false},"author":1,"featured_media":372,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[184,185,34],"topic":[],"class_list":["post-371","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-game-server","tag-ks","tag-kubernetes","tag-34"],"_links":{"self":[{"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/posts\/371","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/comments?post=371"}],"version-history":[{"count":1,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/posts\/371\/revisions"}],"predecessor-version":[{"id":374,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/posts\/371\/revisions\/374"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/media\/372"}],"wp:attachment":[{"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/media?parent=371"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/categories?post=371"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/tags?post=371"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/topic?post=371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}