zoukankan      html  css  js  c++  java
  • helm --dry-run --debug这个可选参数做调试

    我们用模板来生成资源文件的清单,但是如果我们想要调试就非常不方便了,不可能我们每次都去部署一个release实例来校验模板是否正确,所幸的时 Helm 为我们提供了--dry-run --debug这个可选参数,在执行helm install的时候带上这两个参数就可以把对应的 values 值和生成的最终的资源清单文件打印出来,而不会真正的去部署一个release实例,比如我们来调试上面创建的 chart 包:

    $ helm install . --dry-run --debug ./mychart
    [debug] Created tunnel using local port: '35286'
    
    [debug] SERVER: "127.0.0.1:35286"
    
    [debug] Original chart version: ""
    [debug] CHART PATH: /root/course/kubeadm/helm/mychart
    
    NAME:   wrapping-bunny
    REVISION: 1
    RELEASED: Fri Sep  7 23:23:09 2018
    CHART: mychart-0.1.0
    USER-SUPPLIED VALUES:
    {}
    
    COMPUTED VALUES:
    ...
    HOOKS:
    MANIFEST:
    
    ---
    # Source: mychart/templates/configmap.yaml
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: wrapping-bunny-configmap
    data:
      myvalue: "Hello World"
    

    现在我们使用--dry-run就可以很容易地测试代码了,不需要每次都去安装一个 release 实例了,但是要注意的是这不能确保 Kubernetes 本身就一定会接受生成的模板,在调试完成后,还是需要去安装一个实际的 release 实例来进行验证的。

    Debugging Templates

    Debugging templates can be tricky because the rendered templates are sent to the Kubernetes API server, which may reject the YAML files for reasons other than formatting.

    There are a few commands that can help you debug.

    • helm lint is your go-to tool for verifying that your chart follows best practices
    • helm install --dry-run --debug or helm template --debug: We've seen this trick already. It's a great way to have the server render your templates, then return the resulting manifest file.
    • helm get manifest: This is a good way to see what templates are installed on the server.

    When your YAML is failing to parse, but you want to see what is generated, one easy way to retrieve the YAML is to comment out the problem section in the template, and then re-run helm install --dry-run --debug:

    apiVersion: v2
    # some: problem section
    # {{ .Values.foo | quote }}

    The above will be rendered and returned with the comments intact:

    apiVersion: v2
    # some: problem section
    #  "bar"

    This provides a quick way of viewing the generated content without YAML parse errors blocking.

  • 相关阅读:
    ArcGIS Engine获取单条要素的标注(LABEL)内容
    推荐一个winform第三方控件QIOS DevSuite
    解决C#,CAD二次开发实例化AcadApplicationClass失败
    skyline中屏蔽或自定义InformationWindow和NavigationMap的右键菜单
    (转)Skyline TEPro6.0版本在二次开发方面的改进总结
    skyline TEP 6 开发帮助文档CHM中文汉化版
    CCIE一年后的心语(转)
    PC 到 PC的共享
    Mysql 更改某一字段的内容为另一字段加上字符串
    Ralis: 连接数据库并查询
  • 原文地址:https://www.cnblogs.com/weifeng1463/p/12916199.html
Copyright © 2011-2022 走看看