1

My Code:

 public static void Start()
    {
       
        tcpListener = new TcpListener(IPAddress.Any, 26950);
        tcpListener.Start();
        tcpListener.BeginAcceptTcpClient(TCPConnectCallback, null);
        while(true){Thread.Sleep(500);}
       
    }
    private static void TCPConnectCallback(IAsyncResult _result)
    {

        TcpClient _client = tcpListener.EndAcceptTcpClient(_result);
         //Assign _client to local server
    }

My Dockerfile to create and upload an Image:

FROM mcr.microsoft.com/dotnet/sdk

COPY . /app

WORKDIR /app

RUN dotnet publish -c Release -o out

ENTRYPOINT ["dotnet", "Test.dll"]

Command in Cloud Shell:

gcloud builds submit --tag gcr.io/t****/i****

After this, I deploy it on Kubernetes Engine>Workloads

Error: CrashLoopBackOff

Solution:

FROM mcr.microsoft.com/dotnet/sdk:3.1
WORKDIR /app

COPY . .

ENTRYPOINT ["dotnet", "run"]

1 Answers1

0

The error CrashLoopBackOff indicates that a container is repeatedly crashing after restarting. A container might crash for many reasons

For example:

You can get more info about your error the CrashLoopBackOff error to know why your Pod's container is crashing

To see all Pods running in your cluster, run the following command:

kubectl get pods

And to get the Pod's logs, run the following command:

kubectl logs [POD_NAME]

You can also pass in the -p flag to get the logs for the previous instance of a Pod's container, if it exists.

Check "Exit Code" of the crashed container

You can find the exit code by performing the following tasks:

  1. Run the following command:
kubectl describe pod [POD_NAME]
  1. Review the value in the containers: CONTAINER_NAME: last state: exit code

Additionally, check if it has restarts.

For example you can use the command

watch -n1 kubectl get pods POD_NAME

To see if the pod got some of the following states:

creatingContainer -->  running --> completed --> crashloopbackoff

You could see more information about it in the following link

Also you can check this article that can help you with this issue What is a CrashLoopBackOff? How to alert, debug / troubleshoot, and fix Kubernetes CrashLoopBackOff events.

Finally, if you provide more information like the logs and more details, the community could help you more.

Edit 1

Looks like your problem come from the FROM mcr.microsoft.com/dotnet/sdk

I have found the following documentation: Create a Dockerfile for an ASP.NET Core application You could try to use something like:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env

According to the official documentation : microsoft-dotnet-sdk these are the feature tags:

  • 5.0 (Current)
docker pull mcr.microsoft.com/dotnet/sdk:5.0
  • 3.1 (LTS)
docker pull mcr.microsoft.com/dotnet/sdk:3.1
Jose Luis Delgadillo
  • 2,348
  • 1
  • 6
  • 16
  • I edited it. My error should now be described more precise –  Mar 24 '21 at 14:19
  • I have edited my answer. Please take a look at it. – Jose Luis Delgadillo Mar 24 '21 at 16:38
  • It seemed really promising especially the source [microsoft-dotnet-sdk](https://hub.docker.com/_/microsoft-dotnet-sdk) you gave me. But I tried it and the related repositories and none of them worked. I've already worked too long on this matter so except you or some one else can think of something groundbreaking - I can't - I will rewrite my code and do it with sql –  Mar 24 '21 at 19:19
  • @apprentice Let's divide the issue, the initial issue was related with CrashLoopBackOff, this issue is what I tried to help with, but per your last edit it seems that it was already solved. Now the other error seems to be related with dotnet sdk, I suggest to create another case with the proper tags focus the error from the dotnet-sdk side in order that the StackOverflow community can help you with it. On the other hand if you find my answer useful, please consider upvoting/accepting it, thank you! – Jose Luis Delgadillo Mar 24 '21 at 19:54
  • I cannot upvote. I only can accept your answer –  Mar 24 '21 at 19:59