{"id":1880,"date":"2022-06-28T08:33:14","date_gmt":"2022-06-28T08:33:14","guid":{"rendered":"https:\/\/www.ipcpu.com\/?p=1880"},"modified":"2022-07-31T08:35:30","modified_gmt":"2022-07-31T08:35:30","slug":"k8s-event","status":"publish","type":"post","link":"https:\/\/c.ipcpu.com\/2022\/06\/k8s-event\/","title":{"rendered":"K8S Event\u4e8b\u4ef6\u5185\u5bb9\u5206\u6790\u548c\u544a\u8b66"},"content":{"rendered":"

K8S Event\u4e8b\u4ef6\u5185\u5bb9\u5206\u6790.md <\/p>\n

\u4e00\u3001\u6982\u8ff0<\/a>
\u4e8c\u3001event\u4fe1\u606f\u7684\u67e5\u770b<\/a>
\u4e09\u3001event\u4fe1\u606f\u7684\u5206\u7c7b<\/a>
\u56db\u3001Event\u7684\u62a5\u8b66<\/a>
\u53c2\u8003\u8d44\u6599<\/a><\/div>\n

toc<\/a><\/p>\n

\u4e00\u3001\u6982\u8ff0<\/h2>\n

k8s\u7684Event\u4e8b\u4ef6\u662f\u4e00\u79cd\u8d44\u6e90\u5bf9\u8c61\uff0c\u7528\u4e8e\u5c55\u793a\u96c6\u7fa4\u5185\u53d1\u751f\u7684\u60c5\u51b5\uff0ck8s\u7cfb\u7edf\u4e2d\u7684\u5404\u4e2a\u7ec4\u4ef6\u4f1a\u5c06\u8fd0\u884c\u65f6\u53d1\u751f\u7684\u5404\u79cd\u4e8b\u4ef6\u4e0a\u62a5\u7ed9apiserver \u3002\u53ef\u4ee5\u901a\u8fc7kubectl get event \u6216 kubectl describe pod podName \u547d\u4ee4\u663e\u793a\u4e8b\u4ef6\uff0c\u67e5\u770bk8s\u96c6\u7fa4\u4e2d\u53d1\u751f\u4e86\u54ea\u4e9b\u4e8b\u4ef6\u3002
\napiserver \u4f1a\u5c06Event\u4e8b\u4ef6\u5b58\u5728etcd\u96c6\u7fa4\u4e2d\uff0c\u4e3a\u907f\u514d\u78c1\u76d8\u7a7a\u95f4\u88ab\u586b\u6ee1\uff0c\u6545\u5f3a\u5236\u6267\u884c\u4fdd\u7559\u7b56\u7565\uff1a\u5728\u6700\u540e\u4e00\u6b21\u7684\u4e8b\u4ef6\u53d1\u751f\u540e\uff0c\u5220\u96641\u5c0f\u65f6\u4e4b\u524d\u53d1\u751f\u7684\u4e8b\u4ef6\u3002<\/p>\n

\u4e8c\u3001event\u4fe1\u606f\u7684\u67e5\u770b<\/h2>\n

\u5728K8S\u96c6\u7fa4\u7684master\u8282\u70b9\u4e0a\u8fd0\u884c<\/p>\n

\n
kubectl  get event -n project-1573<\/code><\/pre>\n<\/div>\n

\u663e\u793a\u5185\u5bb9\u5982\u4e0b<\/p>\n

\n
LAST SEEN   TYPE      REASON              OBJECT                                MESSAGE\n10m         Normal    SuccessfulRescale   horizontalpodautoscaler\/hpa-10143     New size: 12; reason: cpu resource utilization (percentage of request) above target\n10m         Normal    Scheduled           pod\/service-10143-54fc6ff487-qwlds    Successfully assigned project-1573\/service-10143-54fc6ff487-qwlds to 10-192-2-23.mars.ipcpu.com\n10m         Normal    Pulling             pod\/service-10143-54fc6ff487-qwlds    Pulling image \"reg.ipcpu.com\/push\/push-jms-consumer:prod-1.0-SNAPSHOT-1321\"\n10m         Normal    Pulled              pod\/service-10143-54fc6ff487-qwlds    Successfully pulled image \"reg.ipcpu.com\/push\/push-jms-consumer:prod-1.0-SNAPSHOT-1321\"\n10m         Normal    Created             pod\/service-10143-54fc6ff487-qwlds    Created container service-10143\n10m         Normal    Started             pod\/service-10143-54fc6ff487-qwlds    Started container service-10143\n9m3s        Warning   Unhealthy           pod\/service-10143-54fc6ff487-qwlds    Readiness probe failed: Get http:\/\/10.193.49.247:9203\/actuator\/health: dial tcp 10.193.49.247:9203: connect: connection refused\n10m         Normal    SuccessfulCreate    replicaset\/service-10143-54fc6ff487   Created pod: service-10143-54fc6ff487-xk5zn\n10m         Normal    ScalingReplicaSet   deployment\/service-10143              Scaled up replica set service-10143-54fc6ff487 to 12<\/code><\/pre>\n<\/div>\n

\u7b2c\u4e00\u5217\u662f\u53d1\u751f\u65f6\u95f4\uff0c\u7b2c\u4e8c\u5217\u662f\u7c7b\u578b\u6709Normal\u3001Warning\u7c7b\u578b\uff0c\u7b2c\u4e09\u5217\u662fReason\uff0c\u662f\u4e00\u4e2a\u7b80\u5355\u8bcd\u7ec4\uff0c\u7b2c\u56db\u5217\u662f\u5b9e\u4f8b\u7684ID\u4fe1\u606f\uff0c\u7b2c\u4e94\u5217\u662f\u8be6\u7ec6\u4fe1\u606f\u3002
\n\u5982\u679c\u89c9\u7740\u4e0a\u8ff0\u4fe1\u606f\u4e0d\u591f\u5168\u9762\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528ymal\u683c\u5f0f\u67e5\u770b\u6267\u884c<\/p>\n

\n
kubectl  get event -n project-1573  -o yaml<\/code><\/pre>\n<\/div>\n

\u5185\u5bb9\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n

\n
- apiVersion: v1\n  count: 34\n  eventTime: null\n  firstTimestamp: \"2021-05-26T16:40:14Z\"\n  involvedObject:\n    apiVersion: v1\n    fieldPath: spec.containers{service-16382}\n    kind: Pod\n    name: service-16382-5875dbbf9b-q8lm7\n    namespace: project-1573\n    resourceVersion: \"264300624\"\n    uid: 56e46978-a68f-483a-ace2-8489a49d74be\n  kind: Event\n  lastTimestamp: \"2021-06-01T06:16:24Z\"\n  message: 'Liveness probe failed: Get http:\/\/10.193.8.143:5000\/actuator\/health: net\/http:\n    request canceled (Client.Timeout exceeded while awaiting headers)'\n  metadata:\n    creationTimestamp: \"2021-06-01T06:16:24Z\"\n    name: service-16382-5875dbbf9b-q8lm7.16f2b52c43b0c499\n    namespace: project-1573\n    resourceVersion: \"266833717\"\n    selfLink: \/api\/v1\/namespaces\/project-1573\/events\/service-16382-5875dbbf9b-q8lm7.16f2b52c43b0c499\n    uid: 18704234-943b-43bf-8738-4ce8185402f1\n  reason: Unhealthy\n  reportingComponent: \"\"\n  reportingInstance: \"\"\n  source:\n    component: kubelet\n    host: 10-192-2-21.mars.ipcpu.com\n  type: Warning\nkind: List\nmetadata:\n  resourceVersion: \"\"\n  selfLink: \"\"<\/code><\/pre>\n<\/div>\n

\u4e09\u3001event\u4fe1\u606f\u7684\u5206\u7c7b<\/h2>\n

\u6211\u4eec\u6536\u96c6\u4e86\u7ebf\u4e0a\u96c6\u7fa4\u7684\u6570\u636e\uff0c\u4e3b\u8981\u4ee5\u4e0b\u51e0\u79cd\uff0c
\n
\n
\n<\/p>\n

\u6211\u4eec\u6839\u636eReason\u505a\u4e86\u4e00\u4e2a\u997c\u56fe\uff0c\u5982\u4e0b
\n<\/p>\n

\u56db\u3001Event\u7684\u62a5\u8b66<\/h2>\n

\u5728\u5b9e\u73b0\u62a5\u8b66\u4e4b\u524d\uff0c\u6700\u597d\u5c06Event\u4fe1\u606f\u8fdc\u7a0b\u5b58\u50a8\u5230\u96c6\u4e2d\u7684ES\u6216\u8005\u662f\u963f\u91cc\u4e91\u65e5\u5fd7\u670d\u52a1SLS\u3002
\n\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u8fdb\u884c\u96c6\u4e2d\u7684\u67e5\u8be2\u5206\u6790\u3002
\n\u4f7f\u7528kubernetes-event-exporter\u7ec4\u4ef6\u53ef\u4ee5\u5b9e\u73b0\uff0c\u8fd9\u91cc\u5c31\u4e0d\u8c08\u8be6\u7ec6\u7684\u65b9\u6cd5\u4e86\u3002
\n\u4ee5\u963f\u91cc\u4e91\u65e5\u5fd7\u670d\u52a1SLS\u4e3a\u4f8b\uff0c\u6211\u4eec\u7684\u62a5\u8b66\u67e5\u8be2\u8bed\u53e5\u5982\u4e0b\uff1a<\/p>\n

\n
eventId.type: Warning | select \"eventId.reason\", \"eventId.involvedObject.kind\", \"eventId.involvedObject.namespace\", \"eventId.metadata.name\", \"eventId.message\", \"eventId.count\" from log<\/code><\/pre>\n<\/div>\n

\u7ecf\u8fc7\u4e00\u6bb5\u957f\u65f6\u95f4\u7684\u8fd0\u884c\uff0c\u6211\u4eec\u53d1\u73b0\u91cc\u9762\u6709\u5751\uff0c\u5982\u679cHPA\u5bfc\u81f4Pod\u91ca\u653e\uff0c\u4f46\u662fPod\u7684\u5065\u5eb7\u68c0\u67e5\u4ecd\u7136\u5b58\u5728\uff0c\u5c31\u4f1a\u62a5\u4e00\u4e9bUnHealthy\u62a5\u8b66\uff0c\u4f46\u662f\u5f53\u4f60\u767b\u5f55\u7cfb\u7edf\u67e5\u770b\u65f6\uff0c\u53d1\u73b0Pod\u521a\u521a\u88ab\u5220\u9664\u3002
\n\u6240\u4ee5\u540e\u6765\u6211\u4eec\u628a eventId.reason : Killing \u4e5f\u4e00\u5e76\u8bbe\u7f6e\u4e86\u67e5\u8be2\u6761\u4ef6\uff0c\u7531\u62a5\u8b66\u7cfb\u7edf\u8fdb\u884c\u903b\u8f91\u5224\u65ad\uff0c\u5982\u679c\u6536\u5230\u4e86Pod\u7684Killing\u62a5\u8b66\uff0c\u90a3\u4e48\u5c31\u4e0d\u5728\u5904\u7406\u76f8\u5173Pod\u7684UnHealthy\u62a5\u8b66\u3002<\/p>\n

\u53c2\u8003\u8d44\u6599<\/h2>\n

https:\/\/segmentfault.com\/a\/1190000041204565<\/a>
\n
https:\/\/www.cnblogs.com\/zhangmingcheng\/p\/15917333.html<\/a><\/p>\n

\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1aIPCPU-\u7f51\u7edc\u4e4b\u8def<\/a> » K8S Event\u4e8b\u4ef6\u5185\u5bb9\u5206\u6790\u548c\u544a\u8b66<\/a><\/p>","protected":false},"excerpt":{"rendered":"

K8S Event\u4e8b\u4ef6\u5185\u5bb9\u5206\u6790.md \u4e00\u3001\u6982\u8ff0\u4e8c\u3001event\u4fe1\u606f\u7684\u67e5\u770b\u4e09\u3001event\u4fe1\u606f\u7684\u5206\u7c7b\u56db\u3001Event\u7684\u62a5\u8b66\u53c2\u8003\u8d44\u6599 toc \u4e00\u3001\u6982\u8ff0 k8s\u7684Event\u4e8b\u4ef6\u662f\u4e00\u79cd\u8d44\u6e90\u5bf9\u8c61\uff0c\u7528\u4e8e\u5c55\u793a\u96c6\u7fa4\u5185\u53d1\u751f\u7684\u60c5\u51b5\uff0ck8s\u7cfb\u7edf\u4e2d\u7684\u5404\u4e2a\u7ec4\u4ef6\u4f1a\u5c06\u8fd0\u884c\u65f6\u53d1\u751f\u7684\u5404\u79cd\u4e8b\u4ef6\u4e0a\u62a5\u7ed9apiserver \u3002\u53ef\u4ee5\u901a\u8fc7kubectl get event \u6216 kubectl describe pod podName \u547d\u4ee4\u663e\u793a\u4e8b\u4ef6\uff0c\u67e5\u770bk8s\u96c6\u7fa4\u4e2d\u53d1\u751f\u4e86\u54ea\u4e9b\u4e8b\u4ef6\u3002 apiserver \u4f1a\u5c06Event\u4e8b\u4ef6\u5b58\u5728etcd\u96c6\u7fa4\u4e2d\uff0c\u4e3a\u907f\u514d\u78c1\u76d8\u7a7a\u95f4\u88ab\u586b\u6ee1\uff0c\u6545\u5f3a\u5236\u6267\u884c\u4fdd\u7559\u7b56\u7565\uff1a\u5728\u6700\u540e\u4e00\u6b21\u7684\u4e8b\u4ef6\u53d1\u751f\u540e\uff0c\u5220\u96641\u5c0f\u65f6\u4e4b\u524d\u53d1\u751f\u7684\u4e8b\u4ef6\u3002 \u4e8c\u3001event\u4fe1\u606f\u7684\u67e5\u770b \u5728K8S\u96c6\u7fa4\u7684master\u8282\u70b9\u4e0a\u8fd0\u884c kubectl get event -n project-1573 \u663e\u793a\u5185\u5bb9\u5982\u4e0b LAST SEEN TYPE REASON OBJECT MESSAGE 10m Normal SuccessfulRescale horizontalpodautoscaler\/hpa-10143 New size: 12; reason: cpu resource utilization (percentage of request) above target 10m Normal Scheduled pod\/service-10143-54fc6ff487-qwlds Successfully assigned project-1573\/service-10143-54fc6ff487-qwlds to […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,13],"tags":[173],"_links":{"self":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1880"}],"collection":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/comments?post=1880"}],"version-history":[{"count":1,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1880\/revisions"}],"predecessor-version":[{"id":1881,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1880\/revisions\/1881"}],"wp:attachment":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/media?parent=1880"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/categories?post=1880"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/tags?post=1880"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}