因此,我正在尝试自动化docker构建和推送过程以及kubectl应用部署过程,为此,我在主文件夹中创建了一个skaffold配置文件,如下所示:
apiVersion: skaffold/v2alpha3
kind: Config
deploy:
kubectl:
manifests:
- ./infra/k8s/*
build:
local:
push: false
artifacts:
- image: xyz/client
context: client
docker:
dockerfile: Dockerfile
sync:
manual:
- src: 'src/**/*.js'
dest: .
- image: xyz/comments
context: comments
docker:
dockerfile: Dockerfile
sync:
manual:
- src: '*.js'
dest: .
- image: xyz/event-bus
context: event-bus
docker:
dockerfile: Dockerfile
sync:
manual:
- src: '*.js'
dest: .
- image: xyz/moderation
context: moderation
docker:
dockerfile: Dockerfile
sync:
manual:
- src: '*.js'
dest: .
- image: xyz/posts
context: posts
docker:
dockerfile: Dockerfile
sync:
manual:
- src: '*.js'
dest: .
- image: xyz/query
context: query
docker:
dockerfile: Dockerfile
sync:
manual:
- src: '*.js'
dest: .
当我尝试在文件夹中使用skaffold dev
命令时,我得到了以下错误:
parsing skaffold config: error parsing skaffold configuration file
工件使用context:
来引用源位置。
我想你一定在用旧版本的Skafold。Skafold的新版本提供了更多细节:
parsing skaffold config: unable to parse config: yaml: unmarshal errors:
line 4: field content not found in type v2alpha3.Artifact
line 12: field content not found in type v2alpha3.Artifact
line 20: field content not found in type v2alpha3.Artifact
line 28: field content not found in type v2alpha3.Artifact
line 36: field content not found in type v2alpha3.Artifact
line 44: field content not found in type v2alpha3.Artifact
您可能想查看IntelliJ和VS代码的云代码,或在线云外壳编辑器,该编辑器提供skaffold.yaml
编辑帮助,包括突出显示文件中的错误。
您在- image:
下面的键中有content
而不是context
,更改它应该可以工作。
这个工作流程对我有效:
- 将第一行更改为:apiVersion:skaffold/v2beta17
- 首先执行"skaffold-init">
- 执行"saffold-dev">
我建议查看此文档:https://skaffold.dev/docs/workflows/