微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决解析 skaffold 配置:解析 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

解决方法

工件使用 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 编辑帮助,包括突出显示文件中的错误。

,

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

,

这个工作流程对我有用:

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。