'CrashLoopBackOff when trying to run .Net Applications in AKS cluster accross 2 pods

Apologies from the start but please bear with me, I am still rather novice at this so if you see any issues glaringly obvious, please forgive me.

I am working at a company where some devs are trying to have us deploy some .NET Core applications to containers in Azure Kubernetes Service (AKS). From my understanding, they have been written in .NET Core 3.1. The goal is to run this process using a CI/CD Azure Pipeline, using Azure Repos as repository, using a build pipeline to create the docker image, push image to our Azure Container Registry and create an artifact for the release pipeline to then deploy (using helm) contianers into the AKS.

File Structure is as follows:

file structure

Dockerfile

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
COPY ["AppFolder1\App.csproj", "."]
RUN dotnet restore "AppFolder1\App.csproj"
COPY . .
RUN dotnet build "AppFolder1\App.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "AppFolder1\App.csproj" -c Release -o /app/publish

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

ERROR

Question: Could there be an issue with 6.0 sdk when trying to deploy app made with .net core 3.1?

  1. running "kubectl get pods -n redacted-namespace" a) retrieves two pods with CrashLoopBackOff Status showing 9 restarts

  2. running "kubectl define pod -n redacted-namespace" retrieves information on pods a) both pods show successful pod scheduling - Successfully assigned redacted-namespace/ to aks-nodepool1-02 AND aks-nodepool1-00

    b) Both show multiple successful pull of image

    c) Both show creation of container and start of container

    d) End message: Warning BackOff 58s (x117 over 26m) kubelet Back-off restarting failed container

--ATTEMPTS TO SOLVE-- It was suggested that the Dockerfile was to blame. Spent time creating and running pipeline with multiple iterations of dockerfile, including changing .net versioning to 3.1 from 6.0. No successful pipelines using these dockerfiles yet.


running kubectl logs <pod-name> -n redacted-namespace:

Could not execute because the application was not found or a compatible .NET SDK is not installed.
Possible reasons for this include:
  * You intended to execute a .NET program:
      The application 'DotNet.Docker.dll' does not exist.
  * You intended to execute a .NET SDK command:
      It was not possible to find any installed .NET SDKs.
      Install a .NET SDK from:
        https://aka.ms/dotnet-download

I had figured that the installation of the .NET SDK should have been handled by the dockerfile line 1, however it doesn't seem to be working properly. In the meantime, adding in pipeline release Agent Task Use .NET Core sdk 6.0 and deleting previous pods to try again.

Re-running pipeline release - No effect. Likely .NET Core SDK install agent task does not work inside of each pod and is therefore not available as an installed resource within pods and replicas.



Solution 1:[1]

Apparently there were TWO problems with the Dockerfile. The first and foremost, @Hans Kilian, you're absolutely right. Apparently they were using .NET 3.1. The other issue was the ENDPOINT I had set up was not pointing to the right .dll file. This I found by going to Solutions/App.sln and pulled the name from the Project line (something like Project("################################")= "Project_name"... Its working and running just fine now. Thank you!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Akira_Yam