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.

  • 相关阅读:
    windows sharepoint service 适配器 使用说明
    Windows SharePoint Services 适配器 启动工作流失败的解决方案。
    编写一个SharePoint 自定义Web服务
    任意输入三个数,获得最大值
    用ASP获取别的网页的内容
    k8s搭建web界面管理rancher
    CRT 远程连接 ubuntu失败
    开源Nginx 文件上传服务器。ngx_upload_module+web.py+gevent+varnish前端缓存
    Esxi 5.1 添加存储设备的问题
    Abp Vnext 中如何统一接口返回值
  • 原文地址:https://www.cnblogs.com/weifeng1463/p/12916199.html
Copyright © 2011-2022 走看看