解析 skaffold 配置:解析 skaffold 配置文件时出错

parsing skaffold config: error parsing skaffold configuration file

所以,我正在尝试自动化 docker 构建和推送过程以及 kubectl apply 部署过程,为此,我在主文件夹中创建了一个 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: 来引用源位置。

我认为您使用的一定是旧版本的 Skaffold。较新版本的 Skaffold 提供了更多详细信息:

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

您可能想查看 Cloud Code for IntelliJ and VS Code or the online Cloud Shell Editor,它提供 skaffold.yaml 编辑帮助,包括突出显示文件中的错误。

- image: 下面的键中 content 而不是 context 更改它,它应该可以工作。

这个工作流程对我有用:

  1. 将第一行更改为:apiVersion:skaffold/v2beta17
  2. 先执行'skaffold init'
  3. 执行'sakffold dev'

我建议查看此文档: https://skaffold.dev/docs/workflows/