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.

  • 相关阅读:
    git生成sshkey
    Linux中假设系统丢失了ls命令
    Linux中rpm包管理器
    Linux软件包分类
    VI编辑器
    Java多线程——多线程方法详解
    Maven 无法下载依赖包的解决方法---三步dao!!!
    7. SOFAJRaft源码分析—如何实现一个轻量级的对象池?
    动手造轮子:实现简单的 EventQueue
    java中的string对象深入了解
  • 原文地址:https://www.cnblogs.com/weifeng1463/p/12916199.html
Copyright © 2011-2022 走看看