{"id":84915,"date":"2026-07-26T20:41:54","date_gmt":"2026-07-26T12:41:54","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/84915.html"},"modified":"2026-07-26T20:41:54","modified_gmt":"2026-07-26T12:41:54","slug":"kubernetes%e5%b8%b8%e7%94%a8%e6%93%8d%e4%bd%9c%e4%b8%8e%e6%a6%82%e5%bf%b5%e6%80%bb%e7%bb%93-%e4%bb%8e%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%af%bc%e5%87%bamongo%e6%95%b0%e6%8d%ae%ef%bc%8c%e5%b9%b6%e4%b8%8b","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/84915.html","title":{"rendered":"Kubernetes\u5e38\u7528\u64cd\u4f5c\u4e0e\u6982\u5ff5\u603b\u7ed3--\u4ece\u670d\u52a1\u5668\u5bfc\u51famongo\u6570\u636e\uff0c\u5e76\u4e0b\u8f7d\u5230\u672c\u5730"},"content":{"rendered":"<h2>Kubernetes \u5e38\u7528\u64cd\u4f5c\u4e0e\u6982\u5ff5\u603b\u7ed3<\/h2>\n<p>\u672c\u6587\u603b\u7ed3 K8s \u65e5\u5e38\u8fd0\u7ef4\u4e2d\u7684\u5e38\u89c1\u6982\u5ff5\u3001\u547d\u4ee4\u548c\u6392\u9519\u601d\u8def&#xff0c;\u9002\u5408\u5feb\u901f\u67e5\u9605\u3002<\/p>\n<hr \/>\n<h3>&#x1f4d1; \u76ee\u5f55<\/h3>\n<ul>\n<li>\u4e00\u3001\u6838\u5fc3\u6982\u5ff5&#xff1a;Pod \u4e0e Container<\/li>\n<li>\u4e8c\u3001\u8d44\u6e90\u547d\u540d\u89c4\u5219<\/li>\n<li>\u4e09\u3001\u4fee\u6539 Pod \u8d44\u6e90\u914d\u7f6e<\/li>\n<li>\u56db\u3001\u547d\u540d\u7a7a\u95f4&#xff08;Namespace&#xff09;<\/li>\n<li>\u4e94\u3001\u7f16\u8f91\u8d44\u6e90\u540e\u7684\u4fdd\u5b58\u4e0e\u751f\u6548<\/li>\n<li>\u516d\u3001MongoDB \u6570\u636e\u5bfc\u51fa&#xff08;mongodump&#xff09;<\/li>\n<li>\u4e03\u3001\u4ece Pod \u4e2d\u62f7\u8d1d\u6570\u636e\u5230\u672c\u5730<\/li>\n<li>\u516b\u3001\u7f51\u7edc\u8fde\u901a\u6027\u68c0\u67e5<\/li>\n<li>\u4e5d\u3001\u5e38\u89c1\u9519\u8bef\u4e0e\u6392\u9519<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e00\u3001\u6838\u5fc3\u6982\u5ff5&#xff1a;Pod \u4e0e Container<\/h3>\n<table>\n<tr>\u6982\u5ff5\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>Pod&#xff08;\u5bb9\u5668\u7ec4&#xff09;<\/td>\n<td>K8s \u6700\u5c0f\u8c03\u5ea6\u5355\u4f4d&#xff0c;\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u5bb9\u5668<\/td>\n<\/tr>\n<tr>\n<td>Container&#xff08;\u5bb9\u5668&#xff09;<\/td>\n<td>\u5b9e\u9645\u8fd0\u884c\u8fdb\u7a0b\u7684\u5355\u5143&#xff0c;\u5b9a\u4e49\u5728 Pod \u5185<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li>Pod \u540d&#xff1a;\u5982 my-app-abc123-xyz99<\/li>\n<li>\u4e00\u4e2a Pod \u53ef\u4ee5\u6709\u591a\u4e2a\u5bb9\u5668&#xff08;\u5982 1\/2 READY \u8868\u793a 2 \u4e2a\u5bb9\u5668\u4e2d\u6709 1 \u4e2a\u5c31\u7eea&#xff09;<\/li>\n<li>resources&#xff08;CPU\u3001\u5185\u5b58&#xff09;\u914d\u7f6e\u5728\u5bb9\u5668\u4e0a&#xff0c;\u800c\u4e0d\u662f Pod \u4e0a<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e8c\u3001\u8d44\u6e90\u547d\u540d\u89c4\u5219<\/h3>\n<h4>Pod \u547d\u540d\u683c\u5f0f<\/h4>\n<p>&lt;Deployment\u540d&gt;-&lt;ReplicaSet\u54c8\u5e0c&gt;-&lt;Pod\u540e\u7f00&gt;<\/p>\n<p>\u793a\u4f8b&#xff1a;my-app-abc123-xyz99<\/p>\n<table>\n<tr>\u90e8\u5206\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td>my-app<\/td>\n<td>Deployment \u540d\u79f0<\/td>\n<\/tr>\n<tr>\n<td>abc123<\/td>\n<td>ReplicaSet \u7684\u54c8\u5e0c\u503c<\/td>\n<\/tr>\n<tr>\n<td>xyz99<\/td>\n<td>\u8be5 Pod \u7684\u552f\u4e00\u540e\u7f00<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u6613\u9519\u70b9<\/h4>\n<ul>\n<li>\u7f16\u8f91 Deployment \u65f6\u7528&#xff1a;kubectl edit deployment &lt;Deployment\u540d&gt;<\/li>\n<li>\u4e0d\u8981\u7528 Pod \u5168\u540d&#xff1a;kubectl edit deployment my-app-abc123-xyz99 \u274c&#xff08;\u4f1a\u62a5 NotFound&#xff09;<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e09\u3001\u4fee\u6539 Pod \u8d44\u6e90\u914d\u7f6e<\/h3>\n<h4>1. \u7f16\u8f91 Deployment&#xff08;\u63a8\u8350&#xff09;<\/h4>\n<p>\u8d44\u6e90\u914d\u7f6e\u5199\u5728 Deployment \u7684 Pod \u6a21\u677f\u4e2d&#xff0c;\u4fee\u6539 Deployment \u624d\u80fd\u6301\u4e45\u751f\u6548&#xff1a;<\/p>\n<p>kubectl edit deployment <span class=\"token operator\">&lt;<\/span>Deployment\u540d<span class=\"token operator\">&gt;<\/span> -n <span class=\"token operator\">&lt;<\/span>\u547d\u540d\u7a7a\u95f4<span class=\"token operator\">&gt;<\/span><\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p>kubectl edit deployment my-app -n default<\/p>\n<h4>2. \u8d44\u6e90\u914d\u7f6e\u7ed3\u6784<\/h4>\n<p><span class=\"token key atrule\">resources<\/span><span class=\"token punctuation\">:<\/span><br \/>\n  <span class=\"token key atrule\">limits<\/span><span class=\"token punctuation\">:<\/span>      <span class=\"token comment\"># \u6700\u5927\u53ef\u4f7f\u7528\u8d44\u6e90<\/span><br \/>\n    <span class=\"token key atrule\">cpu<\/span><span class=\"token punctuation\">:<\/span> 100m<br \/>\n    <span class=\"token key atrule\">memory<\/span><span class=\"token punctuation\">:<\/span> 100Mi<br \/>\n  <span class=\"token key atrule\">requests<\/span><span class=\"token punctuation\">:<\/span>    <span class=\"token comment\"># \u8c03\u5ea6\u65f6\u7533\u8bf7\u7684\u4fdd\u8bc1\u8d44\u6e90<\/span><br \/>\n    <span class=\"token key atrule\">cpu<\/span><span class=\"token punctuation\">:<\/span> 20m<br \/>\n    <span class=\"token key atrule\">memory<\/span><span class=\"token punctuation\">:<\/span> 40Mi<\/p>\n<h4>3. \u5e38\u7528\u5355\u4f4d<\/h4>\n<table>\n<tr>\u5355\u4f4d\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td>m<\/td>\n<td>\u6beb\u6838&#xff0c;1000m &#061; 1 \u6838 CPU<\/td>\n<\/tr>\n<tr>\n<td>Mi<\/td>\n<td>Mebibytes&#xff08;1024 \u8fdb\u5236&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>Gi<\/td>\n<td>Gibibytes<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>4. \u8d44\u6e90\u7ffb\u500d\u793a\u4f8b<\/h4>\n<table>\n<tr>\u914d\u7f6e\u9879\u539f\u503c\u7ffb\u500d\u540e<\/tr>\n<tbody>\n<tr>\n<td>limits.cpu<\/td>\n<td>50m<\/td>\n<td>100m<\/td>\n<\/tr>\n<tr>\n<td>limits.memory<\/td>\n<td>50Mi<\/td>\n<td>100Mi<\/td>\n<\/tr>\n<tr>\n<td>requests.cpu<\/td>\n<td>10m<\/td>\n<td>20m<\/td>\n<\/tr>\n<tr>\n<td>requests.memory<\/td>\n<td>20Mi<\/td>\n<td>40Mi<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u56db\u3001\u547d\u540d\u7a7a\u95f4&#xff08;Namespace&#xff09;<\/h3>\n<ul>\n<li>kubectl \u9ed8\u8ba4\u64cd\u4f5c default \u547d\u540d\u7a7a\u95f4<\/li>\n<li>\u5176\u4ed6\u547d\u540d\u7a7a\u95f4\u9700\u7528 -n &lt;namespace&gt; \u6307\u5b9a<\/li>\n<li>\u8de8\u547d\u540d\u7a7a\u95f4\u65f6&#xff0c;\u4e0d\u52a0 -n \u4f1a\u62a5 NotFound<\/li>\n<\/ul>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u6307\u5b9a\u547d\u540d\u7a7a\u95f4<\/span><br \/>\nkubectl get pod -n default<\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u6240\u6709\u547d\u540d\u7a7a\u95f4<\/span><br \/>\nkubectl get pod -A<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u7f16\u8f91\u8d44\u6e90\u540e\u7684\u4fdd\u5b58\u4e0e\u751f\u6548<\/h3>\n<h4>1. \u4f7f\u7528 vim\/vi \u7f16\u8f91\u65f6<\/h4>\n<p>kubectl edit \u4f1a\u6253\u5f00 vim\/vi&#xff1a;<\/p>\n<table>\n<tr>\u64cd\u4f5c\u547d\u4ee4<\/tr>\n<tbody>\n<tr>\n<td>\u4fdd\u5b58\u5e76\u9000\u51fa<\/td>\n<td>Esc \u2192 :wq \u2192 \u56de\u8f66<\/td>\n<\/tr>\n<tr>\n<td>\u4e0d\u4fdd\u5b58\u5f3a\u5236\u9000\u51fa<\/td>\n<td>Esc \u2192 :q! \u2192 \u56de\u8f66<\/td>\n<\/tr>\n<tr>\n<td>\u53ea\u4fdd\u5b58\u4e0d\u9000\u51fa<\/td>\n<td>Esc \u2192 :w \u2192 \u56de\u8f66<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>2. \u4f7f\u4fee\u6539\u751f\u6548<\/h4>\n<p>\u4fee\u6539 Deployment \u540e&#xff0c;\u9700\u8981\u89e6\u53d1 Pod \u91cd\u5efa&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u65b9\u5f0f\u4e00&#xff1a;\u6eda\u52a8\u91cd\u542f&#xff08;\u63a8\u8350&#xff09;<\/span><br \/>\nkubectl rollout restart deployment\/my-app -n default<\/p>\n<p><span class=\"token comment\"># \u65b9\u5f0f\u4e8c&#xff1a;\u5220\u9664 Pod&#xff0c;\u7531 Deployment \u81ea\u52a8\u91cd\u5efa<\/span><br \/>\nkubectl delete pod my-app-abc123-xyz99 -n default<\/p>\n<hr \/>\n<h3>\u516d\u3001MongoDB \u6570\u636e\u5bfc\u51fa&#xff08;mongodump&#xff09;<\/h3>\n<h4>1. \u5bfc\u51fa\u6307\u5b9a\u6570\u636e\u5e93<\/h4>\n<p>mongodump &#8211;uri <span class=\"token string\">&#039;mongodb:\/\/user:password&#064;&lt;host&gt;:&lt;port&gt;\/&lt;\u6570\u636e\u5e93\u540d&gt;?authSource&#061;admin&#039;<\/span> <span class=\"token punctuation\">\\\\<\/span><br \/>\n  &#8211;out \/tmp\/backup\/<span class=\"token operator\">&lt;<\/span>\u6570\u636e\u5e93\u540d<span class=\"token operator\">&gt;<\/span>_backup <span class=\"token punctuation\">\\\\<\/span><br \/>\n  &#8211;forceTableScan<\/p>\n<h4>2. \u5bfc\u51fa\u6240\u6709\u6570\u636e\u5e93<\/h4>\n<p>mongodump &#8211;uri <span class=\"token string\">&#039;mongodb:\/\/user:password&#064;&lt;host&gt;:&lt;port&gt;\/?authSource&#061;admin&#039;<\/span> <span class=\"token punctuation\">\\\\<\/span><br \/>\n  &#8211;out \/tmp\/backup\/mongo_full_backup <span class=\"token punctuation\">\\\\<\/span><br \/>\n  &#8211;forceTableScan<\/p>\n<h4>3. \u53c2\u6570\u8bf4\u660e<\/h4>\n<table>\n<tr>\u53c2\u6570\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td>&#8211;uri<\/td>\n<td>MongoDB \u8fde\u63a5\u5b57\u7b26\u4e32&#xff08;\u7528\u6237\u540d\u3001\u5bc6\u7801\u3001\u4e3b\u673a\u3001\u7aef\u53e3\u3001\u8ba4\u8bc1\u5e93&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>&#8211;out<\/td>\n<td>\u5bfc\u51fa\u6587\u4ef6\u4fdd\u5b58\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td>&#8211;forceTableScan<\/td>\n<td>\u5f3a\u5236\u4f7f\u7528\u8868\u626b\u63cf&#xff08;\u5f53\u7d22\u5f15\u4e0d\u53ef\u7528\u65f6\u4f7f\u7528&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>4. \u526f\u672c\u96c6\u8fde\u63a5\u793a\u4f8b<\/h4>\n<p>mongodump &#8211;uri <span class=\"token string\">&#039;mongodb:\/\/user:password&#064;&lt;host1&gt;:&lt;port&gt;,&lt;host2&gt;:&lt;port&gt;\/&lt;\u6570\u636e\u5e93\u540d&gt;?authSource&#061;admin&amp;replicaSet&#061;&lt;\u526f\u672c\u96c6\u540d&gt;&#039;<\/span> <span class=\"token punctuation\">\\\\<\/span><br \/>\n  &#8211;out \/tmp\/backup\/mongo_backup <span class=\"token punctuation\">\\\\<\/span><br \/>\n  &#8211;forceTableScan<\/p>\n<h4>5. \u6ce8\u610f\u4e8b\u9879<\/h4>\n<ul>\n<li>\u82e5\u5bfc\u51fa\u8fc7\u7a0b\u4e2d\u51fa\u73b0 Killed&#xff0c;\u591a\u4e3a\u5185\u5b58\u4e0d\u8db3&#xff0c;\u53ef\u8c03\u5927 Pod \u8d44\u6e90\u6216\u6309\u5e93\u5206\u522b\u5bfc\u51fa<\/li>\n<li>\u5bfc\u51fa\u6570\u636e\u4f4d\u4e8e\u5bb9\u5668\u5185\u7684\u6307\u5b9a\u8def\u5f84&#xff0c;\u9700\u901a\u8fc7 kubectl exec \u6216 kubectl cp \u62f7\u8d1d\u5230\u672c\u5730&#xff08;\u89c1\u4e0b\u4e00\u8282&#xff09;<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e03\u3001\u4ece Pod \u4e2d\u62f7\u8d1d\u6570\u636e\u5230\u672c\u5730<\/h3>\n<h4>\u91cd\u8981\u6982\u5ff5<\/h4>\n<ul>\n<li>Pod \u5185\u7684 \/tmp \u7b49\u8def\u5f84\u5c5e\u4e8e\u5bb9\u5668\u5185\u90e8\u6587\u4ef6\u7cfb\u7edf<\/li>\n<li>\u5728\u5bbf\u4e3b\u673a\u6216\u8df3\u677f\u673a\u4e0a\u76f4\u63a5\u6d4f\u89c8&#xff0c;\u770b\u4e0d\u5230\u5bb9\u5668\u5185\u7684\u8fd9\u4e9b\u76ee\u5f55<\/li>\n<li>\u5fc5\u987b\u901a\u8fc7 kubectl exec \u6216 kubectl cp \u8bbf\u95ee<\/li>\n<\/ul>\n<h4>\u5b8c\u6574\u64cd\u4f5c\u6d41\u7a0b\u793a\u4f8b<\/h4>\n<p>\u5728\u80fd\u6267\u884c kubectl \u7684\u73af\u5883&#xff08;\u672c\u5730\u6216\u8df3\u677f\u673a&#xff09;\u4f9d\u6b21\u6267\u884c&#xff1a;<\/p>\n<p><span class=\"token comment\"># 1. \u67e5\u770b Pod \u540d<\/span><br \/>\nkubectl get pod -n default -l <span class=\"token assign-left variable\">app<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token operator\">&lt;<\/span>app\u540d<span class=\"token operator\">&gt;<\/span><\/p>\n<p><span class=\"token comment\"># 2. \u4ece Pod \u91cc\u6253\u5305\u5e76\u4fdd\u5b58\u5230\u672c\u673a&#xff08;\u628a &lt;Pod\u540d&gt; \u6362\u6210\u4e0a\u4e00\u6b65\u5f97\u5230\u7684\u540d\u5b57&#xff09;<\/span><br \/>\nkubectl <span class=\"token builtin class-name\">exec<\/span> -n default <span class=\"token operator\">&lt;<\/span>Pod\u540d<span class=\"token operator\">&gt;<\/span> &#8212; <span class=\"token function\">tar<\/span> czf &#8211; -C \/tmp\/backup data <span class=\"token operator\">&gt;<\/span> \/root\/backup.tar.gz<\/p>\n<p><span class=\"token comment\"># 3. \u68c0\u67e5\u6587\u4ef6<\/span><br \/>\n<span class=\"token function\">ls<\/span> -lh \/root\/backup.tar.gz<\/p>\n<h4>\u65b9\u6cd5\u4e00&#xff1a;\u6d41\u5f0f\u6253\u5305\u5e76\u4e0b\u8f7d&#xff08;\u63a8\u8350&#xff09;<\/h4>\n<p>\u5728\u80fd\u6267\u884c kubectl \u7684\u7ec8\u7aef\u8fd0\u884c&#xff1a;<\/p>\n<p>kubectl <span class=\"token builtin class-name\">exec<\/span> -n default <span class=\"token operator\">&lt;<\/span>Pod\u540d<span class=\"token operator\">&gt;<\/span> &#8212; <span class=\"token function\">tar<\/span> czf &#8211; -C \/tmp\/backup data <span class=\"token operator\">&gt;<\/span> .\/backup.tar.gz<\/p>\n<ul>\n<li>tar czf -&#xff1a;\u5728 Pod \u5185\u6253\u5305\u5e76\u8f93\u51fa\u5230 stdout<\/li>\n<li>&gt; .\/backup.tar.gz&#xff1a;\u5728\u672c\u5730\u63a5\u6536\u5e76\u4fdd\u5b58<\/li>\n<\/ul>\n<h4>\u65b9\u6cd5\u4e8c&#xff1a;\u5206\u6b65\u62f7\u8d1d<\/h4>\n<p><span class=\"token comment\"># 1. \u5728 Pod \u5185\u6253\u5305<\/span><br \/>\nkubectl <span class=\"token builtin class-name\">exec<\/span> -n default <span class=\"token operator\">&lt;<\/span>Pod\u540d<span class=\"token operator\">&gt;<\/span> &#8212; <span class=\"token function\">tar<\/span> czf \/tmp\/backup.tar.gz -C \/tmp\/backup data<\/p>\n<p><span class=\"token comment\"># 2. \u62f7\u8d1d\u5230\u672c\u5730<\/span><br \/>\nkubectl <span class=\"token function\">cp<\/span> default\/<span class=\"token operator\">&lt;<\/span>Pod\u540d<span class=\"token operator\">&gt;<\/span>:\/tmp\/backup.tar.gz .\/backup.tar.gz<\/p>\n<p><span class=\"token comment\"># 3. \u89e3\u538b<\/span><br \/>\n<span class=\"token function\">tar<\/span> xzf backup.tar.gz<\/p>\n<h4>\u901a\u8fc7\u8df3\u677f\u673a<\/h4>\n<p>\u82e5\u672c\u5730&#xff08;\u6c99\u7bb1&#xff09;\u65e0\u6cd5\u76f4\u63a5\u8bbf\u95ee\u96c6\u7fa4&#xff0c;\u9700\u5148 SSH \u5230\u8df3\u677f\u673a&#xff1a;<\/p>\n<p><span class=\"token comment\"># 1. SSH \u5230\u8df3\u677f\u673a<\/span><br \/>\n<span class=\"token function\">ssh<\/span> root&#064;192.168.1.100<\/p>\n<p><span class=\"token comment\"># 2. \u5728\u8df3\u677f\u673a\u4e0a\u6267\u884c kubectl \u6253\u5305\u5e76\u4fdd\u5b58<\/span><br \/>\nkubectl <span class=\"token builtin class-name\">exec<\/span> -n default <span class=\"token operator\">&lt;<\/span>Pod\u540d<span class=\"token operator\">&gt;<\/span> &#8212; <span class=\"token function\">tar<\/span> czf &#8211; -C \/tmp\/backup data <span class=\"token operator\">&gt;<\/span> \/root\/backup.tar.gz<\/p>\n<p><span class=\"token comment\"># 3. \u5728\u672c\u5730\u4ece\u8df3\u677f\u673a\u62c9\u53d6<\/span><br \/>\n<span class=\"token function\">scp<\/span> root&#064;192.168.1.100:\/root\/backup.tar.gz .\/<\/p>\n<hr \/>\n<h3>\u516b\u3001\u7f51\u7edc\u8fde\u901a\u6027\u68c0\u67e5<\/h3>\n<h4>1. ping&#xff08;ICMP&#xff09;<\/h4>\n<p><span class=\"token function\">ping<\/span> -c <span class=\"token number\">4<\/span> <span class=\"token number\">192.168<\/span>.1.100<\/p>\n<ul>\n<li>\u80fd\u6536\u5230\u56de\u590d&#xff1a;\u7f51\u7edc\u53ef\u8fbe<\/li>\n<li>\u65e0\u54cd\u5e94&#xff1a;\u53ef\u80fd\u88ab\u9632\u706b\u5899\u7981\u6b62\u6216\u7f51\u7edc\u4e0d\u901a&#xff08;ping \u5e38\u88ab\u4f01\u4e1a\u7f51\u7edc\u7981\u7528&#xff09;<\/li>\n<\/ul>\n<h4>2. \u7aef\u53e3\u8fde\u901a\u6027&#xff08;nc&#xff09;<\/h4>\n<p><span class=\"token function\">nc<\/span> -zv <span class=\"token number\">192.168<\/span>.1.100 <span class=\"token number\">22<\/span><\/p>\n<ul>\n<li>succeeded \/ open&#xff1a;\u7aef\u53e3\u53ef\u8fbe<\/li>\n<li>Connection refused&#xff1a;\u4e3b\u673a\u53ef\u8fbe&#xff0c;\u7aef\u53e3\u672a\u5f00\u653e<\/li>\n<li>Connection timed out&#xff1a;\u7f51\u7edc\u4e0d\u901a\u6216\u9632\u706b\u5899\u62e6\u622a<\/li>\n<\/ul>\n<h4>3. kubectl \u8fde\u901a\u6027<\/h4>\n<p><span class=\"token comment\"># \u6d4b\u8bd5\u80fd\u5426\u8bbf\u95ee K8s API&#xff08;\u66ff\u6362\u4e3a\u5b9e\u9645 API \u5730\u5740&#xff09;<\/span><br \/>\n<span class=\"token function\">nc<\/span> -zv <span class=\"token number\">192.168<\/span>.1.10 <span class=\"token number\">6443<\/span><\/p>\n<p>\u82e5 kubectl \u62a5 Unable to connect to the server&#xff0c;\u8bf4\u660e\u5f53\u524d\u73af\u5883\u65e0\u6cd5\u8bbf\u95ee\u96c6\u7fa4 API&#xff0c;\u9700\u901a\u8fc7 VPN \u6216\u8df3\u677f\u673a\u3002<\/p>\n<hr \/>\n<h3>\u4e5d\u3001\u5e38\u89c1\u9519\u8bef\u4e0e\u6392\u9519<\/h3>\n<h4>1. deployments.apps &#034;xxx&#034; not found<\/h4>\n<table>\n<tr>\u539f\u56e0\u5904\u7406<\/tr>\n<tbody>\n<tr>\n<td>\u7528\u4e86 Pod \u540d\u800c\u4e0d\u662f Deployment \u540d<\/td>\n<td>\u4f7f\u7528 kubectl edit deployment &lt;Deployment\u540d&gt;<\/td>\n<\/tr>\n<tr>\n<td>\u547d\u540d\u7a7a\u95f4\u4e0d\u5bf9<\/td>\n<td>\u52a0\u4e0a -n &lt;namespace&gt;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>2. Unable to connect to the server: dial tcp xxx:6443: connect: invalid argument<\/h4>\n<ul>\n<li>\u5f53\u524d\u73af\u5883\u65e0\u6cd5\u8bbf\u95ee K8s API \u670d\u52a1\u5668<\/li>\n<li>\u5904\u7406&#xff1a;\u68c0\u67e5 VPN\u3001\u7f51\u7edc&#xff0c;\u6216\u901a\u8fc7\u8df3\u677f\u673a\u6267\u884c kubectl<\/li>\n<\/ul>\n<h4>3. \u4fee\u6539\u8d44\u6e90\u914d\u7f6e\u540e\u4e0d\u751f\u6548<\/h4>\n<ul>\n<li>\u76f4\u63a5\u7f16\u8f91 Pod \u7684\u4fee\u6539\u53ef\u80fd\u5728 Pod \u91cd\u5efa\u65f6\u88ab\u8986\u76d6<\/li>\n<li>\u5904\u7406&#xff1a;\u7f16\u8f91 Deployment&#xff0c;\u7136\u540e\u6267\u884c kubectl rollout restart deployment\/xxx<\/li>\n<\/ul>\n<h4>4. \u5728\u5bbf\u4e3b\u673a\/\u8df3\u677f\u673a\u627e\u4e0d\u5230 Pod \u5185\u7684\u6587\u4ef6<\/h4>\n<ul>\n<li>\u5bb9\u5668\u6709\u72ec\u7acb\u6587\u4ef6\u7cfb\u7edf&#xff0c;\u5bbf\u4e3b\u673a\u4e0a\u65e0\u6cd5\u76f4\u63a5\u6d4f\u89c8<\/li>\n<li>\u5904\u7406&#xff1a;\u4f7f\u7528 kubectl exec \u6216 kubectl cp \u4ece Pod \u62f7\u8d1d\u6570\u636e<\/li>\n<\/ul>\n<hr \/>\n<h3>\u603b\u7ed3<\/h3>\n<table>\n<tr>\u573a\u666f\u5e38\u7528\u547d\u4ee4<\/tr>\n<tbody>\n<tr>\n<td>\u4fee\u6539 Pod \u8d44\u6e90<\/td>\n<td>kubectl edit deployment &lt;\u540d&gt; -n &lt;ns&gt; \u2192 :wq \u2192 kubectl rollout restart<\/td>\n<\/tr>\n<tr>\n<td>\u67e5\u770b Pod<\/td>\n<td>kubectl get pod -n &lt;ns&gt; -l app&#061;&lt;app\u540d&gt;<\/td>\n<\/tr>\n<tr>\n<td>MongoDB \u5bfc\u51fa<\/td>\n<td>mongodump &#8211;uri &#039;&#8230;&#039; &#8211;out \/tmp\/backup &#8211;forceTableScan<\/td>\n<\/tr>\n<tr>\n<td>\u4ece Pod \u62f7\u6570\u636e<\/td>\n<td>kubectl exec &#8230; tar &#8230; &gt; \u672c\u5730\u6587\u4ef6 \u6216 kubectl cp<\/td>\n<\/tr>\n<tr>\n<td>\u68c0\u67e5\u7f51\u7edc<\/td>\n<td>ping\u3001nc -zv<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<p>\u6807\u7b7e&#xff1a;Kubernetes\u3001kubectl\u3001Pod\u3001Deployment\u3001MongoDB\u3001mongodump\u3001\u8d44\u6e90\u914d\u7f6e\u3001\u8fd0\u7ef4<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kubernetes \u5e38\u7528\u64cd\u4f5c\u4e0e\u6982\u5ff5\u603b\u7ed3 \u672c\u6587\u603b\u7ed3 K8s \u65e5\u5e38\u8fd0\u7ef4\u4e2d\u7684\u5e38\u89c1\u6982\u5ff5\u3001\u547d\u4ee4\u548c\u6392\u9519\u601d\u8def&#xff0c;\u9002\u5408\u5feb\u901f\u67e5\u9605\u3002 &#x1f4d1; \u76ee\u5f55<br \/>\n\u4e00\u3001\u6838\u5fc3\u6982\u5ff5&#xff1a;Pod \u4e0e Container\u4e8c\u3001\u8d44\u6e90\u547d\u540d\u89c4\u5219\u4e09\u3001\u4fee\u6539 Pod \u8d44\u6e90\u914d\u7f6e\u56db\u3001\u547d\u540d\u7a7a\u95f4&#xff08;Namespace&#xff09;\u4e94\u3001\u7f16\u8f91\u8d44\u6e90\u540e\u7684\u4fdd\u5b58\u4e0e\u751f\u6548\u516d\u3001MongoDB \u6570\u636e\u5bfc\u51fa&#xff08;mongodump&#xff09;\u4e03\u3001\u4ece Pod \u4e2d\u62f7\u8d1d\u6570\u636e\u5230\u672c\u5730\u516b\u3001\u7f51\u7edc\u8fde\u901a\u6027\u68c0\u67e5\u4e5d\u3001\u5e38\u89c1<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[120,121,43],"topic":[],"class_list":["post-84915","post","type-post","status-publish","format-standard","hentry","category-server","tag-kubernetes","tag-121","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Kubernetes\u5e38\u7528\u64cd\u4f5c\u4e0e\u6982\u5ff5\u603b\u7ed3-\u4ece\u670d\u52a1\u5668\u5bfc\u51famongo\u6570\u636e\uff0c\u5e76\u4e0b\u8f7d\u5230\u672c\u5730 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/84915.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Kubernetes\u5e38\u7528\u64cd\u4f5c\u4e0e\u6982\u5ff5\u603b\u7ed3-\u4ece\u670d\u52a1\u5668\u5bfc\u51famongo\u6570\u636e\uff0c\u5e76\u4e0b\u8f7d\u5230\u672c\u5730 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Kubernetes \u5e38\u7528\u64cd\u4f5c\u4e0e\u6982\u5ff5\u603b\u7ed3 \u672c\u6587\u603b\u7ed3 K8s \u65e5\u5e38\u8fd0\u7ef4\u4e2d\u7684\u5e38\u89c1\u6982\u5ff5\u3001\u547d\u4ee4\u548c\u6392\u9519\u601d\u8def&#xff0c;\u9002\u5408\u5feb\u901f\u67e5\u9605\u3002 &#x1f4d1; \u76ee\u5f55 \u4e00\u3001\u6838\u5fc3\u6982\u5ff5&#xff1a;Pod \u4e0e Container\u4e8c\u3001\u8d44\u6e90\u547d\u540d\u89c4\u5219\u4e09\u3001\u4fee\u6539 Pod \u8d44\u6e90\u914d\u7f6e\u56db\u3001\u547d\u540d\u7a7a\u95f4&#xff08;Namespace&#xff09;\u4e94\u3001\u7f16\u8f91\u8d44\u6e90\u540e\u7684\u4fdd\u5b58\u4e0e\u751f\u6548\u516d\u3001MongoDB \u6570\u636e\u5bfc\u51fa&#xff08;mongodump&#xff09;\u4e03\u3001\u4ece Pod \u4e2d\u62f7\u8d1d\u6570\u636e\u5230\u672c\u5730\u516b\u3001\u7f51\u7edc\u8fde\u901a\u6027\u68c0\u67e5\u4e5d\u3001\u5e38\u89c1\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/84915.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-26T12:41:54+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/84915.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/84915.html\",\"name\":\"Kubernetes\u5e38\u7528\u64cd\u4f5c\u4e0e\u6982\u5ff5\u603b\u7ed3-\u4ece\u670d\u52a1\u5668\u5bfc\u51famongo\u6570\u636e\uff0c\u5e76\u4e0b\u8f7d\u5230\u672c\u5730 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-26T12:41:54+00:00\",\"dateModified\":\"2026-07-26T12:41:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/84915.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/84915.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/84915.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Kubernetes\u5e38\u7528\u64cd\u4f5c\u4e0e\u6982\u5ff5\u603b\u7ed3--\u4ece\u670d\u52a1\u5668\u5bfc\u51famongo\u6570\u636e\uff0c\u5e76\u4e0b\u8f7d\u5230\u672c\u5730\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Kubernetes\u5e38\u7528\u64cd\u4f5c\u4e0e\u6982\u5ff5\u603b\u7ed3-\u4ece\u670d\u52a1\u5668\u5bfc\u51famongo\u6570\u636e\uff0c\u5e76\u4e0b\u8f7d\u5230\u672c\u5730 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/84915.html","og_locale":"zh_CN","og_type":"article","og_title":"Kubernetes\u5e38\u7528\u64cd\u4f5c\u4e0e\u6982\u5ff5\u603b\u7ed3-\u4ece\u670d\u52a1\u5668\u5bfc\u51famongo\u6570\u636e\uff0c\u5e76\u4e0b\u8f7d\u5230\u672c\u5730 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Kubernetes \u5e38\u7528\u64cd\u4f5c\u4e0e\u6982\u5ff5\u603b\u7ed3 \u672c\u6587\u603b\u7ed3 K8s \u65e5\u5e38\u8fd0\u7ef4\u4e2d\u7684\u5e38\u89c1\u6982\u5ff5\u3001\u547d\u4ee4\u548c\u6392\u9519\u601d\u8def&#xff0c;\u9002\u5408\u5feb\u901f\u67e5\u9605\u3002 &#x1f4d1; \u76ee\u5f55 \u4e00\u3001\u6838\u5fc3\u6982\u5ff5&#xff1a;Pod \u4e0e Container\u4e8c\u3001\u8d44\u6e90\u547d\u540d\u89c4\u5219\u4e09\u3001\u4fee\u6539 Pod \u8d44\u6e90\u914d\u7f6e\u56db\u3001\u547d\u540d\u7a7a\u95f4&#xff08;Namespace&#xff09;\u4e94\u3001\u7f16\u8f91\u8d44\u6e90\u540e\u7684\u4fdd\u5b58\u4e0e\u751f\u6548\u516d\u3001MongoDB \u6570\u636e\u5bfc\u51fa&#xff08;mongodump&#xff09;\u4e03\u3001\u4ece Pod \u4e2d\u62f7\u8d1d\u6570\u636e\u5230\u672c\u5730\u516b\u3001\u7f51\u7edc\u8fde\u901a\u6027\u68c0\u67e5\u4e5d\u3001\u5e38\u89c1","og_url":"https:\/\/www.wsisp.com\/helps\/84915.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-26T12:41:54+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/84915.html","url":"https:\/\/www.wsisp.com\/helps\/84915.html","name":"Kubernetes\u5e38\u7528\u64cd\u4f5c\u4e0e\u6982\u5ff5\u603b\u7ed3-\u4ece\u670d\u52a1\u5668\u5bfc\u51famongo\u6570\u636e\uff0c\u5e76\u4e0b\u8f7d\u5230\u672c\u5730 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-26T12:41:54+00:00","dateModified":"2026-07-26T12:41:54+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/84915.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/84915.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/84915.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Kubernetes\u5e38\u7528\u64cd\u4f5c\u4e0e\u6982\u5ff5\u603b\u7ed3--\u4ece\u670d\u52a1\u5668\u5bfc\u51famongo\u6570\u636e\uff0c\u5e76\u4e0b\u8f7d\u5230\u672c\u5730"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/84915","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=84915"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/84915\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=84915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=84915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=84915"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=84915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}