我是Kubernetes的新手。
因此,我具有构建的.NET Core控制台应用程序Docker映像:
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"]
此图像在我的机器上运行良好。但是,当我尝试在Kubernetes中将其部署为CronJob时,它会失败。
这是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
以及从Pod上查看日志得到的错误消息:
NAME READY STATUS RESTARTS AGE
netcore-cronjob-1582854120-scwfb 0/1 Error 0 19s
当我运行kubectl logs -n aim-ns netcore-cronjob-1582854120-scwfb
时,我得到:
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
我在这里想念什么?
答案 0 :(得分:0)
我遇到了同样的问题,我需要更改“FROM mcr.microsoft.com/dotnet/core/runtime:3.0-buster-slim AS base” (用于运行应用程序)更改为“FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS base”。我认为运行时间必须足够,但是...
再见 马库斯