{"id":127,"date":"2026-07-23T23:40:58","date_gmt":"2026-07-23T15:40:58","guid":{"rendered":"https:\/\/fsdata.site\/?p=127"},"modified":"2026-07-23T23:40:58","modified_gmt":"2026-07-23T15:40:58","slug":"kubernetes-pod-troubleshooting","status":"publish","type":"post","link":"https:\/\/fsdata.site\/?p=127","title":{"rendered":"Kubernetes Pod \u8c03\u5ea6\u4e0e\u6545\u969c\u6392\u67e5\u5b9e\u6218"},"content":{"rendered":"<h2>Pod \u662f\u600e\u4e48\u88ab\u8c03\u5ea6\u548c\u8fd0\u884c\u7684<\/h2>\n<p>\u7406\u89e3 Kubernetes \u6392\u9519\uff0c\u5148\u8981\u7406\u89e3 Pod \u7684\u751f\u547d\u5468\u671f\uff1a<strong>Pending \u2192 ContainerCreating \u2192 Running \u2192 Succeeded\/Failed<\/strong>\u3002\u4efb\u4f55\u4e00\u4e2a\u9636\u6bb5\u5361\u4f4f\u90fd\u4f1a\u5728 <code>kubectl get pods<\/code> \u91cc\u770b\u5230\u5bf9\u5e94\u7684\u5f02\u5e38\u72b6\u6001\u3002\u672c\u6587\u6309&#8221;\u5361\u5728\u54ea\u3001\u600e\u4e48\u67e5\u3001\u600e\u4e48\u4fee&#8221;\u6765\u8bb2\u3002<\/p>\n<h2>\u4e00\u3001\u8c03\u5ea6\u76f8\u5173\uff1aPod \u4e00\u76f4 Pending<\/h2>\n<p>Pending \u901a\u5e38\u662f\u8c03\u5ea6\u5668\u627e\u4e0d\u5230\u5408\u9002\u7684\u8282\u70b9\u3002\u5e38\u89c1\u539f\u56e0\uff1a<\/p>\n<ul>\n<li>\u8d44\u6e90\u8bf7\u6c42\u8d85\u8fc7\u8282\u70b9\u5269\u4f59\uff08CPU\/Memory request \u592a\u5927\uff09<\/li>\n<li>\u8282\u70b9\u6709 taint\uff0cPod \u6ca1\u6709\u5bf9\u5e94 toleration<\/li>\n<li>nodeSelector \/ affinity \u6761\u4ef6\u8fc7\u4e25\uff0c\u6ca1\u6709\u8282\u70b9\u6ee1\u8db3<\/li>\n<\/ul>\n<pre><code>kubectl describe pod my-pod\n# \u770b Events \u6bb5\uff0c\u901a\u5e38\u76f4\u63a5\u5199\u7740 \"0\/3 nodes are available: ...\"\n<\/code><\/pre>\n<h3>\u7528 nodeSelector \/ affinity \u63a7\u5236\u8c03\u5ea6<\/h3>\n<pre><code>spec:\n  nodeSelector:\n    disktype: ssd\n  tolerations:\n  - key: \"gpu\"\n    operator: \"Equal\"\n    value: \"true\"\n    effect: \"NoSchedule\"\n<\/code><\/pre>\n<h2>\u4e8c\u3001\u955c\u50cf\u76f8\u5173\uff1aImagePullBackOff<\/h2>\n<p>\u955c\u50cf\u62c9\u4e0d\u4e0b\u6765\uff0c\u4e5d\u6210\u662f\u8fd9\u51e0\u79cd\uff1a<\/p>\n<ul>\n<li>\u955c\u50cf\u540d\/Tag \u5199\u9519<\/li>\n<li>\u79c1\u6709\u4ed3\u5e93\u6ca1\u914d <code>imagePullSecrets<\/code><\/li>\n<li>\u8282\u70b9\u7f51\u7edc\u8bbf\u95ee\u4e0d\u4e86\u955c\u50cf\u4ed3\u5e93\uff08\u5c24\u5176\u56fd\u5185\u62c9 docker.io\uff09<\/li>\n<\/ul>\n<pre><code>kubectl describe pod my-pod | grep -A5 Events\n# \u82e5\u770b\u5230 \"pull access denied\" \u6216 \"manifest unknown\" \u5373\u4e0a\u8ff0\u539f\u56e0\n<\/code><\/pre>\n<h2>\u4e09\u3001\u542f\u52a8\u76f8\u5173\uff1aCrashLoopBackOff<\/h2>\n<p>\u5bb9\u5668\u8d77\u6765\u53c8\u5d29\uff0c\u5faa\u73af\u91cd\u542f\u3002\u6392\u67e5\u987a\u5e8f\uff1a<\/p>\n<pre><code># 1. \u770b\u5bb9\u5668\u65e5\u5fd7\uff08\u52a0 --previous \u770b\u4e0a\u4e00\u6b21\u5d29\u6e83\u7684\u65e5\u5fd7\uff09\nkubectl logs my-pod --previous\n\n# 2. \u770b\u5177\u4f53\u4e8b\u4ef6\nkubectl describe pod my-pod\n\n# 3. \u5982\u679c\u662f\u914d\u7f6e\/\u4f9d\u8d56\u95ee\u9898\uff0c\u53ef\u4e34\u65f6\u8fdb\u5bb9\u5668\u8c03\u8bd5\nkubectl exec -it my-pod -- sh\n<\/code><\/pre>\n<p>\u5e38\u89c1\u6839\u56e0\uff1a\u5e94\u7528\u542f\u52a8\u4f9d\u8d56\u7684\u6570\u636e\u5e93\u6ca1\u5c31\u7eea\u3001\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\u9519\u8bef\u3001\u5185\u5b58\u8d85\u9650\u88ab OOMKilled\uff08\u770b Events \u91cc\u6709\u6ca1\u6709 <code>OOMKilled<\/code>\uff09\u3002<\/p>\n<h2>\u56db\u3001\u5c31\u7eea\u4e0e\u5b58\u6d3b\u63a2\u9488<\/h2>\n<p>\u5f88\u591a&#8221;\u670d\u52a1\u8d77\u6765\u4e86\u4f46\u8bbf\u95ee 503&#8243;\u7684\u95ee\u9898\uff0c\u662f\u5c31\u7eea\u63a2\u9488\u6ca1\u914d\u5bf9\uff1a<\/p>\n<pre><code>livenessProbe:\n  httpGet: { path: \/health, port: 8080 }\n  initialDelaySeconds: 30\n  periodSeconds: 10\nreadinessProbe:\n  httpGet: { path: \/ready, port: 8080 }\n  periodSeconds: 5\n<\/code><\/pre>\n<p><strong>liveness<\/strong> \u5931\u8d25\u4f1a\u91cd\u542f\u5bb9\u5668\uff0c<strong>readiness<\/strong> \u5931\u8d25\u4f1a\u628a Pod \u4ece Service \u540e\u7aef\u6458\u6389\u4f46\u4e0d\u91cd\u542f\u3002\u4e24\u8005\u522b\u7528\u540c\u4e00\u4e2a\u8def\u5f84\uff0c\u5426\u5219\u4f1a\u8bef\u6740\u3002<\/p>\n<h2>\u4e94\u3001\u8d44\u6e90\u9650\u5236\u522b\u5fd8\u4e86<\/h2>\n<pre><code>resources:\n  requests: { cpu: \"100m\", memory: \"256Mi\" }\n  limits:   { cpu: \"500m\", memory: \"512Mi\" }\n<\/code><\/pre>\n<p>\u4e0d\u8bbe limits \u5bb9\u6613\u88ab\u90bb\u5c45&#8221;\u5435\u9192&#8221;\u6216\u81ea\u5df1\u628a\u8282\u70b9\u5185\u5b58\u5403\u6ee1\u3002\u8bbe\u4e86 memory limit \u53c8\u8d85\u9650\u5c31\u4f1a OOMKilled\uff0c\u8981\u7ed3\u5408\u65e5\u5fd7\u5224\u65ad\u662f\u8c03\u5927\u8fd8\u662f\u4fee\u5185\u5b58\u6cc4\u6f0f\u3002<\/p>\n<h2>\u5c0f\u7ed3<\/h2>\n<p>K8s \u6392\u9519\u7684\u6838\u5fc3\u5fc3\u6cd5\u662f\uff1a<strong>\u5148\u7528 <code>describe<\/code> \u770b Events\uff0c\u518d\u7528 <code>logs --previous<\/code> \u770b\u5d29\u6e83\u539f\u56e0\uff0c\u6700\u540e\u7528 <code>exec<\/code> \u8fdb\u5bb9\u5668\u786e\u8ba4<\/strong>\u3002\u7edd\u5927\u591a\u6570 Pod \u5f02\u5e38\u90fd\u9003\u4e0d\u51fa Pending \/ ImagePull \/ CrashLoop \u8fd9\u4e09\u7c7b\uff0c\u7167\u7740\u4e0a\u9762\u7684\u6e05\u5355\u9010\u4e00\u6392\u9664\u5373\u53ef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ece Pending \/ ImagePullBackOff \/ CrashLoopBackOff \u4e09\u7c7b\u5f02\u5e38\u5165\u624b\uff0c\u7528 describe+logs \u5feb\u901f\u5b9a\u4f4d\u3002<\/p>\n","protected":false},"author":2,"featured_media":116,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-127","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/fsdata.site\/index.php?rest_route=\/wp\/v2\/posts\/127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fsdata.site\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fsdata.site\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fsdata.site\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/fsdata.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=127"}],"version-history":[{"count":0,"href":"https:\/\/fsdata.site\/index.php?rest_route=\/wp\/v2\/posts\/127\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fsdata.site\/index.php?rest_route=\/wp\/v2\/media\/116"}],"wp:attachment":[{"href":"https:\/\/fsdata.site\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fsdata.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fsdata.site\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}