I am new to Kubernetes.
So I have this .NET Core console application Docker image that I built:
FROM mcr.microsoft.com/dotnet/core/runtime:3.0-buster-slim AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
WORKDIR /src
COPY ["DataSync.Entry/DataSync.Entry.csproj", "DataSync.Entry/"]
RUN dotnet restore "DataSync.Entry/DataSync.Entry.csproj"
COPY . .
WORKDIR "/src/DataSync.Entry"
RUN dotnet build "DataSync.Entry.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "DataSync.Entry.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "DataSync.Entry.dll"]
This image works perfectly on my machine. However when I try to deploy it as a CronJob in Kubernetes it fails.
Here's the YAML:
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: netcore-cronjob
namespace: aim-ns
labels:
app: netcore-cronjob
spec:
schedule: "*/2 * * * *"
jobTemplate:
spec: #JOB
backoffLimit: 1
template:
spec: #POD
containers:
- name: netcore-job
image: <ACR>.azurecr.io/aim/test-data-sync-netcore:v1 #my docker image above pushed to ACR
command: ["dotnet", "DataSync.Entry.dll"]
args: []
resources:
requests:
memory: "64Mi"
cpu: "100m"
limits:
memory: "128Mi"
cpu: "150m"
restartPolicy: Never
And the error message I got from viewing the logs on the Pod:
NAME READY STATUS RESTARTS AGE
netcore-cronjob-1582854120-scwfb 0/1 Error 0 19s
And when I run kubectl logs -n aim-ns netcore-cronjob-1582854120-scwfb
I get:
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
What am I missing here?