27.2. 运行 Helm chart-verifier 工具


执行 chart-verifier 工具的建议目录结构如下:

.
└── src
    ├── Chart.yaml
    ├── README.md
    ├── templates
    │   ├── deployment.yaml
    │   ├── _helpers.tpl
    │   ├── hpa.yaml
    │   ├── ingress.yaml
    │   ├── NOTES.txt
    │   ├── serviceaccount.yaml
    │   ├── service.yaml
    │   └── tests
    │       └── test-connection.yaml
    ├── values.schema.json
    └── values.yaml
Copy to Clipboard Toggle word wrap

先决条件

  • 安装 Podman 或 Docker CLI 的容器引擎。
  • 互联网连接,以检查镜像是否经过红帽认证。
  • GitHub 配置集,将 chart 提交到 OpenShift Helm Charts 仓库
  • Red Hat OpenShift Container Platform 集群。
  • 在运行 chart-verifier 工具前,使用以下命令打包 Helm Chart:

    $ helm package <helmchart folder>
    Copy to Clipboard Toggle word wrap

    此命令将归档您的 Helm Chart,并将其转换为 .tgz 文件格式。

步骤

您可以使用两种方法运行一组 chart-verifier 工具:

27.2.1. 使用 Podman 或 Docker

  1. 使用通用资源标识符(uri)远程运行可用 chart 的所有可用检查,假设 kube 配置文件位于位置 ${HOME}/.kube :

    $ podman run --rm -i                                  \
            -e KUBECONFIG=/.kube/config                   \
            -v "${HOME}/.kube":/.kube                     \
            "quay.io/redhat-certification/chart-verifier" \
            verify                                        \
            <chart-uri>
    Copy to Clipboard Toggle word wrap

    在这个命令中,图表是 https uri 上可用的 Chart 存档的位置。确保存档必须采用 .tgz 格式。

  2. 在您的系统中本地运行所有可用检查,假设 chart 在当前目录中可用,并且 kube 配置文件位于 ${HOME}/.kube 的位置:

    $ podman run --rm                                     \
            -e KUBECONFIG=/.kube/config                   \
            -v "${HOME}/.kube":/.kube                     \
            -v $(pwd):/charts                             \
            "quay.io/redhat-certification/chart-verifier" \
            verify                                        \
            /charts/<chart>
    Copy to Clipboard Toggle word wrap

    在这个命令中,chart-uri 是您的本地目录中提供的 chart 归档的位置。确保存档必须采用 .tgz 格式。

  3. 运行以下命令,以获取与命令关联的可用选项及其用法:

    $ podman run -it --rm quay.io/redhat-certification/chart-verifier verify --help
    Copy to Clipboard Toggle word wrap

    命令的输出类似以下示例:

    Verifies a Helm chart by checking some of its characteristics
    
    Usage:
      chart-verifier verify <chart-uri> [flags]
    
    Flags:
      -S, --chart-set strings           set values for the chart (can specify multiple or separate values with commas: key1=val1,key2=val2)
      -G, --chart-set-file strings      set values from respective files specified via the command line (can specify multiple or separate values with commas: key1=path1,key2=path2)
      -X, --chart-set-string strings    set STRING values for the chart (can specify multiple or separate values with commas: key1=val1,key2=val2)
      -F, --chart-values strings        specify values in a YAML file or a URL (can specify multiple)
          --debug                       enable verbose output
      -x, --disable strings             all checks will be enabled except the informed ones
      -e, --enable strings              only the informed checks will be enabled
          --helm-install-timeout duration   helm install timeout (default 5m0s)
      -h, --help                        help for verify
          --kube-apiserver string       the address and the port for the Kubernetes API server
          --kube-as-group stringArray   group to impersonate for the operation, this flag can be repeated to specify multiple groups.
          --kube-as-user string         username to impersonate for the operation
          --kube-ca-file string         the certificate authority file for the Kubernetes API server connection
          --kube-context string         name of the kubeconfig context to use
          --kube-token string           bearer token used for authentication
          --kubeconfig string           path to the kubeconfig file
      -n, --namespace string            namespace scope for this request
      -V, --openshift-version string    set the value of certifiedOpenShiftVersions in the report
      -o, --output string               the output format: default, json or yaml
      -k, --pgp-public-key string       file containing gpg public key of the key used to sign the chart
      -W, --web-catalog-only            set this to indicate that the distribution method is web catalog only (default: true)
          --registry-config string      path to the registry config file (default "/home/baiju/.config/helm/registry.json")
          --repository-cache string     path to the file containing cached repository indexes (default "/home/baiju/.cache/helm/repository")
          --repository-config string    path to the file containing repository names and URLs (default "/home/baiju/.config/helm/repositories.yaml")
      -s, --set strings                 overrides a configuration, e.g: dummy.ok=false
      -f, --set-values strings          specify application and check configuration values in a YAML file or a URL (can specify multiple)
      -E, --suppress-error-log          suppress the error log (default: written to ./chartverifier/verifier-<timestamp>.log)
          --timeout duration            time to wait for completion of chart install and test (default 30m0s)
      -w, --write-to-file               write report to ./chartverifier/report.yaml (default: stdout)
    Global Flags:
          --config string   config file (default is $HOME/.chart-verifier.yaml)
    Copy to Clipboard Toggle word wrap
  4. 运行检查的子集:

    $ podman run --rm -i                                  \
            -e KUBECONFIG=/.kube/config                   \
            -v "${HOME}/.kube":/.kube                     \
            "quay.io/redhat-certification/chart-verifier" \
            verify -enable images-are-certified,helm-lint      \
            <chart-uri>
    Copy to Clipboard Toggle word wrap
  5. 运行除子集之外的所有检查:

    $ podman run --rm -i                                  \
            -e KUBECONFIG=/.kube/config                   \
            -v "${HOME}/.kube":/.kube                     \
            "quay.io/redhat-certification/chart-verifier" \
            verify -disable images-are-certified,helm-lint      \
            <chart-uri>
    Copy to Clipboard Toggle word wrap
    注意

    运行检查子集旨在减少开发的反馈循环。要认证您的图表,您必须运行所有必要的检查。

  6. 提供 chart-override 值:

    $ podman run --rm -i                                  \
            -e KUBECONFIG=/.kube/config                   \
            -v "${HOME}/.kube":/.kube                     \
            "quay.io/redhat-certification/chart-verifier" \
            verify –chart-set default.port=8080                   \
            <chart-uri>
    Copy to Clipboard Toggle word wrap
  7. 从当前目录中的文件提供 chart-override 值:

    $ podman run --rm -i                                  \
            -e KUBECONFIG=/.kube/config                   \
            -v "${HOME}/.kube":/.kube                     \
            -v $(pwd):/values                             \
            "quay.io/redhat-certification/chart-verifier" \
            verify –chart-values /values/overrides.yaml              \
            <chart-uri>
    Copy to Clipboard Toggle word wrap

27.2.1.1. 配置 timeout 选项

如果 chart-testing 进程延迟,请增加超时值。默认情况下,图表测试过程需要大约 30 分钟才能完成。

$ podman run --rm -i                                  \
        -e KUBECONFIG=/.kube/config                   \
        -v "${HOME}/.kube":/.kube                     \
        -v $(pwd):/values                             \
        "quay.io/redhat-certification/chart-verifier" \
        verify --timeout 40m                          \
        <chart-uri>
Copy to Clipboard Toggle word wrap
注意

如果您在 Chart 测试过程中观察到延迟,红帽建议您向红帽认证团队提交报告进行验证。

27.2.1.2. 保存报告

当 chart 测试过程完成后,报告信息会被默认显示。您可以通过将报告重定向到文件来保存报告。

例如:

  $ podman run --rm -i                                  \
          -e KUBECONFIG=/.kube/config                   \
          -v "${HOME}/.kube":/.kube                     \
          "quay.io/redhat-certification/chart-verifier" \
          verify –enable images-are-certified,helm-lint      \
          <chart-uri> > report.yaml
Copy to Clipboard Toggle word wrap

除了这个命令,使用 a -w 选项将报告直接写入文件 ./chartverifier/report.yaml。若要获取此文件,您必须对文件进行卷挂载至 /app/chartverifer

例如:

  $ podman run --rm -i                                  \
          -e KUBECONFIG=/.kube/config                   \
          -v "${HOME}/.kube":/.kube                     \
          -v $(pwd)/chartverifier:/app/chartverifier    \
          -w                                            \
          "quay.io/redhat-certification/chart-verifier" \
          verify –enable images-are-certified,helm-lint      \
          <chart-uri>
Copy to Clipboard Toggle word wrap

如果文件已存在,新报告会覆盖该文件。

27.2.1.3. 配置错误日志

默认情况下,生成错误日志并保存到文件 ./chartverifier/verify-<timestamp>.yaml 中。它包括错误消息、每个检查的结果以及有关 Chart 测试的附加信息。要获得错误日志的副本,您必须挂载卷到 /app/chartverifer

例如:

 $ podman run --rm -i                                  \
          -e KUBECONFIG=/.kube/config                   \
          -v "${HOME}/.kube":/.kube                     \
          -v $(pwd)/chartverifier:/app/chartverifier    \
          "quay.io/redhat-certification/chart-verifier" \
          verify –enable images-are-certified,helm-lint      \
          <chart-uri> > report.yaml
Copy to Clipboard Toggle word wrap

如果要将多个日志存储到同一目录中,您可以一次存储最多 10 个日志文件。当达到最大文件限制时,旧的日志文件会自动替换为较新的日志文件。

使用 -E or -suppress-error-log 选项来限制错误日志输出。

注意

错误和警告消息是标准错误输出信息,无法使用 -E or -suppress-error-log 选项阻止。

27.2.2. 使用二进制文件

注意

这个方法只适用于 Linux 系统。

  1. 从版本页面中下载并安装最新的 chart-verifier 二进制文件。https://github.com/redhat-certification/chart-verifier/releases
  2. 使用以下命令解压 tarball 二进制文件:

    $ tar zxvf <tarball>
    Copy to Clipboard Toggle word wrap
  3. 在 unzipped 目录中运行以下命令执行所有 Helm Chart 检查:

    $ ./chart-verifier verify <chart-uri>
    Copy to Clipboard Toggle word wrap

    在这个命令中,chart-uri 是服务器上可用的 Chart 存档的位置。确保存档必须采用 .tgz 格式。默认情况下,chart-verifier 工具假定 kube 配置文件位于默认位置 $HOME/.kube。如果文件在默认位置不可用,请将环境变量设置为 KUBECONFIG

    chart-verifier 的输出包括执行的测试详情以及每个测试的结果状态。它还指明每个测试对于红帽认证是否是必需的或推荐。如需更多信息,请参阅 Helm Chart 检查的类型

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat