Redis stack trace does not appear in Kubernetes Pod Log! Why not?

Siegfried Heintze 1,861 Reputation points
2020-12-17T20:50:41.157+00:00

I have an ASP.NET core 3 web app I'm trying to debug in an Azure Kubernetes pod.

I could look at the kubernetes pod log and see my System.Console.WriteLine statements inside of my ConfigureServices functions and everything looked great -- including my WriteLine statement indicating that I had called AddDistributedRedisCache that should use the bitnami redis server.

However my web app was failing and I could not figure out why until I tried out the kubernetes bridge. There I saw the little console window pop up where all my WriteLine statements manifested AND the stack trace indicating the failure to connect with the Redis server... Ah hah!

Previously there were no helpful error messages except the standard message in the browser telling me to turn on developer mode to see more details. Apparently this is not possible for kubernetes resident apps to run in developer mode in spite of explicitly calling app.UseDeveloperExceptionPage();.

The problem was fixed by creating a Redis service in the same name space as my web app...

Why did this redis stack trace not appear in the kubernetes pod log? Perhaps the stack trace writes to stderr and maybe the kubernetes pod log only picks up stdout? Is there kubernetes setting to change this?

Maybe there is an ASP.NET call to make everything appear in stdout so it can be seen in the kubernetes pod log?

Is this a kubernetes issue or an ASP.NET issue?

Thanks

Siegfried

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,154 questions
Azure Cache for Redis
Azure Cache for Redis
An Azure service that provides access to a secure, dedicated Redis cache, managed by Microsoft.
213 questions
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
1,853 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sergei Li 1 Reputation point
    2021-01-22T10:20:24.58+00:00
    1. Answering your main question. There is a chance that your pod consists of more than one container. In this case, you need to specify the container name:
      kubectl logs my-pod -c my-container
    2. As for moving a Redis service into the same namespace as your webapp. You could have avoided that by using the correct service DNS name which includes the name of the Redis namespace: my-svc.my-namespace
      The full version is my-svc.my-namespace.svc.cluster-domain.example