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

时间:2021-03-19 10:37:23

标签: docker kubernetes yaml web-deployment skaffold

因此,我正在尝试自动化 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

3 个答案:

答案 0 :(得分:0)

工件使用 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 或在线 Cloud Shell Editor,它提供 skaffold.yaml 编辑帮助,包括突出显示文件中的错误。

答案 1 :(得分:0)

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

答案 2 :(得分:0)

这个工作流程对我有用:

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

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

相关问题