English 中文(简体)
ASP.NET K8S的核心应用有时在东道方hang。 Buid()
原标题:ASP.NET Core application in K8S sometimes hangs on HostBuilder.Buid()

我有一个伙伴关系。 NET 核心6应用在Kubernetes。 在启动阶段,它只是为启动伙伴关系制定典型的守则。 NET 核心应用。 现在突然开始,但并不总是在<代码>builder.Build()打电话(我用Console表示)。 在进入<代码>Startup级的构造之前,以及在经过一段时间后,K8S将杀死od。

我不知道如何进一步调查这一问题。 是什么原因?

Is there something I can try to change in the code or in the configuration of the application? Or could there be something in Kubernetes that could cause this issue to suddenly appear?

public static void Main(string[] args)
{
    var builder = CreateHostBuilder(args);
    var host = builder.Build(); // hangs here
    host.Run();
}

public static IHostBuilder CreateHostBuilder(string[] args)
{
    var builder = Host.CreateDefaultBuilder(args);
    builder = builder.ConfigureWebHostDefaults(webBuilder =>
    {
        webBuilder.UseStartup<Startup>();
    });

    return builder;
}

Added: Running kubectl logs <pod_name> will only produce some logs from linkerd, which does not show me anything weird (the errors look like failing health check, which makes sense given the application does not fully start up):

Defaulted container "linkerd-proxy" out of: linkerd-proxy, <deployment_name>, linkerd-init (init)
[     0.020493s]  INFO ThreadId(01) linkerd2_proxy::rt: Using single-threaded proxy runtime
[     0.021883s]  INFO ThreadId(01) linkerd2_proxy: Admin interface on 0.0.0.0:4191
[     0.021913s]  INFO ThreadId(01) linkerd2_proxy: Inbound interface on 0.0.0.0:4143
[     0.021927s]  INFO ThreadId(01) linkerd2_proxy: Outbound interface on 127.0.0.1:4140
[     0.021935s]  INFO ThreadId(01) linkerd2_proxy: Tap DISABLED
[     0.021941s]  INFO ThreadId(01) linkerd2_proxy: Local identity is default.default.serviceaccount.identity.linkerd.cluster.local
[     0.021948s]  INFO ThreadId(01) linkerd2_proxy: Identity verified via linkerd-identity-headless.linkerd.svc.cluster.local:8080 (linkerd-identity.linkerd.serviceaccount.identity.linkerd.cluster.local)
[     0.021954s]  INFO ThreadId(01) linkerd2_proxy: Destinations resolved via linkerd-dst-headless.linkerd.svc.cluster.local:8086 (linkerd-destination.linkerd.serviceaccount.identity.linkerd.cluster.local)
[     0.043719s]  INFO ThreadId(02) daemon:identity: linkerd_app: Certified identity id=default.default.serviceaccount.identity.linkerd.cluster.local
[    17.330501s]  INFO ThreadId(01) inbound:server{port=80}:rescue{client.addr=87.233.137.147:47108}: linkerd_app_core::errors::respond: HTTP/1.1 request failed error=error trying to connect: Connection refused (os error 111) error.sources=[Connection refused (os error 111)]
[    37.318022s]  INFO ThreadId(01) inbound:server{port=80}:rescue{client.addr=87.233.137.147:49918}: linkerd_app_core::errors::respond: HTTP/1.1 request failed error=error trying to connect: Connection refused (os error 111) error.sources=[Connection refused (os error 111)]
[    57.317661s]  INFO ThreadId(01) inbound:server{port=80}:rescue{client.addr=87.233.137.147:55614}: linkerd_app_core::errors::respond: HTTP/1.1 request failed error=error trying to connect: Connection refused (os error 111) error.sources=[Connection refused (os error 111)]
[    77.317162s]  INFO ThreadId(01) inbound:server{port=80}:rescue{client.addr=87.233.137.147:49574}: linkerd_app_core::errors::respond: HTTP/1.1 request failed error=error trying to connect: Connection refused (os error 111) error.sources=[Connection refused (os error 111)]
[    97.317333s]  INFO ThreadId(01) inbound:server{port=80}:rescue{client.addr=87.233.137.147:41688}: linkerd_app_core::errors::respond: HTTP/1.1 request failed error=error trying to connect: Connection refused (os error 111) error.sources=[Connection refused (os error 111)]```
问题回答

该法典一般如下文所示。

public class Program
{
    public static void Main(string[] args)
    {
        CreateHostBuilder(args).Build().Run();
    }
    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>();
            });

}

此外,还可以检查<代码>kubectllogs <pod_name> 例外情况详情。

问题似乎是在蚊帐核心器具中,而不是在青春期。 如果使用Docker和Kubernetes,你就可以看到Docker桌面的标志。

Docker Container: enter image description here

Logs: enter image description here

The kubectl logs podname command will also do the same work.

也可以创建Kubernetes Liveness Readinessstartup Probes,以便让Kubernetes检测器具的健康状况,并为不健康的服采取适当的行动。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签