skip to Main Content

OK I´m new to ASP.NET Core 6 and k8s. So far all apps I was hosting (java, js, python) didn’t have any issue.

Deployment service and ingress were created successfully but I was having error in pod:

{"EventId":3,"LogLevel":"Warning","Category":"Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware","Message":"Failed
to determine the https port for redirect.","State":{"Message":"Failed
to determine the https port for redirect.

I have always managed certificates at ingress level and so far with no issues. I’m always using Nginx also as IC.

After some research I end up with following post:

How to make sure my .NET Core service running in EKS can find the https port?

So basically I decided to remove the C# code the https redirection I saw in developers code and rebuild image app.UseHttpsRedirection(); . This way I can managed security ssl as I said, from ingress level. (Here is the commented line)

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

//app.UseHttpsRedirection();

So now I tested new Docker image locally and it works.

enter image description here

But inside kubernetes I’m getting:

enter image description here

There are no redirects errors but I’m just getting "application is shutting down now".

Any idea what this can be related to?

Ingres secret with certificates were created successfully and ingres is using that secret for tls.

here describe pod.

enter image description here

2

Answers


  1. Chosen as BEST ANSWER

    ok So Application was running but giving 404, so k8s interpreted that as unhealthy. So I added the health check in the liveness and readiness probe like: path: /healthy and that way it started to give the 200 code and container started to run normally.


  2. I am not sure about your configuration, but I had the similar "application is shutting down now" issue and found out that I missed .AddHealthChecks() and .UseHealthChecks("/health") in Startup.cs file. Your reason can be different, but maybe this will give you a hint 🙂

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search