Azure Kubernetes 排错

Exit Code: 139

Reason: Error

表明容器收到了 SIGSEGV 信号,无效的内存引用,对应 kill -11 一般是代码有问题,或者 docker 的基础镜像有问题。

我们的程序是 Asp.net core 无效的内存引用通常不会导致程序退出的。

在 Azure portal 平台可以通过 container inventory 来查询到哪一个 container

ContainerInventory 
| where ContainerHostname =="web-live-899dc5cf6-v7n62"
| order  by TimeGenerated asc 

Container state 是 deleted的说明这个时候被删了。 可以看到它的 containerId 然后通过 containerId 我们可以去查询它的 Container Log

ContainerLog  
| where ContainerID =="5fc67b69ef600f48a42afcec83d23531e91f84887148ceee2d384ca51885c54b"
| order by TimeGenerated asc 

日志拉到最后面我们可以一般可以看到一些消息。 我们的程序看到的是

An unhandled exception was thrown by the application.
Out of memory.

(我们的程序的内存限制是4G但是它用到3.53G的时候就不行了。)

这边是微软介绍哪些原因会导致 out of memory https://learn.microsoft.com/en-us/troubleshoot/developer/webapps/aspnet/health-diagnostic-performance/troubleshoot-outofmemoryexception

Kubernetes 错误代码

Exit Code: 139

Reason: Error

表明容器收到了 SIGSEGV 信号,无效的内存引用,对应 kill -11 一般是代码有问题,或者 docker 的基础镜像有问题。

我们的程序是 Asp.net core 无效的内存引用通常不会导致程序退出的。

在 Azure portal 平台可以通过 container inventory 来查询到哪一个 container

ContainerInventory 
| where ContainerHostname =="web-live-899dc5cf6-v7n62"
| order  by TimeGenerated asc 

Container state 是 deleted的说明这个时候被删了。 可以看到它的 containerId 然后通过 containerId 我们可以去查询它的 Container Log

ContainerLog  
| where ContainerID =="5fc67b69ef600f48a42afcec83d23531e91f84887148ceee2d384ca51885c54b"
| order by TimeGenerated asc 

日志拉到最后面我们可以一般可以看到一些消息。 我们的程序看到的是

An unhandled exception was thrown by the application.
Out of memory.

(我们的程序的内存限制是4G但是它用到3.53G的时候就不行了。)

这边是微软介绍哪些原因会导致 out of memory https://learn.microsoft.com/en-us/troubleshoot/developer/webapps/aspnet/health-diagnostic-performance/troubleshoot-outofmemoryexception

Exit Code 137

Reason: OomKilled

这个是Pod 实际占用的内存超过了 resources 中 定义的内存限制

 resources:
                limits:
                  memory: 3072Mi #3G

Reason:Error

可能是Liveness 检查不过。 如果时间还比较近的话我们可以用

kubectl describe pod xxxx
# 然后就可以看到如下的记录了
Events:
  Type     Reason     Age                  From     Message
  ----     ------     ----                 ----     -------
  Warning  Unhealthy  14m (x9 over 53m)    kubelet  Liveness probe failed:
  Normal   Killing    14m                  kubelet  Container xxxx failed liveness probe, will be restarted

Azure kube events 不懂为什么看不到 Killing的记录。 Unhealthy是可以看到的

下一篇:Aks issues
最近更新的
...