• 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.

  • 相关阅读:
    云计算
    uc/xi
    互联网 2.0概念
    java连接数据库
    记录一下安装 mysql 的踩坑之路
    1
    Linux介绍与基本必知命令
    Web课程Linux命令统计
    7——条件判断、三目运算、条件循环、迭代循环
    6——散列类型、运算符优先级、逻辑运算
  • 原文地址:https://www.cnblogs.com/weifeng1463/p/12916199.html
Copyright © 2020-2023  润新知