0

After migrating my app to .NET 8.0 I cannot run it on k8s because of 'Error: UPGRADE FAILED: context deadline exceeded'. Message in pod logs indicate more specific issue which is: enter image description here

My dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["src/MyApi/MyApi.csproj", "src/MyApi/"]
RUN dotnet restore "src/MyApi/MyApi.csproj"
COPY . .
WORKDIR "/src/src/MyApi"
RUN dotnet build "MyApi.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "MyApi.csproj" -c Release -o /app/publish

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

And my Dockerfile.publish:

FROM mcr.microsoft.com/dotnet/runtime:8.0
ENV ASPNETCORE_ENVIRONMENT=Docker
EXPOSE 80
WORKDIR /app
COPY . .
HEALTHCHECK --interval=30s --timeout=10s CMD curl -f http://localhost/health || exit 1
ENTRYPOINT ["dotnet", "MyApi.dll"]

When in my Dockerfile.publish I have FROM mcr.microsoft.com/dotnet/runtime:6.0 then at least I can see in logs that framework for NET.6 is found. I have no idea what could be wrong as locally Api is working as expected.

1
  • 1) Do you have a minimal reproducible example? 2) "as locally Api is working as expected" - you mean when you are running docker image locally? 3) Are you sure that this docker file is used by your build system/k8s?
    – Guru Stron
    Commented Jul 8 at 14:42

0