runtime: .NET 6 with specific Dynatrace versions does not start up in a AKS, and produces no logs

Description

I have a .NET 6 API that I would like to run in AKS. Locally it works just fine. In AKS the pod will start up, but the container produces no logs and refuses all connections. I can exec into the container and run dotnet MyApp.Api.dll but the command will just hang and not write any output.

Exec’ing into the container and manually running dotnet MyApp.Api.dll will just hang and produce no output.

Reproduction Steps

Generate a minimal .NET 6 webapi (.e.g dotnet new webapi -minimal -o MyApp.Api).

Create a Dockerfile and build and push to a repo.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app

# Switch the default port from 80 to 5000
ENV ASPNETCORE_URLS=http://+:5000 \
    # Enable detection of running in a container
    DOTNET_RUNNING_IN_CONTAINER=true

EXPOSE 5000

# Create a group and user to run the ASP.NET Core application
RUN addgroup --system dotnetappgroup && \
	adduser --system --ingroup dotnetappgroup --shell /bin/sh dotnetappuser && \
	mkdir -p /local/ && \
	chown dotnetappuser:dotnetappgroup /local && \
	chown dotnetappuser:dotnetappgroup /app

# Update Docker to run all future commands as the appuser user.
USER dotnetappuser

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
ARG NuGetConfig=NuGet.Config
WORKDIR /src
COPY . .
RUN dotnet restore "MyApp.Api/MyApp.Api.csproj"
WORKDIR "/src/MyApp.Api"
RUN dotnet build "MyApp.Api.csproj" -c Release -o /app/build --no-restore

FROM build AS publish
RUN dotnet publish "MyApp.Api.csproj" -c Release -o /app/publish --no-restore

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyApp.Api.dll"]

Create an AKS cluster. Obviously there can be a ton of variability here. I am using:

Kubernetes version 1.20.9
Node image version AKSUbuntu-1804gen2containerd-2021.10.19
Container runtime version containerd://1.4.9+azure

Deploy your app. The important bits about the manifest are:

image: <YOUR_IMAGE_REFERENCE>
imagePullPolicy: Always
name: myapp
ports:
- containerPort: 5000
  protocol: TCP
resources:
  limits:
    cpu: 200m
    memory: 500Mi
  requests:
    cpu: 100m
    memory: 200Mi

Expected behavior

The pod should start up, and the logs should show the typical startup output (e.g. Now listening on port…).

Actual behavior

The pod reports that it is running, but there are no logs, and all connections are refused.

Regression?

Prior versions of .NET Core do not have this problem.

Known Workarounds

No response

Configuration

No response

Other information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 56 (19 by maintainers)

Most upvoted comments

Related: https://stackoverflow.com/questions/70973535/net-6-container-not-starting-properly-in-aks

That was me 😃

I also have a support request open with Microsoft. My last resort is to ask Batman for help.