{"id":108107,"date":"2026-09-21T01:11:55","date_gmt":"2026-09-20T17:11:55","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/108107.html"},"modified":"2026-09-21T01:11:55","modified_gmt":"2026-09-20T17:11:55","slug":"k8spod%e7%ae%a1%e7%90%86%e7%9f%a5%e8%af%86%e7%82%b9%e6%80%bb%e7%bb%93","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/108107.html","title":{"rendered":"k8spod\u7ba1\u7406\u77e5\u8bc6\u70b9\u603b\u7ed3"},"content":{"rendered":"<h3>\u76ee\u5f55<\/h3>\n<ul>\n<li>\u4e00\u3001\u547d\u4ee4\u5f0f\u5bf9\u8c61\u7ba1\u7406\n<ul>\n<li>1.1 \u547d\u540d\u7a7a\u95f4\u7ba1\u7406<\/li>\n<li>1.2 Pod \u7684\u521b\u5efa\u4e0e\u67e5\u770b<\/li>\n<li>1.3 Pod \u6545\u969c\u6392\u67e5<\/li>\n<li>1.4 Pod \u7684\u5220\u9664<\/li>\n<\/ul>\n<\/li>\n<li>\u4e8c\u3001kubectl \u547d\u4ee4\u5b9e\u64cd\n<ul>\n<li>2.1 \u5b9e\u9a8c\u955c\u50cf\u51c6\u5907<\/li>\n<li>2.2 \u7528 dry-run \u751f\u6210 yaml \u6587\u4ef6<\/li>\n<li>2.3 \u5e38\u7528\u7ba1\u7406\u547d\u4ee4<\/li>\n<li>2.4 \u6eda\u52a8\u66f4\u65b0\u547d\u4ee4<\/li>\n<li>2.5 \u5f39\u6027\u4f38\u7f29\u547d\u4ee4<\/li>\n<\/ul>\n<\/li>\n<li>\u4e09\u3001\u5229\u7528 yaml \u6587\u4ef6\u58f0\u660e\u8d44\u6e90\n<ul>\n<li>3.1 \u5355 Pod \u8fd0\u884c\u591a\u5bb9\u5668<\/li>\n<li>3.2 \u66b4\u9732\u7aef\u53e3<\/li>\n<li>3.3 \u6307\u5b9a\u73af\u5883\u53d8\u91cf<\/li>\n<li>3.4 \u9009\u62e9\u8fd0\u884c\u8282\u70b9<\/li>\n<li>3.5 \u5171\u4eab\u5bbf\u4e3b\u673a\u7f51\u7edc<\/li>\n<li>3.6 \u8d44\u6e90\u4f18\u5148\u7ea7 QoS<\/li>\n<li>3.7 \u5bb9\u5668\u91cd\u542f\u89c4\u5219<\/li>\n<\/ul>\n<\/li>\n<li>\u56db\u3001Pod \u7684\u751f\u547d\u5468\u671f\n<ul>\n<li>4.1 init \u5bb9\u5668<\/li>\n<li>4.2 \u5b58\u6d3b\u63a2\u9488 livenessProbe<\/li>\n<li>4.3 \u5c31\u7eea\u63a2\u9488 readinessProbe<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e00\u3001\u547d\u4ee4\u5f0f\u5bf9\u8c61\u7ba1\u7406<\/h3>\n<p>\u547d\u4ee4\u5f0f\u5bf9\u8c61\u7ba1\u7406\u662f\u6307\u76f4\u63a5\u901a\u8fc7 kubectl \u547d\u4ee4\u64cd\u4f5c\u96c6\u7fa4\u4e2d\u7684\u8d44\u6e90\u5bf9\u8c61&#xff0c;\u4e0d\u4f9d\u8d56 yaml \u6587\u4ef6\u3002<\/p>\n<h4>\u547d\u4ee4\u5206\u7c7b<\/h4>\n<table>\n<tr>\u64cd\u4f5c\u547d\u4ee4\u683c\u5f0f\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u67e5\u770b<\/td>\n<td>kubectl get &lt;\u8d44\u6e90&gt;<\/td>\n<td>\u67e5\u770b\u8d44\u6e90\u5217\u8868&#xff0c;-o wide \u663e\u793a IP \u548c\u6240\u5728\u8282\u70b9<\/td>\n<\/tr>\n<tr>\n<td>\u521b\u5efa<\/td>\n<td>kubectl run\/create &lt;\u8d44\u6e90&gt;<\/td>\n<td>\u547d\u4ee4\u5f0f\u521b\u5efa Pod\u3001Deployment \u7b49<\/td>\n<\/tr>\n<tr>\n<td>\u63cf\u8ff0<\/td>\n<td>kubectl describe &lt;\u8d44\u6e90&gt;<\/td>\n<td>\u67e5\u770b\u8d44\u6e90\u8be6\u7ec6\u4fe1\u606f&#xff0c;\u5305\u62ec\u4e8b\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>\u5220\u9664<\/td>\n<td>kubectl delete &lt;\u8d44\u6e90&gt;<\/td>\n<td>\u5220\u9664\u8d44\u6e90<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>1.1 \u547d\u540d\u7a7a\u95f4\u7ba1\u7406<\/h4>\n<p>\u547d\u540d\u7a7a\u95f4&#xff08;Namespace&#xff09;\u7528\u6765\u5bf9\u96c6\u7fa4\u8d44\u6e90\u505a\u903b\u8f91\u9694\u79bb\u3002\u96c6\u7fa4\u521d\u59cb\u5316\u540e\u4f1a\u81ea\u5e26 5 \u4e2a\u547d\u540d\u7a7a\u95f4&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get namespaces<\/span><br \/>\nNAME              STATUS   AGE<br \/>\ndefault           Active   4h20m<br \/>\nkube-flannel      Active   3h31m<br \/>\nkube-node-lease   Active   4h20m<br \/>\nkube-public       Active   4h20m<br \/>\nkube-system       Active   4h20m<\/p>\n<table>\n<tr>\u547d\u540d\u7a7a\u95f4\u7528\u9014<\/tr>\n<tbody>\n<tr>\n<td>default<\/td>\n<td>\u9ed8\u8ba4\u547d\u540d\u7a7a\u95f4&#xff0c;\u7528\u6237\u8d44\u6e90\u9ed8\u8ba4\u653e\u8fd9\u91cc<\/td>\n<\/tr>\n<tr>\n<td>kube-system<\/td>\n<td>\u96c6\u7fa4\u6838\u5fc3\u7ec4\u4ef6&#xff08;apiserver\u3001controller-manager \u7b49&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>kube-public<\/td>\n<td>\u516c\u5171\u8d44\u6e90&#xff0c;\u6240\u6709\u7528\u6237\u53ef\u8bfb<\/td>\n<\/tr>\n<tr>\n<td>kube-node-lease<\/td>\n<td>\u8282\u70b9\u5fc3\u8df3\u79df\u7ea6<\/td>\n<\/tr>\n<tr>\n<td>kube-flannel<\/td>\n<td>\u7f51\u7edc\u63d2\u4ef6 flannel \u7684\u8d44\u6e90<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u521b\u5efa\u547d\u540d\u7a7a\u95f4\u540e&#xff0c;kubectl get namespaces \u4e2d\u4f1a\u51fa\u73b0\u65b0\u9879&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl create namespace timinglee<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get namespaces<\/span><br \/>\nNAME              STATUS   AGE<br \/>\ndefault           Active   4h22m<br \/>\nkube-flannel      Active   3h32m<br \/>\nkube-node-lease   Active   4h22m<br \/>\nkube-public       Active   4h22m<br \/>\nkube-system       Active   4h22m<br \/>\ntiminglee         Active   5s<\/p>\n<p>\u5220\u9664\u547d\u540d\u7a7a\u95f4&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl delete namespaces timinglee<\/span><br \/>\nnamespace <span class=\"token string\">&#034;timinglee&#034;<\/span> deleted<\/p>\n<p>\u5220\u9664\u547d\u540d\u7a7a\u95f4\u4f1a\u8fde\u540c\u5176\u4e2d\u7684\u6240\u6709\u8d44\u6e90\u4e00\u8d77\u5220\u9664&#xff0c;\u64cd\u4f5c\u524d\u8981\u786e\u8ba4\u3002<\/p>\n<\/p>\n<h4>1.2 Pod \u7684\u521b\u5efa\u4e0e\u67e5\u770b<\/h4>\n<p>Pod \u662f Kubernetes \u7684\u6700\u5c0f\u8c03\u5ea6\u5355\u4f4d\u3002\u7528 kubectl run \u76f4\u63a5\u521b\u5efa&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u5f53\u524d\u547d\u540d\u7a7a\u95f4\u4e2d\u7684 pod<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods -o wide<\/span><br \/>\nNo resources found <span class=\"token keyword\">in<\/span> default namespace.<\/p>\n<p><span class=\"token comment\"># \u521b\u5efa pod<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl run lee &#8211;image nginx:latest<\/span><br \/>\npod\/lee created<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods -o wide<\/span><br \/>\nNAME   READY   STATUS    RESTARTS   AGE   IP            NODE        NOMINATED NODE   READINESS GATES<br \/>\nlee    <span class=\"token number\">1<\/span>\/1     Running   <span class=\"token number\">0<\/span>          25s   <span class=\"token number\">10.244<\/span>.1.10   k8s-node1   <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span>           <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span><\/p>\n<p>-o wide \u4f1a\u989d\u5916\u663e\u793a pod \u7684 IP \u548c\u6240\u5728\u8282\u70b9\u3002\u672c\u4f8b\u4e2d pod \u88ab\u8c03\u5ea6\u5230 k8s-node1&#xff0c;\u5206\u914d\u7684\u96c6\u7fa4 IP \u662f 10.244.1.10\u3002<\/p>\n<\/p>\n<h4>1.3 Pod \u6545\u969c\u6392\u67e5<\/h4>\n<p>\u955c\u50cf\u4e0d\u5b58\u5728\u65f6&#xff0c;pod \u4f1a\u505c\u5728 ImagePullBackOff \u72b6\u6001&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl run error &#8211;image lee:v1<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods -o wide<\/span><br \/>\nNAME    READY   STATUS             RESTARTS   AGE   IP            NODE        NOMINATED NODE   READINESS GATES<br \/>\nerror   <span class=\"token number\">0<\/span>\/1     ImagePullBackOff   <span class=\"token number\">0<\/span>          38s   <span class=\"token number\">10.244<\/span>.2.3    k8s-node2   <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span>           <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span><br \/>\nlee     <span class=\"token number\">1<\/span>\/1     Running            <span class=\"token number\">0<\/span>          91s   <span class=\"token number\">10.244<\/span>.1.10   k8s-node1   <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span>           <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span><\/p>\n<p>\u7528 kubectl describe \u67e5\u770b\u8be6\u7ec6\u4fe1\u606f\u5b9a\u4f4d\u539f\u56e0&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl describe pods error<\/span><br \/>\nName:             error<br \/>\nNamespace:        default<br \/>\nNode:             k8s-node2\/172.25.254.20<br \/>\nStatus:           Pending<br \/>\nIP:               <span class=\"token number\">10.244<\/span>.2.3<br \/>\nContainers:<br \/>\n  error:<br \/>\n    Image:          lee:v1<br \/>\n    State:          Waiting<br \/>\n      Reason:       ImagePullBackOff<br \/>\n    Ready:          False<br \/>\nConditions:<br \/>\n  Type                        Status<br \/>\n  PodReadyToStartContainers   True<br \/>\n  Initialized                 True<br \/>\n  Ready                       False<br \/>\n  ContainersReady             False<br \/>\n  PodScheduled                True<br \/>\nQoS Class:                   BestEffort<br \/>\nEvents:<br \/>\n  Type     Reason     Age                From               Message<br \/>\n  &#8212;-     &#8212;&#8212;     &#8212;-               &#8212;-               &#8212;&#8212;-<br \/>\n  Normal   Scheduled  87s                default-scheduler  Successfully assigned default\/error to k8s-node2<br \/>\n  Warning  Failed     28s <span class=\"token punctuation\">(<\/span>x2 over 65s<span class=\"token punctuation\">)<\/span>  kubelet            Failed to pull image <span class=\"token string\">&#034;lee:v1&#034;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token punctuation\">..<\/span>. not found<br \/>\n  Warning  Failed     28s <span class=\"token punctuation\">(<\/span>x2 over 65s<span class=\"token punctuation\">)<\/span>  kubelet            Error: ErrImagePull<br \/>\n  Normal   BackOff    16s <span class=\"token punctuation\">(<\/span>x2 over 64s<span class=\"token punctuation\">)<\/span>  kubelet            Back-off pulling image <span class=\"token string\">&#034;lee:v1&#034;<\/span><br \/>\n  Warning  Failed     16s <span class=\"token punctuation\">(<\/span>x2 over 64s<span class=\"token punctuation\">)<\/span>  kubelet            Error: ImagePullBackOff<br \/>\n  Normal   Pulling    2s <span class=\"token punctuation\">(<\/span>x3 over 86s<span class=\"token punctuation\">)<\/span>   kubelet            Pulling image <span class=\"token string\">&#034;lee:v1&#034;<\/span><\/p>\n<p>Pod \u4ece\u521b\u5efa\u5230\u8fd0\u884c&#xff0c;\u4ee5\u53ca\u62c9\u955c\u50cf\u5931\u8d25\u7684\u8def\u5f84\u5982\u4e0b&#xff1a;<\/p>\n<p>  #mermaid-svg-idCeFR1RsOJl3kCx{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-idCeFR1RsOJl3kCx .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-idCeFR1RsOJl3kCx .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-idCeFR1RsOJl3kCx .error-icon{fill:#552222;}#mermaid-svg-idCeFR1RsOJl3kCx .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-idCeFR1RsOJl3kCx .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-idCeFR1RsOJl3kCx .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-idCeFR1RsOJl3kCx .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-idCeFR1RsOJl3kCx .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-idCeFR1RsOJl3kCx .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-idCeFR1RsOJl3kCx .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-idCeFR1RsOJl3kCx .marker{fill:#333333;stroke:#333333;}#mermaid-svg-idCeFR1RsOJl3kCx .marker.cross{stroke:#333333;}#mermaid-svg-idCeFR1RsOJl3kCx svg{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-idCeFR1RsOJl3kCx p{margin:0;}#mermaid-svg-idCeFR1RsOJl3kCx .label{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;color:#333;}#mermaid-svg-idCeFR1RsOJl3kCx .cluster-label text{fill:#333;}#mermaid-svg-idCeFR1RsOJl3kCx .cluster-label span{color:#333;}#mermaid-svg-idCeFR1RsOJl3kCx .cluster-label span p{background-color:transparent;}#mermaid-svg-idCeFR1RsOJl3kCx .label text,#mermaid-svg-idCeFR1RsOJl3kCx span{fill:#333;color:#333;}#mermaid-svg-idCeFR1RsOJl3kCx .node rect,#mermaid-svg-idCeFR1RsOJl3kCx .node circle,#mermaid-svg-idCeFR1RsOJl3kCx .node ellipse,#mermaid-svg-idCeFR1RsOJl3kCx .node polygon,#mermaid-svg-idCeFR1RsOJl3kCx .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-idCeFR1RsOJl3kCx .rough-node .label text,#mermaid-svg-idCeFR1RsOJl3kCx .node .label text,#mermaid-svg-idCeFR1RsOJl3kCx .image-shape .label,#mermaid-svg-idCeFR1RsOJl3kCx .icon-shape .label{text-anchor:middle;}#mermaid-svg-idCeFR1RsOJl3kCx .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-idCeFR1RsOJl3kCx .rough-node .label,#mermaid-svg-idCeFR1RsOJl3kCx .node .label,#mermaid-svg-idCeFR1RsOJl3kCx .image-shape .label,#mermaid-svg-idCeFR1RsOJl3kCx .icon-shape .label{text-align:center;}#mermaid-svg-idCeFR1RsOJl3kCx .node.clickable{cursor:pointer;}#mermaid-svg-idCeFR1RsOJl3kCx .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-idCeFR1RsOJl3kCx .arrowheadPath{fill:#333333;}#mermaid-svg-idCeFR1RsOJl3kCx .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-idCeFR1RsOJl3kCx .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-idCeFR1RsOJl3kCx .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-idCeFR1RsOJl3kCx .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-idCeFR1RsOJl3kCx .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-idCeFR1RsOJl3kCx .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-idCeFR1RsOJl3kCx .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-idCeFR1RsOJl3kCx .cluster text{fill:#333;}#mermaid-svg-idCeFR1RsOJl3kCx .cluster span{color:#333;}#mermaid-svg-idCeFR1RsOJl3kCx div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-idCeFR1RsOJl3kCx .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-idCeFR1RsOJl3kCx rect.text{fill:none;stroke-width:0;}#mermaid-svg-idCeFR1RsOJl3kCx .icon-shape,#mermaid-svg-idCeFR1RsOJl3kCx .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-idCeFR1RsOJl3kCx .icon-shape p,#mermaid-svg-idCeFR1RsOJl3kCx .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-idCeFR1RsOJl3kCx .icon-shape .label rect,#mermaid-svg-idCeFR1RsOJl3kCx .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-idCeFR1RsOJl3kCx .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-idCeFR1RsOJl3kCx .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-idCeFR1RsOJl3kCx :root{&#8211;mermaid-font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;}<\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>kubectl run lee&#8211;image nginx:latest<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>Scheduler \u8c03\u5ea6Scheduled \u2192 k8s-node1<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>kubelet \u62c9\u53d6\u955c\u50cfPulling \u2192 \u6210\u529f<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u5bb9\u5668\u542f\u52a8Running 1\/1<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>kubectl run error&#8211;image lee:v1<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>Scheduler \u8c03\u5ea6Scheduled \u2192 k8s-node2<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u955c\u50cf\u4e0d\u5b58\u5728ErrImagePull<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>ImagePullBackOff\u72b6\u6001 Waiting, Ready False<\/p>\n<p><\/span><\/p>\n<p>describe \u4e2d\u7684 Events \u662f\u6392\u67e5\u95ee\u9898\u7684\u5173\u952e&#xff1a;Scheduled \u8868\u793a\u8c03\u5ea6\u6210\u529f&#xff0c;ErrImagePull \/ ImagePullBackOff \u8bf4\u660e\u955c\u50cf\u62c9\u53d6\u5931\u8d25&#xff0c;\u901a\u5e38\u662f\u955c\u50cf\u540d\u5199\u9519\u6216\u955c\u50cf\u4e0d\u5b58\u5728\u3002<\/p>\n<\/p>\n<h4>1.4 Pod \u7684\u5220\u9664<\/h4>\n<p><span class=\"token comment\"># \u5220\u9664\u5355\u4e2a pod<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl delete pods error<\/span><\/p>\n<p><span class=\"token comment\"># \u5220\u9664\u5f53\u524d\u547d\u540d\u7a7a\u95f4\u4e0b\u6240\u6709 pod<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl delete pods &#8211;all<\/span><br \/>\npod <span class=\"token string\">&#034;error&#034;<\/span> deleted from default namespace<br \/>\npod <span class=\"token string\">&#034;lee&#034;<\/span> deleted from default namespace<\/p>\n<hr \/>\n<h3>\u4e8c\u3001kubectl \u547d\u4ee4\u5b9e\u64cd<\/h3>\n<\/p>\n<h4>2.1 \u5b9e\u9a8c\u955c\u50cf\u51c6\u5907<\/h4>\n<p>\u52a0\u8f7d\u5230\u672c\u5730\u5e76\u63a8\u9001\u8fdb Harbor \u4ed3\u5e93\u7684 library \u9879\u76ee&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># docker load -i myapp.tar.gz<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># docker tag timinglee\/myapp:v1 reg.timinglee.org\/library\/myapp:v1<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># docker push reg.timinglee.org\/library\/myapp:v1<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># docker tag timinglee\/myapp:v2 reg.timinglee.org\/library\/myapp:v2<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># docker push reg.timinglee.org\/library\/myapp:v2<\/span><\/p>\n<h4>2.2 \u7528 dry-run \u751f\u6210 yaml \u6587\u4ef6<\/h4>\n<p>&#8211;dry-run&#061;client -o yaml \u53ef\u4ee5\u5728\u4e0d\u771f\u6b63\u521b\u5efa\u8d44\u6e90\u7684\u60c5\u51b5\u4e0b&#xff0c;\u628a\u8d44\u6e90\u7684 yaml \u5b9a\u4e49\u8f93\u51fa\u5230\u6587\u4ef6&#xff0c;\u518d\u6309\u9700\u4fee\u6539\u540e apply&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl create deployment webcluster &#8211;image myapp:v1 &#8211;replicas 2 &#8211;dry-run&#061;client -o yaml &gt; webcluster.yml<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim webcluster.yml<\/span><br \/>\napiVersion: apps\/v1<br \/>\nkind: Deployment<br \/>\nmetadata:<br \/>\n  labels:<br \/>\n    app: webcluster<br \/>\n  name: webcluster<br \/>\nspec:<br \/>\n  replicas: <span class=\"token number\">2<\/span><br \/>\n  selector:<br \/>\n    matchLabels:<br \/>\n      app: webcluster<br \/>\n  template:<br \/>\n    metadata:<br \/>\n      labels:<br \/>\n        app: webcluster<br \/>\n    spec:<br \/>\n      containers:<br \/>\n      &#8211; image: myapp:v1<br \/>\n        name: myapp<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl apply -f webcluster.yml<\/span><br \/>\ndeployment.apps\/webcluster created<\/p>\n<p>yaml \u4e2d\u56db\u4e2a\u5b57\u6bb5\u7684\u542b\u4e49&#xff1a;<\/p>\n<table>\n<tr>\u5b57\u6bb5\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td>metadata.labels<\/td>\n<td>\u8d44\u6e90\u7684\u6807\u7b7e<\/td>\n<\/tr>\n<tr>\n<td>spec.replicas<\/td>\n<td>\u671f\u671b\u7684 pod \u6570\u91cf<\/td>\n<\/tr>\n<tr>\n<td>spec.selector.matchLabels<\/td>\n<td>\u63a7\u5236\u5668\u901a\u8fc7\u8be5\u6807\u7b7e\u9009\u62e9\u5b83\u7ba1\u7406\u7684 pod<\/td>\n<\/tr>\n<tr>\n<td>spec.template<\/td>\n<td>\u521b\u5efa pod \u7684\u5c5e\u6027\u6a21\u677f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>2.3 \u5e38\u7528\u7ba1\u7406\u547d\u4ee4<\/h4>\n<p>create&#xff1a;\u521b\u5efa\u8d44\u6e90<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl create deployment webcluster &#8211;replicas 2 &#8211;image myapp:v1<\/span><br \/>\ndeployment.apps\/webcluster created<br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get deployments.apps<\/span><br \/>\nNAME         READY   UP-TO-DATE   AVAILABLE   AGE<br \/>\nwebcluster   <span class=\"token number\">2<\/span>\/2     <span class=\"token number\">2<\/span>            <span class=\"token number\">2<\/span>           15s<br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods<\/span><br \/>\nNAME                          READY   STATUS    RESTARTS   AGE<br \/>\nwebcluster-77c87d9946-28thm   <span class=\"token number\">1<\/span>\/1     Running   <span class=\"token number\">0<\/span>          24s<br \/>\nwebcluster-77c87d9946-vwrsq   <span class=\"token number\">1<\/span>\/1     Running   <span class=\"token number\">0<\/span>          24s<\/p>\n<p><span class=\"token comment\"># \u5220\u9664<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl delete deployments.apps webcluster<\/span><br \/>\ndeployment.apps <span class=\"token string\">&#034;webcluster&#034;<\/span> deleted from default namespace<br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods<\/span><br \/>\nNo resources found <span class=\"token keyword\">in<\/span> default namespace.<\/p>\n<p>\u7531 Deployment \u521b\u5efa\u7684 pod \u547d\u540d\u5e26 pod-template-hash \u540e\u7f00&#xff08;\u5982 77c87d9946&#xff09;&#xff0c;\u540c\u4e00\u4e2a Deployment \u4e0b\u7684 pod \u4f7f\u7528\u76f8\u540c\u7684\u6a21\u677f\u54c8\u5e0c\u3002<\/p>\n<p>edit&#xff1a;\u7f16\u8f91\u8d44\u6e90<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl edit deployments.apps webcluster<\/span><br \/>\n  replicas: <span class=\"token number\">2<\/span>    <span class=\"token comment\"># \u5728\u7f16\u8f91\u5668\u4e2d\u4fee\u6539\u526f\u672c\u6570<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods<\/span><br \/>\nNAME                          READY   STATUS    RESTARTS   AGE<br \/>\nwebcluster-77c87d9946-2cgr7   <span class=\"token number\">1<\/span>\/1     Running   <span class=\"token number\">0<\/span>          36s<br \/>\nwebcluster-77c87d9946-2wqn7   <span class=\"token number\">1<\/span>\/1     Running   <span class=\"token number\">0<\/span>          103s<\/p>\n<p>patch&#xff1a;\u6253\u8865\u4e01\u4fee\u6539\u5355\u4e2a\u5b57\u6bb5<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl patch deployments.apps webcluster -p &#039;{&#034;spec&#034;:{&#034;replicas&#034;:1}}&#039;<\/span><br \/>\ndeployment.apps\/webcluster patched<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods<\/span><br \/>\nNAME                          READY   STATUS    RESTARTS   AGE<br \/>\nwebcluster-77c87d9946-2wqn7   <span class=\"token number\">1<\/span>\/1     Running   <span class=\"token number\">0<\/span>          6m20s<\/p>\n<p>expose&#xff1a;\u66b4\u9732\u670d\u52a1<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl expose deployment webcluster &#8211;port 80 &#8211;target-port 80<\/span><br \/>\nservice\/webcluster exposed<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get service<\/span><br \/>\nNAME         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT<span class=\"token punctuation\">(<\/span>S<span class=\"token punctuation\">)<\/span>   AGE<br \/>\nkubernetes   ClusterIP   <span class=\"token number\">10.96<\/span>.0.1      <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span>        <span class=\"token number\">443<\/span>\/TCP   6h<br \/>\nwebcluster   ClusterIP   <span class=\"token number\">10.97<\/span>.61.108   <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span>        <span class=\"token number\">80<\/span>\/TCP    18s<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl describe svc webcluster<\/span><br \/>\nName:                     webcluster<br \/>\nSelector:                 <span class=\"token assign-left variable\">app<\/span><span class=\"token operator\">&#061;<\/span>webcluster<br \/>\nType:                     ClusterIP<br \/>\nIP:                       <span class=\"token number\">10.97<\/span>.61.108<br \/>\nPort:                     <span class=\"token operator\">&lt;<\/span>unset<span class=\"token operator\">&gt;<\/span>  <span class=\"token number\">80<\/span>\/TCP<br \/>\nTargetPort:               <span class=\"token number\">80<\/span>\/TCP<br \/>\nEndpoints:                <span class=\"token number\">10.244<\/span>.1.11:80,10.244.5.10:80,10.244.5.9:80 &#043; <span class=\"token number\">1<\/span> more<span class=\"token punctuation\">..<\/span>.<\/p>\n<p>Service \u901a\u8fc7 Selector&#xff08;\u6807\u7b7e\u9009\u62e9\u5668&#xff09;\u627e\u5230\u540e\u7aef\u7684 pod&#xff0c;\u8bbf\u95ee ClusterIP \u65f6\u4f1a\u8f6e\u8be2\u5230\u4e0d\u540c\u7684 pod&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl 10.97.61.108\/hostname.html<\/span><br \/>\nwebcluster-77c87d9946-gh9v7<br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl 10.97.61.108\/hostname.html<\/span><br \/>\nwebcluster-77c87d9946-m69wl<br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl 10.97.61.108\/hostname.html<\/span><br \/>\nwebcluster-77c87d9946-4p4mz<\/p>\n<p>\u591a\u6b21 curl \u8fd4\u56de\u4e0d\u540c\u7684 pod \u540d&#xff0c;\u8bf4\u660e\u6d41\u91cf\u88ab\u5206\u53d1\u5230\u591a\u4e2a\u526f\u672c\u4e0a\u3002<\/p>\n<p>logs&#xff1a;\u67e5\u770b\u65e5\u5fd7<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl logs pods\/webcluster-77c87d9946-gh9v7<\/span><br \/>\n<span class=\"token number\">10.244<\/span>.0.0 &#8211; &#8211; <span class=\"token punctuation\">[<\/span><span class=\"token number\">20<\/span>\/Aug\/2026:08:43:52 &#043;0000<span class=\"token punctuation\">]<\/span> <span class=\"token string\">&#034;GET \/hostname.html HTTP\/1.1&#034;<\/span> <span class=\"token number\">200<\/span> <span class=\"token number\">28<\/span> <span class=\"token string\">&#034;-&#034;<\/span> <span class=\"token string\">&#034;curl\/7.76.1&#034;<\/span> <span class=\"token string\">&#034;-&#034;<\/span><\/p>\n<p>attach&#xff1a;\u6302\u63a5\u5bb9\u5668<\/p>\n<p><span class=\"token comment\"># \u4ea4\u4e92\u5f0f\u521b\u5efa pod<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl run -it testpod &#8211;image busybox:latest<\/span><br \/>\n\/ <span class=\"token comment\">#        # ctrl&#043;pq \u9000\u51fa<\/span><\/p>\n<p><span class=\"token comment\"># \u91cd\u65b0\u6302\u63a5\u5230\u5bb9\u5668\u7ec8\u7aef<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl attach pods\/testpod -it<\/span><br \/>\n\/ <span class=\"token comment\">#<\/span><\/p>\n<p>exec&#xff1a;\u5728\u5bb9\u5668\u4e2d\u6267\u884c\u547d\u4ee4<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl run testpod &#8211;image nginx:latest<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl exec -it pods\/testpod -c testpod &#8212; \/bin\/bash<\/span><br \/>\nroot&#064;testpod:\/<span class=\"token comment\">#<\/span><\/p>\n<p>exec \u9002\u5408\u8fdb\u5bb9\u5668\u505a\u8bca\u65ad&#xff0c;attach \u662f\u6302\u63a5\u5230\u5bb9\u5668\u7684\u4e3b\u8fdb\u7a0b\u7ec8\u7aef&#xff0c;\u4e24\u8005\u573a\u666f\u4e0d\u540c\u3002<\/p>\n<p>cp&#xff1a;\u5bb9\u5668\u4e0e\u4e3b\u673a\u95f4\u62f7\u8d1d\u6587\u4ef6<\/p>\n<p><span class=\"token comment\"># \u5bb9\u5668 \u2192 \u4e3b\u673a<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl cp testpod:\/usr\/share\/nginx\/html\/index.html \/mnt\/test<\/span><\/p>\n<p><span class=\"token comment\"># \u4e3b\u673a \u2192 \u5bb9\u5668<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># echo timinglee &gt; \/mnt\/index.html<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl cp \/mnt\/index.html testpod:\/usr\/share\/nginx\/html\/index.html<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl 10.244.1.12<\/span><br \/>\ntiminglee<\/p>\n<p>label&#xff1a;\u7ba1\u7406\u6807\u7b7e<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods &#8211;show-labels<\/span><br \/>\nNAME                         READY   STATUS    RESTARTS   AGE     LABELS<br \/>\nwebcluster-9787d97f6-zl6q2   <span class=\"token number\">1<\/span>\/1     Running   <span class=\"token number\">0<\/span>          6m57s   <span class=\"token assign-left variable\">app<\/span><span class=\"token operator\">&#061;<\/span>webcluster,pod-template-hash<span class=\"token operator\">&#061;<\/span>9787d97f6<\/p>\n<p><span class=\"token comment\"># \u5220\u9664\u6807\u7b7e&#xff08;app- \u8868\u793a\u5220\u9664 app \u6807\u7b7e&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl label pods webcluster-9787d97f6-zl6q2 app-<\/span><br \/>\npod\/webcluster-9787d97f6-zl6q2 unlabeled<\/p>\n<p><span class=\"token comment\"># \u6dfb\u52a0\u6807\u7b7e<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl label pods webcluster-9787d97f6-zl6q2 app&#061;webcluster<\/span><br \/>\npod\/webcluster-9787d97f6-zl6q2 labeled<\/p>\n<p>\u6807\u7b7e\u662f Kubernetes \u8d44\u6e90\u5173\u8054\u7684\u57fa\u7840&#xff1a;Service \u9760\u6807\u7b7e\u627e Pod&#xff0c;\u63a7\u5236\u5668\u9760\u6807\u7b7e\u7ba1\u7406 Pod\u3002\u5220\u9664\u6807\u7b7e\u540e pod \u4f1a\u8131\u79bb\u63a7\u5236\u5668\u7684\u7ba1\u7406\u8303\u56f4\u3002<\/p>\n<\/p>\n<h4>2.4 \u6eda\u52a8\u66f4\u65b0\u547d\u4ee4<\/h4>\n<p>rollout status&#xff1a;\u67e5\u770b\u66f4\u65b0\u72b6\u6001<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl rollout status deployment webcluster<\/span><br \/>\ndeployment <span class=\"token string\">&#034;webcluster&#034;<\/span> successfully rolled out<\/p>\n<p>rollout restart&#xff1a;\u91cd\u542f\u5e94\u7528<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl rollout restart deployment webcluster<\/span><br \/>\ndeployment.apps\/webcluster restarted<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods<\/span><br \/>\nNAME                          READY   STATUS              RESTARTS   AGE<br \/>\nwebcluster-7bfd865747-jmhwl   <span class=\"token number\">1<\/span>\/1     Running             <span class=\"token number\">0<\/span>          19s<br \/>\nwebcluster-7bfd865747-qv2xt   <span class=\"token number\">0<\/span>\/1     Completed           <span class=\"token number\">0<\/span>          21s<br \/>\nwebcluster-9787d97f6-z7xv5    <span class=\"token number\">1<\/span>\/1     Running             <span class=\"token number\">0<\/span>          1s<br \/>\nwebcluster-9787d97f6-zl6q2    <span class=\"token number\">0<\/span>\/1     ContainerCreating   <span class=\"token number\">0<\/span>          0s<\/p>\n<p>restart \u4e0d\u662f\u91cd\u542f\u5df2\u6709\u5bb9\u5668&#xff0c;\u800c\u662f\u7528\u65b0\u7684 pod \u6a21\u677f\u91cd\u65b0\u521b\u5efa\u4e00\u6279 pod\u3002pod \u540d\u4e2d\u7684\u6a21\u677f\u54c8\u5e0c\u4ece 77c87d9946 \u53d8\u6210\u4e86 7bfd865747\u30019787d97f6&#xff0c;\u65e7 pod \u72b6\u6001\u53d8\u4e3a Completed\u3002<\/p>\n<\/p>\n<h4>2.5 \u5f39\u6027\u4f38\u7f29\u547d\u4ee4<\/h4>\n<p><span class=\"token comment\"># \u6269\u5bb9\u5230 4 \u4e2a\u526f\u672c<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl scale deployment webcluster &#8211;replicas 4<\/span><br \/>\ndeployment.apps\/webcluster scaled<br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods<\/span><br \/>\nNAME                         READY   STATUS    RESTARTS   AGE<br \/>\nwebcluster-9787d97f6-bh796   <span class=\"token number\">1<\/span>\/1     Running   <span class=\"token number\">0<\/span>          2s<br \/>\nwebcluster-9787d97f6-bh8jd   <span class=\"token number\">1<\/span>\/1     Running   <span class=\"token number\">0<\/span>          2s<br \/>\nwebcluster-9787d97f6-z7xv5   <span class=\"token number\">1<\/span>\/1     Running   <span class=\"token number\">0<\/span>          89s<br \/>\nwebcluster-9787d97f6-zl6q2   <span class=\"token number\">1<\/span>\/1     Running   <span class=\"token number\">0<\/span>          88s<\/p>\n<p><span class=\"token comment\"># \u7f29\u5bb9\u5230 1 \u4e2a\u526f\u672c<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl scale deployment webcluster &#8211;replicas 1<\/span><br \/>\ndeployment.apps\/webcluster scaled<\/p>\n<hr \/>\n<h3>\u4e09\u3001\u5229\u7528 yaml \u6587\u4ef6\u58f0\u660e\u8d44\u6e90<\/h3>\n<p>\u547d\u4ee4\u5f0f\u64cd\u4f5c\u9002\u5408\u4e34\u65f6\u5b9e\u9a8c&#xff0c;\u6b63\u5f0f\u7684\u8d44\u6e90\u914d\u7f6e\u7528 yaml \u6587\u4ef6\u58f0\u660e&#xff0c;\u4fbf\u4e8e\u7248\u672c\u7ba1\u7406\u3002<\/p>\n<\/p>\n<h4>3.1 \u5355 Pod \u8fd0\u884c\u591a\u5bb9\u5668<\/h4>\n<p>\u4e00\u4e2a Pod \u53ef\u4ee5\u653e\u591a\u4e2a\u5bb9\u5668&#xff0c;\u5b83\u4eec\u5171\u4eab\u7f51\u7edc\u548c\u5b58\u50a8\u3002\u4e0b\u9762\u5728 testpod \u4e2d\u540c\u65f6\u8fd0\u884c myapp \u548c busybox \u4e24\u4e2a\u5bb9\u5668&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl run testpod &#8211;image myapp:v1 &#8211;dry-run&#061;client -o yaml &gt; testpod.yaml<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim testpod.yaml<\/span><br \/>\napiVersion: v1<br \/>\nkind: Pod<br \/>\nmetadata:<br \/>\n  labels:<br \/>\n    run: testpod<br \/>\n  name: testpod<br \/>\nspec:<br \/>\n  containers:<br \/>\n  &#8211; image: myapp:v1<br \/>\n    name: myapp1<br \/>\n  &#8211; image: busyboxplus:latest<br \/>\n    name: busybox<br \/>\n    command:<br \/>\n    &#8211; \/bin\/sh<br \/>\n    &#8211; <span class=\"token parameter variable\">-c<\/span><br \/>\n    &#8211; <span class=\"token function\">sleep<\/span> <span class=\"token number\">10000<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl apply -f testpod.yaml<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods<\/span><br \/>\nNAME      READY   STATUS    RESTARTS   AGE<br \/>\ntestpod   <span class=\"token number\">2<\/span>\/2     Running   <span class=\"token number\">0<\/span>          2m41s<\/p>\n<p>READY 2\/2 \u8868\u793a\u4e24\u4e2a\u5bb9\u5668\u90fd\u6b63\u5e38\u8fd0\u884c\u3002\u8fdb\u5165 busybox \u5bb9\u5668&#xff0c;\u7528 127.0.0.1 \u8bbf\u95ee\u540c Pod \u5185 myapp \u7684\u670d\u52a1&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl exec -it pods\/testpod -c busybox &#8212; \/bin\/sh<\/span><br \/>\n\/ <span class=\"token comment\"># curl 127.0.0.1<\/span><br \/>\nHello MyApp <span class=\"token operator\">|<\/span> Version: v1 <span class=\"token operator\">|<\/span> <span class=\"token operator\">&lt;<\/span>a <span class=\"token assign-left variable\">href<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;hostname.html&#034;<\/span><span class=\"token operator\">&gt;<\/span>Pod Name<span class=\"token operator\">&lt;<\/span>\/a<span class=\"token operator\">&gt;<\/span><\/p>\n<p>\u591a\u5bb9\u5668\u5171\u4eab\u7f51\u7edc\u6808&#xff0c;\u6240\u4ee5\u5bb9\u5668\u95f4\u7528 localhost \u5c31\u80fd\u4e92\u901a\u3002exec \u65f6\u8981\u901a\u8fc7 -c \u6307\u5b9a\u8fdb\u54ea\u4e2a\u5bb9\u5668\u3002<\/p>\n<\/p>\n<h4>3.2 \u66b4\u9732\u7aef\u53e3<\/h4>\n<p>\u5728\u5bb9\u5668\u914d\u7f6e\u4e2d\u58f0\u660e\u7aef\u53e3\u6620\u5c04&#xff0c;\u53ef\u4ee5\u628a pod \u7684\u7aef\u53e3\u6620\u5c04\u5230\u5bbf\u4e3b\u673a\u4e0a&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim testpod.yaml<\/span><br \/>\napiVersion: v1<br \/>\nkind: Pod<br \/>\nmetadata:<br \/>\n  labels:<br \/>\n    run: testpod<br \/>\n  name: testpod<br \/>\nspec:<br \/>\n  containers:<br \/>\n  &#8211; image: myapp:v1<br \/>\n    name: myapp1<br \/>\n    ports:<br \/>\n    &#8211; name: http<br \/>\n      containerPort: <span class=\"token number\">80<\/span>    <span class=\"token comment\"># pod \u5185\u90e8\u5bb9\u5668\u7aef\u53e3<\/span><br \/>\n      hostPort: <span class=\"token number\">80<\/span>         <span class=\"token comment\"># pod \u6240\u5728\u8282\u70b9\u7aef\u53e3<\/span><br \/>\n      protocol: TCP        <span class=\"token comment\"># \u7aef\u53e3\u6240\u7528\u534f\u8bae<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl apply -f testpod.yaml<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods -o wide<\/span><br \/>\nNAME      READY   STATUS    RESTARTS   AGE     IP            NODE        NOMINATED NODE   READINESS GATES<br \/>\ntestpod   <span class=\"token number\">1<\/span>\/1     Running   <span class=\"token number\">0<\/span>          3m33s   <span class=\"token number\">10.244<\/span>.5.43   k8s-node2   <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span>           <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl k8s-node2<\/span><br \/>\nHello MyApp <span class=\"token operator\">|<\/span> Version: v1 <span class=\"token operator\">|<\/span> <span class=\"token operator\">&lt;<\/span>a <span class=\"token assign-left variable\">href<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;hostname.html&#034;<\/span><span class=\"token operator\">&gt;<\/span>Pod Name<span class=\"token operator\">&lt;<\/span>\/a<span class=\"token operator\">&gt;<\/span><\/p>\n<table>\n<tr>\u5b57\u6bb5\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td>name<\/td>\n<td>\u7aef\u53e3\u540d\u79f0<\/td>\n<\/tr>\n<tr>\n<td>containerPort<\/td>\n<td>\u5bb9\u5668\u5185\u670d\u52a1\u7684\u7aef\u53e3<\/td>\n<\/tr>\n<tr>\n<td>hostPort<\/td>\n<td>\u6620\u5c04\u5230\u5bbf\u4e3b\u673a\u7684\u7aef\u53e3<\/td>\n<\/tr>\n<tr>\n<td>protocol<\/td>\n<td>\u534f\u8bae\u7c7b\u578b&#xff0c;\u4e00\u822c TCP<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>pod \u8fd0\u884c\u5728 k8s-node2 \u4e0a&#xff0c;\u6240\u4ee5\u76f4\u63a5\u8bbf\u95ee k8s-node2 \u7684 80 \u7aef\u53e3\u5c31\u80fd\u62ff\u5230\u4e1a\u52a1\u9875\u9762\u3002<\/p>\n<\/p>\n<h4>3.3 \u6307\u5b9a\u73af\u5883\u53d8\u91cf<\/h4>\n<p>\u7528 env \u7ed9\u5bb9\u5668\u4f20\u73af\u5883\u53d8\u91cf\u3002\u4e0b\u9762\u7528 mysql \u548c phpmyadmin \u4e24\u4e2a\u5bb9\u5668\u6f14\u793a&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim mysql.yml<\/span><br \/>\napiVersion: v1<br \/>\nkind: Pod<br \/>\nmetadata:<br \/>\n  labels:<br \/>\n    run: mysql<br \/>\n  name: mysql<br \/>\nspec:<br \/>\n  containers:<br \/>\n  &#8211; image: mysql:8.0<br \/>\n    name: mysql8<br \/>\n    env:<br \/>\n    &#8211; name: MYSQL_ROOT_PASSWORD<br \/>\n      value: lee<\/p>\n<p>  &#8211; image: phpmyadmin:latest<br \/>\n    name: mysqladmin<br \/>\n    env:<br \/>\n    &#8211; name: PMA_ARBITRARY<br \/>\n      value: <span class=\"token string\">&#034;1&#034;<\/span><br \/>\n    ports:<br \/>\n    &#8211; name: phpadminport<br \/>\n      containerPort: <span class=\"token number\">80<\/span><br \/>\n      hostPort: <span class=\"token number\">80<\/span><br \/>\n      protocol: TCP<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl apply -f mysql.yml<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods -o wide<\/span><br \/>\nNAME    READY   STATUS    RESTARTS   AGE   IP            NODE        NOMINATED NODE   READINESS GATES<br \/>\nmysql   <span class=\"token number\">2<\/span>\/2     Running   <span class=\"token number\">0<\/span>          36s   <span class=\"token number\">10.244<\/span>.1.44   k8s-node1   <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span>           <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span><\/p>\n<p>MYSQL_ROOT_PASSWORD \u662f mysql \u955c\u50cf\u8981\u6c42\u7684 root \u5bc6\u7801\u53d8\u91cf&#xff0c;PMA_ARBITRARY \u8ba9 phpmyadmin \u53ef\u4ee5\u8fde\u63a5\u4efb\u610f mysql \u670d\u52a1\u5668\u3002<\/p>\n<\/p>\n<h4>3.4 \u9009\u62e9\u8fd0\u884c\u8282\u70b9<\/h4>\n<p>\u9ed8\u8ba4\u7531\u8c03\u5ea6\u5668\u51b3\u5b9a pod \u8dd1\u5728\u54ea\u53f0\u8282\u70b9\u3002\u60f3\u6307\u5b9a\u8282\u70b9&#xff0c;\u7528 nodeSelector \u6309\u8282\u70b9\u7684\u6807\u7b7e\u5339\u914d&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get nodes &#8211;show-labels<\/span><br \/>\nNAME         STATUS   ROLES           AGE   VERSION   LABELS<br \/>\nk8s-master   Ready    control-plane   29h   v1.35.7   <span class=\"token punctuation\">..<\/span>.,kubernetes.io\/hostname<span class=\"token operator\">&#061;<\/span>k8s-master,<span class=\"token punctuation\">..<\/span>.<br \/>\nk8s-node1    Ready    <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span>          29h   v1.35.7   <span class=\"token punctuation\">..<\/span>.,kubernetes.io\/hostname<span class=\"token operator\">&#061;<\/span>k8s-node1,<span class=\"token punctuation\">..<\/span>.<br \/>\nk8s-node2    Ready    <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span>          24h   v1.35.7   <span class=\"token punctuation\">..<\/span>.,kubernetes.io\/hostname<span class=\"token operator\">&#061;<\/span>k8s-node2,<span class=\"token punctuation\">..<\/span>.<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim mysql.yml<\/span><br \/>\nspec:<br \/>\n  nodeSelector:<br \/>\n    kubernetes.io\/hostname: k8s-node2   <span class=\"token comment\"># \u6307\u5b9a\u8c03\u5ea6\u5230 k8s-node2<\/span><br \/>\n  containers:<br \/>\n  <span class=\"token punctuation\">..<\/span>.<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl apply -f mysql.yml<\/span><br \/>\npod\/mysql created<br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods -o wide<\/span><br \/>\nNAME    READY   STATUS              RESTARTS   AGE   IP       NODE        NOMINATED NODE   READINESS GATES<br \/>\nmysql   <span class=\"token number\">0<\/span>\/2     ContainerCreating   <span class=\"token number\">0<\/span>          11s   <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span>   k8s-node2   <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span>           <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span><\/p>\n<p>pod \u88ab\u8c03\u5ea6\u5230\u4e86 k8s-node2&#xff0c;\u8282\u70b9\u9009\u62e9\u751f\u6548\u3002nodeSelector \u7684\u503c\u53d6\u81ea\u8282\u70b9\u7684\u6807\u7b7e&#xff0c;\u6bd4\u5982 kubernetes.io\/hostname\u3002<\/p>\n<\/p>\n<h4>3.5 \u5171\u4eab\u5bbf\u4e3b\u673a\u7f51\u7edc<\/h4>\n<p>hostNetwork: true \u8ba9 pod \u76f4\u63a5\u4f7f\u7528\u5bbf\u4e3b\u673a\u7f51\u7edc\u6808&#xff0c;\u4e0d\u518d\u5206\u914d\u72ec\u7acb\u7684 Pod IP&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim testpod.yaml<\/span><br \/>\napiVersion: v1<br \/>\nkind: Pod<br \/>\nmetadata:<br \/>\n  labels:<br \/>\n    run: testpod<br \/>\n  name: testpod<br \/>\nspec:<br \/>\n  hostNetwork: <span class=\"token boolean\">true<\/span><br \/>\n  containers:<br \/>\n  &#8211; image: busybox:latest<br \/>\n    name: busybox<br \/>\n    command:<br \/>\n    &#8211; \/bin\/sh<br \/>\n    &#8211; <span class=\"token parameter variable\">-c<\/span><br \/>\n    &#8211; <span class=\"token function\">sleep<\/span> <span class=\"token number\">10000<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl apply -f testpod.yaml<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl exec -it pods\/testpod -c busybox &#8212; \/bin\/sh<\/span><br \/>\n\/ <span class=\"token comment\"># ifconfig<\/span><br \/>\neth0      Link encap:Ethernet  HWaddr 00:0C:29:E9:E3:90<br \/>\n          inet addr:172.25.254.20  Bcast:172.25.254.255  Mask:255.255.255.0<br \/>\n<span class=\"token punctuation\">..<\/span>.<br \/>\nflannel.1 Link encap:Ethernet  HWaddr DE:5A:26:1C:E5:A0<br \/>\n          inet addr:10.244.5.0  Bcast:0.0.0.0  Mask:255.255.255.255<br \/>\n<span class=\"token punctuation\">..<\/span>.<\/p>\n<p>\u5bb9\u5668\u91cc\u770b\u5230\u7684 eth0 \u5730\u5740\u662f\u5bbf\u4e3b\u673a 172.25.254.20&#xff0c;\u8bf4\u660e pod \u76f4\u63a5\u7528\u4e86\u5bbf\u4e3b\u673a\u7684\u7f51\u5361\u3002<\/p>\n<\/p>\n<h4>3.6 \u8d44\u6e90\u4f18\u5148\u7ea7 QoS<\/h4>\n<p>Kubernetes \u6839\u636e\u5bb9\u5668\u662f\u5426\u8bbe\u7f6e requests&#xff08;\u671f\u671b\u503c&#xff09;\u548c limits&#xff08;\u4e0a\u9650\u503c&#xff09;&#xff0c;\u628a pod \u5212\u5206\u4e3a\u4e09\u4e2a QoS \u7b49\u7ea7\u3002\u8d44\u6e90\u7d27\u5f20\u65f6\u6309\u4f18\u5148\u7ea7\u56de\u6536&#xff1a;<\/p>\n<p>BestEffort&#xff1a;\u6ca1\u6709\u4efb\u4f55\u8d44\u6e90\u9650\u5236&#xff0c;\u4f18\u5148\u7ea7\u6700\u4f4e<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl describe pods testpod | grep &#034;QoS Class:&#034;<\/span><br \/>\nQoS Class:                   BestEffort<\/p>\n<p>Burstable&#xff1a;\u8bbe\u5b9a\u4e86\u8d44\u6e90\u9650\u5236&#xff0c;\u4f46\u671f\u671b\u503c\u548c\u9650\u5236\u503c\u4e0d\u540c&#xff0c;\u4f18\u5148\u7ea7\u6b21\u4e4b<\/p>\n<p>spec:<br \/>\n  containers:<br \/>\n  &#8211; image: busybox:latest<br \/>\n    name: busybox<br \/>\n    command:<br \/>\n    &#8211; \/bin\/sh<br \/>\n    &#8211; <span class=\"token parameter variable\">-c<\/span><br \/>\n    &#8211; <span class=\"token function\">sleep<\/span> <span class=\"token number\">10000<\/span><br \/>\n    resources:<br \/>\n      limits:<br \/>\n        cpu: 700m<br \/>\n        memory: 200M<br \/>\n      requests:<br \/>\n        cpu: 500m<br \/>\n        memory: 100M<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl describe pods testpod | grep &#034;QoS Class:&#034;<\/span><br \/>\nQoS Class:                   Burstable<\/p>\n<p>Guaranteed&#xff1a;\u671f\u671b\u503c\u548c\u6700\u5927\u4f7f\u7528\u9650\u5236\u76f8\u540c&#xff0c;\u4f18\u5148\u7ea7\u6700\u9ad8<\/p>\n<p>spec:<br \/>\n  containers:<br \/>\n  &#8211; image: busybox:latest<br \/>\n    name: busybox<br \/>\n    command:<br \/>\n    &#8211; \/bin\/sh<br \/>\n    &#8211; <span class=\"token parameter variable\">-c<\/span><br \/>\n    &#8211; <span class=\"token function\">sleep<\/span> <span class=\"token number\">10000<\/span><br \/>\n    resources:<br \/>\n      limits:<br \/>\n        cpu: 500m<br \/>\n        memory: 100M<br \/>\n      requests:<br \/>\n        cpu: 500m<br \/>\n        memory: 100M<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl apply -f testpod.yaml<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl describe pods testpod | grep &#034;QoS Class:&#034;<\/span><br \/>\nQoS Class:                   Guaranteed<\/p>\n<table>\n<tr>QoS \u7b49\u7ea7\u8d44\u6e90\u8bbe\u7f6e\u6761\u4ef6\u4f18\u5148\u7ea7<\/tr>\n<tbody>\n<tr>\n<td>BestEffort<\/td>\n<td>\u672a\u8bbe\u7f6e\u4efb\u4f55 requests \/ limits<\/td>\n<td>\u6700\u4f4e<\/td>\n<\/tr>\n<tr>\n<td>Burstable<\/td>\n<td>requests \u4e0e limits \u4e0d\u540c<\/td>\n<td>\u6b21\u4e4b<\/td>\n<\/tr>\n<tr>\n<td>Guaranteed<\/td>\n<td>requests \u4e0e limits \u76f8\u540c<\/td>\n<td>\u6700\u9ad8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4f18\u5148\u7ea7\u8d8a\u9ad8&#xff0c;\u8282\u70b9\u8d44\u6e90\u4e0d\u8db3\u65f6\u8d8a\u4e0d\u5bb9\u6613\u88ab\u9a71\u9010\u3002<\/p>\n<\/p>\n<h4>3.7 \u5bb9\u5668\u91cd\u542f\u89c4\u5219<\/h4>\n<p>restartPolicy \u51b3\u5b9a\u5bb9\u5668\u9000\u51fa\u540e\u662f\u5426\u91cd\u542f&#xff0c;\u6709\u4e09\u79cd\u53d6\u503c&#xff1a;<\/p>\n<table>\n<tr>\u7b56\u7565\u884c\u4e3a<\/tr>\n<tbody>\n<tr>\n<td>Always<\/td>\n<td>\u65e0\u8bba\u4ec0\u4e48\u539f\u56e0\u9000\u51fa\u90fd\u4f1a\u91cd\u65b0\u8fd0\u884c<\/td>\n<\/tr>\n<tr>\n<td>OnFailure<\/td>\n<td>\u975e\u6b63\u5e38\u5173\u95ed&#xff08;\u62a5\u9519\u9000\u51fa&#xff09;\u624d\u91cd\u542f<\/td>\n<\/tr>\n<tr>\n<td>Never<\/td>\n<td>\u5bb9\u5668\u5173\u95ed\u540e\u4e0d\u91cd\u542f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5b9e\u9a8c\u9a8c\u8bc1&#xff1a;\u5728\u8282\u70b9\u4e0a\u7528 docker rm -f \u5f3a\u5236\u5220\u9664\u5bb9\u5668&#xff0c;\u89c2\u5bdf pod \u7684\u53cd\u5e94\u3002<\/p>\n<p><span class=\"token comment\"># restartPolicy: Always&#xff0c;\u5bb9\u5668\u88ab\u5220\u9664\u540e\u4f1a\u81ea\u52a8\u62c9\u8d77<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods -o wide -w<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-node2 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># docker rm -f 3051d9de4c36<\/span><\/p>\n<p><span class=\"token comment\"># restartPolicy: OnFailure&#xff0c;\u6b63\u5e38\u9000\u51fa&#xff08;sleep \u547d\u4ee4\u8dd1\u5b8c&#xff09;\u540e\u4e0d\u91cd\u542f<\/span><br \/>\napiVersion: v1<br \/>\nkind: Pod<br \/>\nmetadata:<br \/>\n  labels:<br \/>\n    run: testpod<br \/>\n  name: testpod<br \/>\nspec:<br \/>\n  hostNetwork: <span class=\"token boolean\">true<\/span><br \/>\n  restartPolicy: OnFailure<br \/>\n  containers:<br \/>\n  &#8211; image: busybox:latest<br \/>\n    name: busybox<br \/>\n    command:<br \/>\n    &#8211; \/bin\/sh<br \/>\n    &#8211; <span class=\"token parameter variable\">-c<\/span><br \/>\n    &#8211; <span class=\"token function\">sleep<\/span> <span class=\"token number\">30<\/span><\/p>\n<p><span class=\"token comment\"># \u7b49 30 \u79d2\u8ba9\u5bb9\u5668\u4e2d\u7684\u547d\u4ee4\u8fd0\u884c\u5b8c\u6210\u540e\u518d\u6b21\u89c2\u5bdf<\/span><\/p>\n<p><span class=\"token comment\"># restartPolicy: Never&#xff0c;\u5bb9\u5668\u5173\u95ed\u540e\u4e0d\u91cd\u542f<\/span><br \/>\napiVersion: v1<br \/>\nkind: Pod<br \/>\nmetadata:<br \/>\n  labels:<br \/>\n    run: testpod<br \/>\n  name: testpod<br \/>\nspec:<br \/>\n  hostNetwork: <span class=\"token boolean\">true<\/span><br \/>\n  restartPolicy: Never<br \/>\n  containers:<br \/>\n  &#8211; image: busybox:latest<br \/>\n    name: busybox<br \/>\n    command:<br \/>\n    &#8211; \/bin\/sh<br \/>\n    &#8211; <span class=\"token parameter variable\">-c<\/span><br \/>\n    &#8211; <span class=\"token function\">sleep<\/span> <span class=\"token number\">30<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods -o wide -w<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-node2 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># docker rm -f 3051d9de4c36<\/span><\/p>\n<p>\u5bb9\u5668\u9000\u51fa\u540e\u662f\u5426\u91cd\u542f\u7531 restartPolicy \u51b3\u5b9a&#xff1a;Always \u65e0\u8bba\u4ec0\u4e48\u539f\u56e0\u90fd\u91cd\u65b0\u8fd0\u884c&#xff0c;OnFailure \u53ea\u5728\u975e\u6b63\u5e38\u5173\u95ed\u65f6\u91cd\u542f&#xff0c;Never \u5173\u95ed\u540e\u4e0d\u518d\u62c9\u8d77\u3002<\/p>\n<hr \/>\n<h3>\u56db\u3001Pod \u7684\u751f\u547d\u5468\u671f<\/h3>\n<p>Pod \u4ece\u521b\u5efa\u5230\u9500\u6bc1\u8981\u7ecf\u5386\u521d\u59cb\u5316\u3001\u8fd0\u884c\u3001\u63a2\u9488\u68c0\u67e5\u7b49\u9636\u6bb5&#xff1a;<\/p>\n<p>  #mermaid-svg-h0C2ViuGnpaOXx1V{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-h0C2ViuGnpaOXx1V .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-h0C2ViuGnpaOXx1V .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-h0C2ViuGnpaOXx1V .error-icon{fill:#552222;}#mermaid-svg-h0C2ViuGnpaOXx1V .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-h0C2ViuGnpaOXx1V .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-h0C2ViuGnpaOXx1V .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-h0C2ViuGnpaOXx1V .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-h0C2ViuGnpaOXx1V .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-h0C2ViuGnpaOXx1V .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-h0C2ViuGnpaOXx1V .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-h0C2ViuGnpaOXx1V .marker{fill:#333333;stroke:#333333;}#mermaid-svg-h0C2ViuGnpaOXx1V .marker.cross{stroke:#333333;}#mermaid-svg-h0C2ViuGnpaOXx1V svg{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-h0C2ViuGnpaOXx1V p{margin:0;}#mermaid-svg-h0C2ViuGnpaOXx1V .label{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;color:#333;}#mermaid-svg-h0C2ViuGnpaOXx1V .cluster-label text{fill:#333;}#mermaid-svg-h0C2ViuGnpaOXx1V .cluster-label span{color:#333;}#mermaid-svg-h0C2ViuGnpaOXx1V .cluster-label span p{background-color:transparent;}#mermaid-svg-h0C2ViuGnpaOXx1V .label text,#mermaid-svg-h0C2ViuGnpaOXx1V span{fill:#333;color:#333;}#mermaid-svg-h0C2ViuGnpaOXx1V .node rect,#mermaid-svg-h0C2ViuGnpaOXx1V .node circle,#mermaid-svg-h0C2ViuGnpaOXx1V .node ellipse,#mermaid-svg-h0C2ViuGnpaOXx1V .node polygon,#mermaid-svg-h0C2ViuGnpaOXx1V .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-h0C2ViuGnpaOXx1V .rough-node .label text,#mermaid-svg-h0C2ViuGnpaOXx1V .node .label text,#mermaid-svg-h0C2ViuGnpaOXx1V .image-shape .label,#mermaid-svg-h0C2ViuGnpaOXx1V .icon-shape .label{text-anchor:middle;}#mermaid-svg-h0C2ViuGnpaOXx1V .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-h0C2ViuGnpaOXx1V .rough-node .label,#mermaid-svg-h0C2ViuGnpaOXx1V .node .label,#mermaid-svg-h0C2ViuGnpaOXx1V .image-shape .label,#mermaid-svg-h0C2ViuGnpaOXx1V .icon-shape .label{text-align:center;}#mermaid-svg-h0C2ViuGnpaOXx1V .node.clickable{cursor:pointer;}#mermaid-svg-h0C2ViuGnpaOXx1V .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-h0C2ViuGnpaOXx1V .arrowheadPath{fill:#333333;}#mermaid-svg-h0C2ViuGnpaOXx1V .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-h0C2ViuGnpaOXx1V .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-h0C2ViuGnpaOXx1V .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-h0C2ViuGnpaOXx1V .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-h0C2ViuGnpaOXx1V .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-h0C2ViuGnpaOXx1V .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-h0C2ViuGnpaOXx1V .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-h0C2ViuGnpaOXx1V .cluster text{fill:#333;}#mermaid-svg-h0C2ViuGnpaOXx1V .cluster span{color:#333;}#mermaid-svg-h0C2ViuGnpaOXx1V div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-h0C2ViuGnpaOXx1V .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-h0C2ViuGnpaOXx1V rect.text{fill:none;stroke-width:0;}#mermaid-svg-h0C2ViuGnpaOXx1V .icon-shape,#mermaid-svg-h0C2ViuGnpaOXx1V .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-h0C2ViuGnpaOXx1V .icon-shape p,#mermaid-svg-h0C2ViuGnpaOXx1V .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-h0C2ViuGnpaOXx1V .icon-shape .label rect,#mermaid-svg-h0C2ViuGnpaOXx1V .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-h0C2ViuGnpaOXx1V .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-h0C2ViuGnpaOXx1V .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-h0C2ViuGnpaOXx1V :root{&#8211;mermaid-font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;}<\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u68c0\u6d4b\u5931\u8d25<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u6b63\u5e38<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u5c31\u7eea<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u672a\u5c31\u7eea<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>Pod \u521b\u5efa<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>init \u5bb9\u5668\u6309\u987a\u5e8f\u6267\u884c&#xff0c;\u5168\u90e8\u6210\u529f\u624d\u542f\u52a8\u4e3b\u5bb9\u5668<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u4e3b\u5bb9\u5668\u542f\u52a8Running<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u5b58\u6d3b\u63a2\u9488livenessProbe<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>kubelet \u91cd\u542f\u5bb9\u5668RestartCount &#043;1<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u5c31\u7eea\u63a2\u9488readinessProbe<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u52a0\u5165 Service Endpoints\u63a5\u6536\u6d41\u91cf<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u4ece Endpoints \u79fb\u9664\u4e0d\u63a5\u6536\u6d41\u91cf<\/p>\n<p><\/span><\/p>\n<h4>4.1 init \u5bb9\u5668<\/h4>\n<p>initContainers \u5728\u4e1a\u52a1\u5bb9\u5668\u4e4b\u524d\u8fd0\u884c&#xff0c;\u6309\u987a\u5e8f\u9010\u4e2a\u6267\u884c&#xff0c;\u5168\u90e8\u6210\u529f\u540e\u624d\u542f\u52a8\u4e3b\u5bb9\u5668\u3002\u9002\u5408\u505a\u524d\u7f6e\u68c0\u67e5\u3001\u521d\u59cb\u5316\u6570\u636e\u7b49\u3002<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl run webserver &#8211;image myapp:v1 &#8211;dry-run&#061;client -o yaml &gt; init-example.yml<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim init-example.yml<\/span><br \/>\napiVersion: v1<br \/>\nkind: Pod<br \/>\nmetadata:<br \/>\n  labels:<br \/>\n    run: webserver<br \/>\n  name: webserver<br \/>\nspec:<br \/>\n  initContainers:<br \/>\n  &#8211; name: busybox<br \/>\n    image: busybox:latest<br \/>\n    command:<br \/>\n    &#8211; \/bin\/sh<br \/>\n    &#8211; <span class=\"token parameter variable\">-c<\/span><br \/>\n    &#8211; <span class=\"token string\">&#034;until test -e \/testfile;do echo wating for myservice; sleep 2;done&#034;<\/span><br \/>\n  containers:<br \/>\n  &#8211; image: myapp:v1<br \/>\n    name: webserver<br \/>\n  restartPolicy: Always<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl apply -f init-example.yml<\/span><\/p>\n<p><span class=\"token comment\"># \u53e6\u4e00\u7ec8\u7aef\u76d1\u63a7 pod \u72b6\u6001<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># watch -n 1 kubectl get pods -o wide<\/span><\/p>\n<p><span class=\"token comment\"># init \u5bb9\u5668\u4f1a\u4e00\u76f4\u7b49\u5f85 \/testfile \u51fa\u73b0&#xff0c;\u6b64\u65f6\u4e3b\u5bb9\u5668\u672a\u542f\u52a8<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl exec -it pods\/webserver -c busybox &#8212; \/bin\/sh<\/span><br \/>\n\/ <span class=\"token comment\"># touch \/testfile<\/span><\/p>\n<p>touch \/testfile \u4e4b\u540e init \u5bb9\u5668\u7684\u7b49\u5f85\u6761\u4ef6\u6ee1\u8db3&#xff0c;\u4e3b\u5bb9\u5668\u624d\u5f00\u59cb\u521b\u5efa\u3002<\/p>\n<\/p>\n<h4>4.2 \u5b58\u6d3b\u63a2\u9488 livenessProbe<\/h4>\n<p>\u5b58\u6d3b\u63a2\u9488\u7528\u6765\u5224\u65ad\u5bb9\u5668\u662f\u5426\u8fd8\u6d3b\u7740\u3002\u6ca1\u6709\u5b58\u6d3b\u63a2\u9488\u65f6&#xff0c;\u8fdb\u7a0b\u6b7b\u6389\u5bb9\u5668\u4e0d\u4f1a\u81ea\u52a8\u6062\u590d&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl apply -f livness-example.yaml<\/span><\/p>\n<p><span class=\"token comment\"># \u6d4b\u8bd5\u64cd\u4f5c&#xff1a;\u505c\u6389 nginx \u8fdb\u7a0b<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl exec -it pods\/webserver -c webserver &#8212; \/bin\/sh<\/span><br \/>\n<span class=\"token comment\"># nginx -s stop<\/span><\/p>\n<p><span class=\"token comment\"># pod \u72b6\u6001\u4ecd\u662f Running&#xff0c;\u4f46\u8bbf\u95ee\u5df2\u7ecf\u5931\u8d25<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl 10.244.5.47<\/span><br \/>\ncurl: <span class=\"token punctuation\">(<\/span><span class=\"token number\">7<\/span><span class=\"token punctuation\">)<\/span> Failed to connect to <span class=\"token number\">10.244<\/span>.5.47 port <span class=\"token number\">80<\/span>: \u62d2\u7edd\u8fde\u63a5<\/p>\n<p>\u52a0\u4e86\u5b58\u6d3b\u63a2\u9488\u540e&#xff0c;\u63a2\u9488\u68c0\u6d4b\u5931\u8d25\u4f1a\u89e6\u53d1\u5bb9\u5668\u91cd\u542f&#xff1a;<\/p>\n<p>apiVersion: v1<br \/>\nkind: Pod<br \/>\nmetadata:<br \/>\n  labels:<br \/>\n    run: webserver<br \/>\n  name: webserver<br \/>\nspec:<br \/>\n  containers:<br \/>\n  &#8211; image: myapp:v1<br \/>\n    name: webserver<br \/>\n    command: <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;\/bin\/sh&#034;<\/span>, <span class=\"token string\">&#034;-c&#034;<\/span><span class=\"token punctuation\">]<\/span><br \/>\n    args:<br \/>\n    &#8211; <span class=\"token operator\">|<\/span><br \/>\n      nginx <span class=\"token parameter variable\">-g<\/span> <span class=\"token string\">&#034;daemon off;&#034;<\/span><br \/>\n      <span class=\"token function\">sleep<\/span> <span class=\"token number\">10000<\/span><br \/>\n    livenessProbe:<br \/>\n      tcpSocket:<br \/>\n        port: <span class=\"token number\">80<\/span><br \/>\n      initialDelaySeconds: <span class=\"token number\">3<\/span><br \/>\n      periodSeconds: <span class=\"token number\">1<\/span><br \/>\n      timeoutSeconds: <span class=\"token number\">1<\/span><br \/>\n  restartPolicy: Always<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods -o wide -w<\/span><\/p>\n<p><span class=\"token comment\"># \u505c\u6389 nginx \u540e&#xff0c;\u63a2\u9488\u8fde\u7eed\u68c0\u6d4b\u5931\u8d25&#xff0c;\u5bb9\u5668\u88ab kubelet \u91cd\u542f<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl exec -it pods\/webserver -c webserver &#8212; \/bin\/sh<\/span><br \/>\n\/ <span class=\"token comment\"># nginx -s stop<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl 10.244.5.66<\/span><br \/>\ncurl: <span class=\"token punctuation\">(<\/span><span class=\"token number\">7<\/span><span class=\"token punctuation\">)<\/span> Failed to connect to <span class=\"token number\">10.244<\/span>.5.66 port <span class=\"token number\">80<\/span>: \u62d2\u7edd\u8fde\u63a5<br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl 10.244.5.66<\/span><br \/>\nHello MyApp <span class=\"token operator\">|<\/span> Version: v1 <span class=\"token operator\">|<\/span> <span class=\"token operator\">&lt;<\/span>a <span class=\"token assign-left variable\">href<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;hostname.html&#034;<\/span><span class=\"token operator\">&gt;<\/span>Pod Name<span class=\"token operator\">&lt;<\/span>\/a<span class=\"token operator\">&gt;<\/span>   <span class=\"token comment\"># \u6062\u590d<\/span><\/p>\n<table>\n<tr>\u63a2\u9488\u53c2\u6570\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td>tcpSocket.port<\/td>\n<td>\u63a2\u6d4b\u65b9\u5f0f&#xff1a;TCP \u8fde\u63a5\u6307\u5b9a\u7aef\u53e3<\/td>\n<\/tr>\n<tr>\n<td>initialDelaySeconds<\/td>\n<td>\u5bb9\u5668\u542f\u52a8\u540e\u5ef6\u8fdf\u591a\u4e45\u5f00\u59cb\u63a2\u6d4b<\/td>\n<\/tr>\n<tr>\n<td>periodSeconds<\/td>\n<td>\u63a2\u6d4b\u5468\u671f<\/td>\n<\/tr>\n<tr>\n<td>timeoutSeconds<\/td>\n<td>\u5355\u6b21\u63a2\u6d4b\u8d85\u65f6\u65f6\u95f4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>nginx \u505c\u4e86\u4e4b\u540e&#xff0c;pod \u5148\u662f\u8fde\u4e0d\u4e0a&#xff0c;\u8fc7\u51e0\u79d2\u63a2\u9488\u53d1\u73b0\u5f02\u5e38\u81ea\u52a8\u91cd\u542f\u5bb9\u5668&#xff0c;\u670d\u52a1\u6062\u590d\u3002\u6ca1\u6709\u63a2\u9488\u65f6\u540c\u6837\u7684\u60c5\u51b5\u53ea\u80fd\u4eba\u5de5\u4ecb\u5165\u3002<\/p>\n<\/p>\n<h4>4.3 \u5c31\u7eea\u63a2\u9488 readinessProbe<\/h4>\n<p>\u5c31\u7eea\u63a2\u9488\u5224\u65ad\u5bb9\u5668\u662f\u5426\u51c6\u5907\u597d\u63a5\u6536\u6d41\u91cf\u3002\u6ca1\u6709\u5c31\u7eea\u63a2\u9488\u65f6&#xff0c;\u53ea\u8981\u5bb9\u5668 Running&#xff0c;Service \u5c31\u4f1a\u628a\u6d41\u91cf\u8f6c\u8fdb\u6765&#xff0c;\u5373\u4f7f\u4e1a\u52a1\u5b9e\u9645\u4e0d\u53ef\u7528&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim readness-example.yml<\/span><br \/>\napiVersion: v1<br \/>\nkind: Pod<br \/>\nmetadata:<br \/>\n  labels:<br \/>\n    run: webserver<br \/>\n  name: webserver<br \/>\nspec:<br \/>\n  containers:<br \/>\n  &#8211; image: myapp:v1<br \/>\n    name: webserver<br \/>\n  restartPolicy: Always<br \/>\n&#8212;<br \/>\napiVersion: v1<br \/>\nkind: Service<br \/>\nmetadata:<br \/>\n  labels:<br \/>\n    run: webserver<br \/>\n  name: webserver<br \/>\nspec:<br \/>\n  ports:<br \/>\n  &#8211; port: <span class=\"token number\">80<\/span><br \/>\n    protocol: TCP<br \/>\n    targetPort: <span class=\"token number\">80<\/span><br \/>\n  selector:<br \/>\n    run: webserver<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl apply -f readness-example.yml<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl describe svc webserver<\/span><br \/>\nEndpoints:                <span class=\"token number\">10.244<\/span>.5.67:80<\/p>\n<p><span class=\"token comment\"># \u5220\u9664\u9ed8\u8ba4\u53d1\u5e03\u6587\u4ef6&#xff0c;\u4e1a\u52a1\u5df2\u7ecf 403<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl exec -it pods\/webserver -c webserver &#8212; \/bin\/sh<\/span><br \/>\n\/usr\/share\/nginx\/html <span class=\"token comment\"># rm -fr index.html<\/span><\/p>\n<p><span class=\"token comment\"># Service \u7684 Endpoints \u91cc pod \u8fd8\u5728&#xff0c;\u4f46\u8bbf\u95ee\u8fd4\u56de 403<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl describe svc webserver<\/span><br \/>\nEndpoints:                <span class=\"token number\">10.244<\/span>.5.67:80    <span class=\"token comment\"># \u8fd8\u5728<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl 10.102.162.217<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>html<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>head<span class=\"token operator\">&gt;<\/span><span class=\"token operator\">&lt;<\/span>title<span class=\"token operator\">&gt;<\/span><span class=\"token number\">403<\/span> Forbidden<span class=\"token operator\">&lt;<\/span>\/title<span class=\"token operator\">&gt;<\/span><span class=\"token operator\">&lt;<\/span>\/head<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>body <span class=\"token assign-left variable\">bgcolor<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;white&#034;<\/span><span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>center<span class=\"token operator\">&gt;<\/span><span class=\"token operator\">&lt;<\/span>h<span class=\"token operator\"><span class=\"token file-descriptor important\">1<\/span>&gt;<\/span><span class=\"token number\">403<\/span> Forbidden<span class=\"token operator\">&lt;<\/span>\/h<span class=\"token operator\"><span class=\"token file-descriptor important\">1<\/span>&gt;<\/span><span class=\"token operator\">&lt;<\/span>\/center<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>hr<span class=\"token operator\">&gt;<\/span><span class=\"token operator\">&lt;<\/span>center<span class=\"token operator\">&gt;<\/span>nginx\/1.12.<span class=\"token operator\"><span class=\"token file-descriptor important\">2<\/span>&lt;<\/span>\/center<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>\/body<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>\/html<span class=\"token operator\">&gt;<\/span><\/p>\n<p>\u52a0\u4e86\u5c31\u7eea\u63a2\u9488\u540e&#xff0c;\u53ea\u6709\u63a2\u9488\u68c0\u67e5\u901a\u8fc7&#xff08;\u8fd9\u91cc\u662f\u5bf9 \/index.html \u505a HTTP GET&#xff09;pod \u624d\u4f1a\u88ab\u52a0\u5165 Endpoints&#xff1a;<\/p>\n<p>apiVersion: v1<br \/>\nkind: Pod<br \/>\nmetadata:<br \/>\n  labels:<br \/>\n    run: webserver<br \/>\n  name: webserver<br \/>\nspec:<br \/>\n  containers:<br \/>\n  &#8211; image: myapp:v1<br \/>\n    name: webserver<br \/>\n    readinessProbe:<br \/>\n      httpGet:<br \/>\n        path: \/index.html<br \/>\n        port: <span class=\"token number\">80<\/span><br \/>\n      initialDelaySeconds: <span class=\"token number\">3<\/span><br \/>\n      periodSeconds: <span class=\"token number\">2<\/span><br \/>\n      timeoutSeconds: <span class=\"token number\">1<\/span><br \/>\n  restartPolicy: Always<br \/>\n&#8212;<br \/>\napiVersion: v1<br \/>\nkind: Service<br \/>\nmetadata:<br \/>\n  labels:<br \/>\n    run: webserver<br \/>\n  name: webserver<br \/>\nspec:<br \/>\n  ports:<br \/>\n  &#8211; port: <span class=\"token number\">80<\/span><br \/>\n    protocol: TCP<br \/>\n    targetPort: <span class=\"token number\">80<\/span><br \/>\n  selector:<br \/>\n    run: webserver<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl apply -f readness-example.yml<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;k8s-master pod<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># kubectl get pods -o wide<\/span><br \/>\nNAME        READY   STATUS    RESTARTS   AGE   IP            NODE        NOMINATED NODE   READINESS GATES<br \/>\nwebserver   <span class=\"token number\">1<\/span>\/1     Running   <span class=\"token number\">0<\/span>          7s    <span class=\"token number\">10.244<\/span>.5.69   k8s-node2   <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span>           <span class=\"token operator\">&lt;<\/span>none<span class=\"token operator\">&gt;<\/span><\/p>\n<table>\n<tr>\u63a2\u9488\u4f5c\u7528\u5931\u8d25\u540e\u679c<\/tr>\n<tbody>\n<tr>\n<td>livenessProbe<\/td>\n<td>\u5224\u65ad\u5bb9\u5668\u662f\u5426\u5b58\u6d3b<\/td>\n<td>\u91cd\u542f\u5bb9\u5668<\/td>\n<\/tr>\n<tr>\n<td>readinessProbe<\/td>\n<td>\u5224\u65ad\u5bb9\u5668\u662f\u5426\u5c31\u7eea<\/td>\n<td>\u4ece Endpoints \u6458\u9664&#xff0c;\u4e0d\u63a5\u6536\u6d41\u91cf<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5b58\u6d3b\u63a2\u9488\u7ba1&#034;\u8981\u4e0d\u8981\u91cd\u542f&#034;&#xff0c;\u5c31\u7eea\u63a2\u9488\u7ba1&#034;\u80fd\u4e0d\u80fd\u63a5\u6d41\u91cf&#034;&#xff0c;\u4e24\u8005\u804c\u8d23\u4e0d\u540c&#xff0c;\u4e00\u822c\u540c\u65f6\u914d\u7f6e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u5f55<br \/>\n\u4e00\u3001\u547d\u4ee4\u5f0f\u5bf9\u8c61\u7ba1\u7406 1.1 \u547d\u540d\u7a7a\u95f4\u7ba1\u74061.2 Pod \u7684\u521b\u5efa\u4e0e\u67e5\u770b1.3 Pod \u6545\u969c\u6392\u67e51.4 Pod \u7684\u5220\u9664 \u4e8c\u3001kubectl \u547d\u4ee4\u5b9e\u64cd 2.1 \u5b9e\u9a8c\u955c\u50cf\u51c6\u59072.2 \u7528 dry-run \u751f\u6210 yaml \u6587\u4ef62.3 \u5e38\u7528\u7ba1\u7406\u547d\u4ee42.4 \u6eda\u52a8\u66f4\u65b0\u547d\u4ee42.5 \u5f39\u6027\u4f38\u7f29\u547d\u4ee4 \u4e09\u3001\u5229\u7528 yaml \u6587\u4ef6\u58f0\u660e\u8d44\u6e90 3.1 \u5355 Pod \u8fd0\u884c\u591a\u5bb9\u56683.2 \u66b4\u9732\u7aef\u53e33.3 \u6307\u5b9a\u73af\u5883\u53d8\u91cf3.4 \u9009\u62e9\u8fd0\u884c\u8282\u70b93.5 \u5171\u4eab\u5bbf\u4e3b\u673a\u7f51\u7edc3.6 \u8d44\u6e90\u4f18\u5148\u7ea7 QoS3.7 \u5bb9\u5668\u91cd\u542f\u89c4\u5219 \u56db\u3001P<\/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,763,121],"topic":[],"class_list":["post-108107","post","type-post","status-publish","format-standard","hentry","category-server","tag-kubernetes","tag-763","tag-121"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>k8spod\u7ba1\u7406\u77e5\u8bc6\u70b9\u603b\u7ed3 - \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\/108107.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"k8spod\u7ba1\u7406\u77e5\u8bc6\u70b9\u603b\u7ed3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u76ee\u5f55 \u4e00\u3001\u547d\u4ee4\u5f0f\u5bf9\u8c61\u7ba1\u7406 1.1 \u547d\u540d\u7a7a\u95f4\u7ba1\u74061.2 Pod \u7684\u521b\u5efa\u4e0e\u67e5\u770b1.3 Pod \u6545\u969c\u6392\u67e51.4 Pod \u7684\u5220\u9664 \u4e8c\u3001kubectl \u547d\u4ee4\u5b9e\u64cd 2.1 \u5b9e\u9a8c\u955c\u50cf\u51c6\u59072.2 \u7528 dry-run \u751f\u6210 yaml \u6587\u4ef62.3 \u5e38\u7528\u7ba1\u7406\u547d\u4ee42.4 \u6eda\u52a8\u66f4\u65b0\u547d\u4ee42.5 \u5f39\u6027\u4f38\u7f29\u547d\u4ee4 \u4e09\u3001\u5229\u7528 yaml \u6587\u4ef6\u58f0\u660e\u8d44\u6e90 3.1 \u5355 Pod \u8fd0\u884c\u591a\u5bb9\u56683.2 \u66b4\u9732\u7aef\u53e33.3 \u6307\u5b9a\u73af\u5883\u53d8\u91cf3.4 \u9009\u62e9\u8fd0\u884c\u8282\u70b93.5 \u5171\u4eab\u5bbf\u4e3b\u673a\u7f51\u7edc3.6 \u8d44\u6e90\u4f18\u5148\u7ea7 QoS3.7 \u5bb9\u5668\u91cd\u542f\u89c4\u5219 \u56db\u3001P\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/108107.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-20T17:11:55+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=\"19 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/108107.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/108107.html\",\"name\":\"k8spod\u7ba1\u7406\u77e5\u8bc6\u70b9\u603b\u7ed3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-20T17:11:55+00:00\",\"dateModified\":\"2026-09-20T17:11:55+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/108107.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/108107.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/108107.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"k8spod\u7ba1\u7406\u77e5\u8bc6\u70b9\u603b\u7ed3\"}]},{\"@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":"k8spod\u7ba1\u7406\u77e5\u8bc6\u70b9\u603b\u7ed3 - \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\/108107.html","og_locale":"zh_CN","og_type":"article","og_title":"k8spod\u7ba1\u7406\u77e5\u8bc6\u70b9\u603b\u7ed3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u76ee\u5f55 \u4e00\u3001\u547d\u4ee4\u5f0f\u5bf9\u8c61\u7ba1\u7406 1.1 \u547d\u540d\u7a7a\u95f4\u7ba1\u74061.2 Pod \u7684\u521b\u5efa\u4e0e\u67e5\u770b1.3 Pod \u6545\u969c\u6392\u67e51.4 Pod \u7684\u5220\u9664 \u4e8c\u3001kubectl \u547d\u4ee4\u5b9e\u64cd 2.1 \u5b9e\u9a8c\u955c\u50cf\u51c6\u59072.2 \u7528 dry-run \u751f\u6210 yaml \u6587\u4ef62.3 \u5e38\u7528\u7ba1\u7406\u547d\u4ee42.4 \u6eda\u52a8\u66f4\u65b0\u547d\u4ee42.5 \u5f39\u6027\u4f38\u7f29\u547d\u4ee4 \u4e09\u3001\u5229\u7528 yaml \u6587\u4ef6\u58f0\u660e\u8d44\u6e90 3.1 \u5355 Pod \u8fd0\u884c\u591a\u5bb9\u56683.2 \u66b4\u9732\u7aef\u53e33.3 \u6307\u5b9a\u73af\u5883\u53d8\u91cf3.4 \u9009\u62e9\u8fd0\u884c\u8282\u70b93.5 \u5171\u4eab\u5bbf\u4e3b\u673a\u7f51\u7edc3.6 \u8d44\u6e90\u4f18\u5148\u7ea7 QoS3.7 \u5bb9\u5668\u91cd\u542f\u89c4\u5219 \u56db\u3001P","og_url":"https:\/\/www.wsisp.com\/helps\/108107.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-20T17:11:55+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"19 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/108107.html","url":"https:\/\/www.wsisp.com\/helps\/108107.html","name":"k8spod\u7ba1\u7406\u77e5\u8bc6\u70b9\u603b\u7ed3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-20T17:11:55+00:00","dateModified":"2026-09-20T17:11:55+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/108107.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/108107.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/108107.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"k8spod\u7ba1\u7406\u77e5\u8bc6\u70b9\u603b\u7ed3"}]},{"@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\/108107","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=108107"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/108107\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=108107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=108107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=108107"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=108107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}