我正在考虑使用 Skaffold.dev 来改善我使用 Kubernetes 的开发体验。
我创建了一个默认的 .NET API 项目,它会自动生成我的 docker 文件:
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["TestMicro/TestMicro.csproj", "TestMicro/"]
RUN dotnet restore "TestMicro/TestMicro.csproj"
COPY . .
WORKDIR "/src/TestMicro"
RUN dotnet build "TestMicro.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "TestMicro.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "TestMicro.dll"]
我已经创建了一个 Kubernetes 清单,并且使用kubectl apply
.
安装 skaffold 后,我运行skaffold init
并自动生成了这个
apiVersion: skaffold/v2beta8
kind: Config
metadata:
name: microservices-investigation
build:
artifacts:
- image: testmicro
context: src\Microservices\TestMicro
deploy:
kubectl:
manifests:
- k8s/TestMicro.yaml
但是,当我运行时,skaffold run
我得到以下信息:
$ skaffold run
Generating tags...
- testmicro -> testmicro:bd61fc5-dirty
Checking cache...
- testmicro: Error checking cache.
failed to build: getting hash for artifact "testmicro": getting dependencies for "testmicro": file pattern [TestMicro/TestMicro.csproj] must match at least one file
我认为这是因为,当我docker build
从 CLI 运行时,我必须在docker build -f Dockerfile ..
这里运行看看为什么。
我只是不知道如何将其翻译成 skaffold 的 yaml 文件。有任何想法吗?!