Reputation: 1883
I am having .net a self-hosted application, basically, it runs for 12 hours. The entire functionality is working as expected in my local machine.
Reference: Background tasks with hosted services in ASP.NET Core
Currently, we are using Kubernetes for deployment. While deploying it is checking the health status with the liveness endpoint and deployment is failing since there is no liveness endpoint as it is a background running application. To deploy the application in Kubernetes it is expecting the liveness endpoint.
Is there any way that we can serve some JSON data whenever the liveness endpoint is called from the docker side for the background running application?
Here is my docker code.
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
WORKDIR /app
# Copy everything
COPY . ./
# Restore as distinct layers
RUN dotnet restore
# Build and publish a release
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=build-env /app/out .
EXPOSE 8080/tcp
CMD ["dotnet", "DarkTesting.WorkerService.dll"]
Upvotes: 0
Views: 391
Reputation: 1133
Personally I have found that deploying my background services as ASP.NET Core applications works well, because we can:
Upvotes: 2