我是 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
我在这里想念什么?