{"id":52798,"date":"2025-08-11T19:35:01","date_gmt":"2025-08-11T11:35:01","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/52798.html"},"modified":"2025-08-11T19:35:01","modified_gmt":"2025-08-11T11:35:01","slug":"k8sday03%e6%90%ad%e5%bb%bakubernetes%e9%9b%86%e7%be%a4%ef%bc%882-2%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/52798.html","title":{"rendered":"k8sday03\u642d\u5efakubernetes\u96c6\u7fa4\uff082\/2\uff09"},"content":{"rendered":"<p><span style=\"background-color:#d7d8d9\">\u4eca\u5929\u7ee7\u7eed\u5b8c\u6210k8s\u7684\u96c6\u7fa4\u642d\u5efa&#xff0c;\u6ca1\u770b\u4e0a\u4e00\u7bc7\u7684\u5efa\u8bae\u770b\u770b\u4e0a\u4e00\u7bc7&#xff0c;\u6709\u8d85\u8be6\u7ec6\u7684\u642d\u5efa\u601d\u8def\u54e6~<\/span><\/p>\n<h3>\u521b\u5efa\u591a\u8282\u70b9\u96c6\u7fa4<\/h3>\n<h4>1\u3001\u7f16\u5199kind\u6587\u4ef6<\/h4>\n<h5>\u2460\u6ce8\u610f\u4e8b\u9879&#xff1a;<\/h5>\n<ul>\n<li>\n<p>\u914d\u7f6e\u6587\u4ef6\u7684\u7f16\u5199\u5de5\u5177&#xff1a;\u4efb\u4f55\u6587\u672c\u7f16\u8f91\u5668\u7f16\u5199\u5747\u53ef&#xff0c;eg\u3001Notepad\u3001Vs Code\u7b49\u7b49<\/p>\n<ul>\n<li>\n<p>\u4f7f\u7528\u8bb0\u4e8b\u672c\u7f16\u5199&#xff0c;\u9ed8\u8ba4\u4fdd\u5b58\u4e3a UTF-8 with BOM&#xff0c;\u53ef\u80fd\u5bfc\u81f4 Kind \u65e0\u6cd5\u8bc6\u522b&#xff0c;\u53ea\u9700\u8981\u5728\u4fdd\u5b58\u6587\u4ef6\u7684\u65f6\u5019\u9009\u62e9\u201c\u53e6\u5b58\u4e3a\u201d \u2192 \u7f16\u7801\u9009\u62e9 UTF-8<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u6587\u4ef6\u4fdd\u5b58\u683c\u5f0f&#xff1a;\u5fc5\u987b\u662f YAML \u683c\u5f0f&#xff08;\u540e\u7f00\u4e3a .yaml \u6216 .yml&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u914d\u7f6e\u6587\u4ef6\u4fdd\u5b58\u4f4d\u7f6e&#xff1a;\u4efb\u610f\u76ee\u5f55\u5747\u53ef&#xff08;\u5f53\u7136\u4f60\u8981\u8bb0\u5f97\u4f4f\u5440&#xff0c;\u5f85\u4f1a\u5229\u7528\u914d\u7f6e\u6587\u4ef6\u521b\u5efa\u96c6\u7fa4\u7684\u65f6\u5019\u8981\u7528\u5f97\u7740\u54e6~&#xff09;<\/p>\n<\/li>\n<\/ul>\n<h5>\u2461\u7f16\u5199\u6587\u4ef6\u5e76\u4fdd\u5b58<\/h5>\n<ul>\n<li>\n<p>\u3010\u57fa\u7840\u914d\u7f6e&#xff0c;\u53ea\u4e3a\u642d\u5efa\u6700\u7b80\u5355\u7684\u96c6\u7fa4\u3011\u5728\u4f60\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u5199\u5165&#xff1a;<\/p>\n<\/li>\n<\/ul>\n<p>  kind: Cluster<br \/>\n  apiVersion: kind.x-k8s.io\/v1alpha4<br \/>\n  nodes:<br \/>\n    &#8211; role: control-plane \u00a0# Master \u8282\u70b9<br \/>\n    &#8211; role: worker \u00a0 \u00a0 \u00a0 \u00a0 # Worker \u8282\u70b9 1<br \/>\n    &#8211; role: worker \u00a0 \u00a0 \u00a0 \u00a0 # Worker \u8282\u70b9 2<\/p>\n<ul>\n<li>\n<p>\u3010\u9ad8\u7ea7\u914d\u7f6e&#xff0c;\u5e94\u5bf9\u4f60\u6709\u7279\u522b\u9700\u6c42\u3011\u5982\u6211\u9700\u8981\u6307\u5b9a\u7248\u672c\u6216\u66b4\u9732 Master \u8282\u70b9\u7684\u7aef\u53e3\u7b49\u7b49<\/p>\n<p>\u5728\u4f60\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u5199\u5165&#xff1a;<\/p>\n<\/li>\n<\/ul>\n<p>  kind: Cluster<br \/>\n  apiVersion: kind.x-k8s.io\/v1alpha4<br \/>\n  nodes:<br \/>\n    &#8211; role: control-plane \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# Master \u8282\u70b9<br \/>\n   \u00a0 extraPortMappings:<br \/>\n   \u00a0 &#8211; containerPort: 6443<br \/>\n   \u00a0 \u00a0 hostPort: 36443 \u00a0# \u5bbf\u4e3b\u673a\u7aef\u53e3&#xff0c;\u4e4b\u540e\u53ef\u4ee5\u901a\u8fc7localhost&#xff1a;36443\u8bbf\u95eeAPI Server<br \/>\n   \u00a0 \u00a0 protocol: TCP<br \/>\n   \u00a0  image: kindest\/node:v1.27.3 \u00a0# \u6307\u5b9a\u7248\u672c<br \/>\n    &#8211; role: worker \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # Worker \u8282\u70b9 1<br \/>\n   \u00a0  image: kindest\/node:v1.27.3 \u00a0# \u6307\u5b9a\u7248\u672c<br \/>\n    &#8211; role: worker \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # Worker \u8282\u70b9 2<br \/>\n   \u00a0  image: kindest\/node:v1.27.3 \u00a0# \u6307\u5b9a\u7248\u672c<\/p>\n<p><span style=\"color:#fe2c24\">\u6ce8\u610f&#xff1a;Kind \u5bf9\u8282\u70b9\u89d2\u8272\u6709\u4e25\u683c\u7684\u547d\u540d\u89c4\u8303&#xff0c;\u4e0d\u80fd\u81ea\u5b9a\u4e49\u540d\u79f0&#xff0c;\u4e5f\u5c31\u662f\u8bf4\u4f60\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u89d2\u8272\u540d\u79f0\u4e0d\u53ef \u4ee5\u81ea\u5b9a\u4e49&#xff01;&#xff01;&#xff01;<\/span><\/p>\n<p>Kind \u76ee\u524d\u4e0d\u652f\u6301\u52a8\u6001\u6269\u5bb9&#xff0c;\u5982\u679c\u8981\u589e\u52a0\u65b0\u7684\u8282\u70b9&#xff0c;\u9700\u5220\u9664&#xff0c;\u7136\u540e\u4fee\u6539\u4f60\u7684\u914d\u7f6e\u6587\u4ef6\u5e76\u91cd\u5efa\u96c6\u7fa4<\/p>\n<p>\u4e4b\u540e\u5982\u4e0b\u56fe\u4fdd\u5b58\u5728\u4f60\u7684\u4efb\u610f\u76ee\u5f55\u4e2d<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1226\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811113437-6899d54dbec93.png\" width=\"1600\" \/><\/p>\n<h4>2\u3001\u4f7f\u7528\u914d\u7f6e\u6587\u4ef6\u521b\u5efa\u96c6\u7fa4<\/h4>\n<p>\u672c\u6b65\u521b\u5efa\u96c6\u7fa4\u6709\u4e24\u79cd\u65b9\u6cd5&#xff0c;\u4e00\u79cd\u662f\u4f7f\u7528\u7edd\u5bf9\u8def\u5f84\u521b\u5efa&#xff0c;\u4e00\u79cd\u662f\u76f8\u5bf9\u8def\u5f84\u521b\u5efa<\/p>\n<h6>\u2160\u3001\u7edd\u5bf9\u8def\u5f84<\/h6>\n<p>  # \u5148\u8fdb\u5165\u4f60\u7684Ubuntu\u6216\u8005\u662f\u5176\u4ed6\u53d1\u884c\u7248<br \/>\n  wsl -d Ubuntu<br \/>\n  \u200b<br \/>\n  # \u4f7f\u7528\u914d\u7f6e\u6587\u4ef6\u521b\u5efa\u96c6\u7fa4<br \/>\n  kind create cluster &#8211;name my-multi-node-cluster1 &#8211;config &#034;\/mnt\/e\/cloud-native\/k8s\/kindconfigfile1.yaml&#034;<\/p>\n<h6>\u2161\u3001\u76f8\u5bf9\u8def\u5f84<\/h6>\n<p>  # \u5148\u8fdb\u5165\u4f60\u7684Ubuntu\u6216\u8005\u662f\u5176\u4ed6\u53d1\u884c\u7248<br \/>\n  wsl -d Ubuntu<br \/>\n  \u200b<br \/>\n  # \u5148\u79fb\u5230\u4f60\u7684\u914d\u7f6e\u6587\u4ef6\u6240\u5728\u76ee\u5f55<br \/>\n  cd \/mnt\/e\/cloud-native\/k8s\/<br \/>\n  \u200b<br \/>\n  # \u4f7f\u7528\u914d\u7f6e\u6587\u4ef6\u521b\u5efa\u96c6\u7fa4<br \/>\n  kind create cluster &#8211;name my-multi-node-cluster1 &#8211;config kindconfigfile1.yaml<\/p>\n<p><span style=\"background-color:#f3f3f4\">&#8211;name<\/span>\u00a0&#xff1a;\u6307\u7684\u662f\u4f60\u521b\u5efa\u7684\u591a\u8282\u70b9\u96c6\u7fa4\u7684\u540d\u5b57&#xff0c;\u53ef\u81ea\u5b9a\u4e49<\/p>\n<p><span style=\"background-color:#f3f3f4\">&#8211;<\/span><span style=\"background-color:#f3f3f4\">-config<\/span><span style=\"background-color:#f3f3f4\"> <\/span>&#xff1a;\u6307\u7684\u662f\u4f60\u521a\u521a\u7f16\u8f91\u7684kind\u914d\u7f6e\u6587\u4ef6&#xff0c;\u540e\u9762\u8981\u52a0\u5165\u5bf9\u5e94\u7684\u8def\u5f84&#xff08;\u6ce8\u610f\u6700\u597d\u662f\u4f7f\u7528Linux\u8def\u5f84\u683c\u5f0f&#xff09;<\/p>\n<hr \/>\n<p>\u53ef\u80fd\u95ee\u9898&#xff1a;Docker \u65e0\u6cd5\u4ece\u955c\u50cf\u4ed3\u5e93\u62c9\u53d6 kindest\/node:v1.29.2 \u955c\u50cf&#xff0c;\u8fd9\u767e\u5206\u4e4b\u516b\u4e5d\u5341\u5c31\u662f\u56e0\u4e3a\u6211\u4eec\u662f\u5728\u56fd\u5185\u5bfc\u81f4\u7684\u7f51\u7edc\u95ee\u9898&#xff0c;\u6211\u4eec\u53ea\u8981\u7ed9\u6211\u4eec\u7684wsl2\u4e2d\u7684docker\u914d\u7f6e\u955c\u50cf\u6e90\u52a0\u901f\u5373\u53ef&#xff08;\u4f60\u4e5f\u53ef\u4ee5\u5c06\u4f60Windows\u672c\u5730\u7684docker\u4e2d\u7684\u955c\u50cf\u6e90\u590d\u5236\u52a0\u5230Ubuntu\u4e2d\u7684docker&#xff09;&#xff0c;\u4ee5\u4e0b\u6211\u63d0\u4f9b\u4e00\u4e2a\u7b80\u5355\u7684\u89e3\u51b3\u65b9\u6cd5&#xff1a;<\/p>\n<p> # \u9996\u5148\u786e\u8ba4 Docker \u670d\u52a1\u6b63\u5728\u8fd0\u884c<br \/>\n  # \u5982\u679c\u6ca1\u542f\u52a8\u62a5\u9519\u5c31\u91cd\u542f\u4e00\u4e0bdocker restart<br \/>\n  docker ps<br \/>\n  \u200b<br \/>\n  # \u7f16\u8f91 Docker \u914d\u7f6e\u6587\u4ef6&#xff0c;\u4e00\u822c\u5728\/etc\/docker\/daemon.json&#xff08;\u82e5\u4e0d\u5b58\u5728\u5219\u65b0\u5efa&#xff09;<br \/>\n  # \u914d\u7f6e\u955c\u50cf\u6e90&#xff0c;\u52a0\u901f\u4e0b\u8f7d&#xff0c;\u4f46\u53ef\u80fd\u4ecd\u4e0b\u8f7d\u6bd4\u8f83\u6162&#xff0c;\u4f46\u8fd8\u662f\u53ef\u4ee5\u4e0b\u4e0b\u6765\u7684<br \/>\n  sudo tee \/etc\/docker\/daemon.json &lt;&lt;EOF<br \/>\n  {<br \/>\n   \u00a0&#034;registry-mirrors&#034;: [<br \/>\n   \u00a0 \u00a0&#034;https:\/\/docker.mirrors.ustc.edu.cn&#034;,<br \/>\n   \u00a0 \u00a0&#034;https:\/\/registry-1.docker.io&#034;<br \/>\n    ],<br \/>\n   \u00a0&#034;insecure-registries&#034;: []<br \/>\n  }<br \/>\n  EOF<br \/>\n  \u200b<br \/>\n  # \u91cd\u542fdocker\u4f7f\u4fee\u6539\u751f\u6548<br \/>\n  sudo systemctl restart docker<\/p>\n<p>\u5982\u679c\u8fd8\u662f\u62c9\u53d6\u5931\u8d25&#xff0c;\u770b\u770b\u4f60\u6709\u6ca1\u6709\u5173\u95ed VPN \u6216\u4ee3\u7406\u5de5\u5177&#xff0c;\u8fd9\u4e9b\u4e5f\u53ef\u80fd\u6709\u5f71\u54cd<\/p>\n<p>\u62c9\u53d6\u6210\u529f&#xff0c;\u96c6\u7fa4\u521b\u5efa\u6210\u529f\u53ef\u4ee5\u5f97\u5230\u7c7b\u4f3c\u5982\u56fe\u63d0\u793a&#xff1a;<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"425\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811113450-6899d55a2876c.png\" width=\"1594\" \/><\/p>\n<\/p>\n<h4>3\u3001\u9a8c\u8bc1\u8282\u70b9\u72b6\u6001<\/h4>\n<p>\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\u9a8c\u8bc1&#xff1a;<\/p>\n<p>   kubectl get nodes<\/p>\n<p>\u4f60\u5c06\u4f1a\u770b\u5230\u7c7b\u4f3c\u753b\u9762&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"220\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811113453-6899d55dec0c7.png\" width=\"1595\" \/><\/p>\n<p>\u663e\u793a\u4e86 1 \u4e2a Master&#xff08;control-plane&#xff09;\u548c 2 \u4e2a Worker \u8282\u70b9<\/p>\n<hr \/>\n<p>\u53ef\u80fd\u95ee\u9898&#xff1a;STATUS\u663e\u793aNOTREADY&#xff0c;\u8fd9\u4e00\u822c\u662f\u591a\u53f0\u865a\u62df\u673a\u901a\u8fc7minikube\u6216\u5176\u4ed6\u5de5\u5177\u642d\u5efa\u96c6\u7fa4\u5bb9\u6613\u9047\u5230\u7684\u95ee\u9898&#xff0c;\u5373\u7f51\u7edc\u95ee\u9898&#xff0c;\u4f60\u53ef\u80fd\u9700\u8981\u914d\u7f6e\u90e8\u7f72\u4e00\u4e0bCNI\u7f51\u7edc\u7684\u4e00\u4e9b\u63d2\u4ef6&#xff0c;\u8fd9\u4e5f\u6070\u6070\u4f53\u73b0\u4e86kind\u7684\u4f18\u52bf<\/p>\n<h4>4\u3001\u67e5\u770b\u4e3b\u8282\u70b9\u7684\u6838\u5fc3\u7ec4\u4ef6<\/h4>\n<p>\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\u67e5\u770bPod&#xff1a;<\/p>\n<p>   # \u8bb0\u4f4f\u8981\u6307\u5b9a\u4f60\u8981\u67e5\u770b\u7684Pod\u7684\u6307\u5b9a\u7684\u547d\u540d\u7a7a\u95f4<br \/>\n   kubectl get pods -n kube-system<\/p>\n<p>\u5982\u679c\u6b63\u786e\u642d\u5efa\u5b8c\u6210&#xff0c;\u53ef\u4ee5\u770b\u89c1\u5982\u4e0b\u8f93\u51fa&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"451\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811113455-6899d55fbf980.png\" width=\"1600\" \/><\/p>\n<h4>5\u3001kubectl\u6838\u5fc3\u57fa\u7840\u547d\u4ee4<\/h4>\n<h5>\u2460\u5e38\u89c1\u8d44\u6e90\u7c7b\u578b<\/h5>\n<ul>\n<li>\n<p>Pods&#8212;-po&#xff08;\u522b\u540d&#xff09;<\/p>\n<\/li>\n<li>\n<p>deployments&#8212;-deploy&#xff08;\u522b\u540d&#xff09;<\/p>\n<\/li>\n<li>\n<p>services&#8212;-svc&#xff08;\u522b\u540d&#xff09;<\/p>\n<\/li>\n<li>\n<p>namespace&#8212;-ns&#xff08;\u522b\u540d&#xff09;<\/p>\n<\/li>\n<li>\n<p>nodes&#8212;-no&#xff08;\u522b\u540d&#xff09;<\/p>\n<\/li>\n<\/ul>\n<h5>\u2461\u3001Pod\u64cd\u4f5c<\/h5>\n<ul>\n<li>\n<p>\u521b\u5efaPod&#xff1a;kubectl create -f pod.yaml<\/p>\n<\/li>\n<li>\n<p>\u83b7\u53d6 Pod \u5217\u8868&#xff1a;kubectl get pods<\/p>\n<\/li>\n<li>\n<p>\u5220\u9664 Pod&#xff1a;kubectl delete pod &lt;pod-name&gt;<\/p>\n<\/li>\n<li>\n<p>\u8fdb\u5165 Pod \u7684\u5bb9\u5668&#xff1a;kubectl exec -it &lt;pod-name&gt; &#8212; \/bin\/sh<\/p>\n<\/li>\n<\/ul>\n<h5>\u2462\u3001 Deployment \u64cd\u4f5c<\/h5>\n<ul>\n<li>\n<p>\u521b\u5efa Deployment&#xff1a;kubectl create -f deployment.yaml<\/p>\n<\/li>\n<li>\n<p>\u83b7\u53d6 Deployment \u5217\u8868&#xff1a;kubectl get deployments<\/p>\n<\/li>\n<li>\n<p>\u66f4\u65b0 Deployment&#xff1a;kubectl set image deployment\/&lt;deployment-name&gt; &lt;container-name&gt;&#061;&lt;new-image&gt;<\/p>\n<\/li>\n<li>\n<p>\u5220\u9664 Deployment&#xff1a;kubectl delete deployment &lt;deployment-name&gt;<\/p>\n<\/li>\n<\/ul>\n<h5>\u2463. Service \u64cd\u4f5c<\/h5>\n<ul>\n<li>\n<p>\u521b\u5efa Service&#xff1a;kubectl create -f service.yaml<\/p>\n<\/li>\n<li>\n<p>\u83b7\u53d6 Service \u5217\u8868&#xff1a;kubectl get services<\/p>\n<\/li>\n<li>\n<p>\u5220\u9664 Service&#xff1a;kubectl delete service &lt;service-name&gt;<\/p>\n<\/li>\n<\/ul>\n<h5>\u2464. Namespace \u64cd\u4f5c<\/h5>\n<ul>\n<li>\n<p>\u521b\u5efa Namespace&#xff1a;kubectl create namespace &lt;namespace-name&gt;<\/p>\n<\/li>\n<li>\n<p>\u83b7\u53d6 Namespace \u5217\u8868&#xff1a;kubectl get namespaces<\/p>\n<\/li>\n<li>\n<p>\u5220\u9664 Namespace&#xff1a;kubectl delete namespace &lt;namespace-name&gt;<\/p>\n<\/li>\n<\/ul>\n<p>\u66f4\u591a\u5e38\u89c1\u64cd\u4f5c\u53c2\u8003\u5b98\u65b9\u6587\u6863\u54c8~<\/p>\n<h4>6\u3001\u591a\u8282\u70b9\u4f7f\u7528kubectl\u3010\u53ef\u9009\u3011<\/h4>\n<p>\u4e0d\u5efa\u8bae\u5728 Kubernetes Worker \u8282\u70b9\u4e0a\u5b89\u88c5\u548c\u4f7f\u7528 kubectl&#xff0c;\u5b89\u5168\u98ce\u9669\u9ad8\u3001\u7ef4\u62a4\u590d\u6742\u5316\u3001\u8d44\u6e90\u6d6a\u8d39&#xff0c;\u4f46\u5982\u679c\u4f60\u60f3&#xff0c;\u89c9\u5f97\u65b9\u4fbf\u4e5f\u53ef\u4ee5<\/p>\n<p>\u4f46\u662f\u6211\u66f4\u5efa\u8bae\u4ec5\u5728 Control Plane \u6216\u5916\u90e8\u673a\u5668\u4f7f\u7528 kubectl<\/p>\n<h5>\u2460\u3001\u8fdb\u5165\u4f60\u8981\u5b89\u88c5kubectl\u7684\u5bb9\u5668<\/h5>\n<h5>\u2461\u3001\u5728 \u5bb9\u5668\u5185\u5b89\u88c5 kubectl<\/h5>\n<h5>\u2462\u3001\u590d\u5236\u4e3b\u8282\u70b9\u7684 kubeconfig \u5230\u5bb9\u5668<\/h5>\n<p>\u6574\u4f53\u4e0b\u6765\u5982\u4e0b&#xff1a;<\/p>\n<p>  docker exec -it &lt;worker\u5bb9\u5668\u540d\u79f0&gt; \/bin\/bash<br \/>\n  \u200b<br \/>\n  # \u4e0b\u8f7d kubectl&#xff08;\u4f7f\u7528\u56fd\u5185\u955c\u50cf\u52a0\u901f&#xff09;<br \/>\n  curl -LO https:\/\/dl.k8s.io\/release\/$(curl -L -s https:\/\/dl.k8s.io\/release\/stable.txt)\/bin\/linux\/amd64\/kubectl<br \/>\n  \u200b<br \/>\n  # \u5b89\u88c5\u5230\u53ef\u6267\u884c\u8def\u5f84<br \/>\n  chmod &#043;x kubectl<br \/>\n  mv kubectl \/usr\/local\/bin\/<br \/>\n  \u200b<br \/>\n  # \u9a8c\u8bc1\u5b89\u88c5<br \/>\n  kubectl version &#8211;client<br \/>\n  \u200b<br \/>\n  # \u67e5\u770b\u4e3b\u8282\u70b9\u7684 kubeconfig<br \/>\n  cat \/etc\/kubernetes\/admin.conf<br \/>\n  \u200b<br \/>\n  # \u590d\u5236\u4e3b\u8282\u70b9\u7684 kubeconfig<br \/>\n  scp \/etc\/kubernetes\/admin.conf<br \/>\n  \u200b<br \/>\n  # \u521b\u5efa .kube \u76ee\u5f55<br \/>\n  mkdir -p ~\/.kube<br \/>\n  \u200b<br \/>\n  # \u7c98\u8d34\u5185\u5bb9\u5230\u914d\u7f6e\u6587\u4ef6<br \/>\n  cat &gt; ~\/.kube\/config &lt;&lt;EOF<br \/>\n  &lt;paste kubeconfig content here&gt;<br \/>\n  EOF<br \/>\n  \u200b<br \/>\n  # \u8bbe\u7f6e\u6743\u9650<br \/>\n  chmod 600 ~\/.kube\/config<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb460\u6b21\uff0c\u70b9\u8d5e11\u6b21\uff0c\u6536\u85cf3\u6b21\u3002\u5982\u679c\u8981\u589e\u52a0\u65b0\u7684\u8282\u70b9\uff0c\u9700\u5220\u9664\uff0c\u7136\u540e\u4fee\u6539\u4f60\u7684\u914d\u7f6e\u6587\u4ef6\u5e76\u91cd\u5efa\u96c6\u7fa4\u4e4b\u540e\u5982\u4e0b\u56fe\u4fdd\u5b58\u5728\u4f60\u7684\u4efb\u610f\u76ee\u5f55\u4e2d\u3002<\/p>\n","protected":false},"author":2,"featured_media":52791,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[5318,120,763,190,43],"topic":[],"class_list":["post-52798","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-k8s","tag-kubernetes","tag-763","tag-190","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>k8sday03\u642d\u5efakubernetes\u96c6\u7fa4\uff082\/2\uff09 - \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\/52798.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"k8sday03\u642d\u5efakubernetes\u96c6\u7fa4\uff082\/2\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb460\u6b21\uff0c\u70b9\u8d5e11\u6b21\uff0c\u6536\u85cf3\u6b21\u3002\u5982\u679c\u8981\u589e\u52a0\u65b0\u7684\u8282\u70b9\uff0c\u9700\u5220\u9664\uff0c\u7136\u540e\u4fee\u6539\u4f60\u7684\u914d\u7f6e\u6587\u4ef6\u5e76\u91cd\u5efa\u96c6\u7fa4\u4e4b\u540e\u5982\u4e0b\u56fe\u4fdd\u5b58\u5728\u4f60\u7684\u4efb\u610f\u76ee\u5f55\u4e2d\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/52798.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-11T11:35:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811113437-6899d54dbec93.png\" \/>\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\/52798.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/52798.html\",\"name\":\"k8sday03\u642d\u5efakubernetes\u96c6\u7fa4\uff082\/2\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-11T11:35:01+00:00\",\"dateModified\":\"2025-08-11T11:35:01+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/52798.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/52798.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/52798.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"k8sday03\u642d\u5efakubernetes\u96c6\u7fa4\uff082\/2\uff09\"}]},{\"@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":"k8sday03\u642d\u5efakubernetes\u96c6\u7fa4\uff082\/2\uff09 - \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\/52798.html","og_locale":"zh_CN","og_type":"article","og_title":"k8sday03\u642d\u5efakubernetes\u96c6\u7fa4\uff082\/2\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb460\u6b21\uff0c\u70b9\u8d5e11\u6b21\uff0c\u6536\u85cf3\u6b21\u3002\u5982\u679c\u8981\u589e\u52a0\u65b0\u7684\u8282\u70b9\uff0c\u9700\u5220\u9664\uff0c\u7136\u540e\u4fee\u6539\u4f60\u7684\u914d\u7f6e\u6587\u4ef6\u5e76\u91cd\u5efa\u96c6\u7fa4\u4e4b\u540e\u5982\u4e0b\u56fe\u4fdd\u5b58\u5728\u4f60\u7684\u4efb\u610f\u76ee\u5f55\u4e2d\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/52798.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-11T11:35:01+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811113437-6899d54dbec93.png"}],"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\/52798.html","url":"https:\/\/www.wsisp.com\/helps\/52798.html","name":"k8sday03\u642d\u5efakubernetes\u96c6\u7fa4\uff082\/2\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-11T11:35:01+00:00","dateModified":"2025-08-11T11:35:01+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/52798.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/52798.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/52798.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"k8sday03\u642d\u5efakubernetes\u96c6\u7fa4\uff082\/2\uff09"}]},{"@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\/52798","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=52798"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/52798\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/52791"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=52798"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=52798"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=52798"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=52798"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}