首页 > 其他分享 >helm _helpers.tpl 文件用法

helm _helpers.tpl 文件用法

时间:2023-04-19 20:11:39浏览次数:46  
标签:templates 文件 image tpl #...... chart helpers helm 模板

templates 目录下⾯除了 NOTES.txt 文件和以下划线 _ 开头命令的文件之外,都会被当做 kubernetes 的资源清单文件,而这个下划线开头的文件不会被当做资源清单外,还可以被其他chart 模板中调用

命名模板我们也可以称为子模板,是限定在⼀个文件内部的模板,然后给⼀个名称,在使用命名模板的时候有⼀个需要特别注意的是:模板名称是全局的,如果我们声明了两个相同名称的模板,最后加载的⼀个模板会覆盖掉另外的模板,由于子chart中的模板也是和顶层的模板⼀起编译的,所以在命名的时候⼀定要注意,不能重名了。为了避免重名,有个通用的约定就是为每个定义的模板添加上 chart 名称: {{define”mychart.labels”}} , define 关键字就是用来声明命名模板的,加上 chart 名称就可以避免不同chart 间的模板出现冲突的情况。

values.yaml

image:
  repoprefix: harbor.com/library
  repository: nginx
  pullPolicy: IfNotPresent
  tag: "0.1.1"

templates/_helpers.tpl 

{{- define "myImage" -}}
{{- printf "%s/%s:%s" .Values.image.repoprefix .Values.image.repository  .Values.image.tag }}
{{- end -}}

templates/deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  #......
  template:
    #......
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: {{ template "myImage" . }}

最终效果

---
# Source: aaaaaa/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  #......
  template:
    #......
    spec:
      containers:
        - name: aaaaaa
          image: harbor.com/library/nginx:0.1.1

d

标签:templates,文件,image,tpl,#......,chart,helpers,helm,模板
From: https://www.cnblogs.com/outsrkem/p/17334483.html

相关文章

  • helm 常用语法
     values.yamlimage:repoprefix:harbor.com/libraryrepository:nginxpullPolicy:IfNotPresenttag:"0.1.1"---{{-$image:=printf"%s/%s:%s".Values.image.repoprefix.Values.image.repository.Values.image.tag}}apiVersion:......
  • 69、K8S-Helm-template导出独立的yaml文件
    1、将helm项目导出为独立yaml文件-实践1.1、需求有时候,我们需要导出yaml分析yaml编写情况,而不是直接部署到k8s,这个时候,就需要使用template来实现了1.2、开始操作1.2.1、创建存放yaml文件的目录helm_prometheus]#cd/opt/helm_prometheus/&&mkdirprometheus-tplhelm_p......
  • python的matplotlib绘制动态图形(用animation中的FuncAnimation)
    %matplotlibauto#数据透视表:#统计各月每天的刷卡金额之和#month_day_df=pd.pivot_table(data_df,values="刷卡金额",index="日",columns="月份",aggfunc=np.sum)#用折线图表示1月份每天的刷卡金额之和importmatplotlib.pyplotaspltfrommatplotlib.animationimpor......
  • Helm模板.Files.Get函数
     常规用法apiVersion:v1kind:ConfigMapmetadata:name:templatesbinaryData:file1:{{.Files.Get"files/file1"|b64enc}}file2:{{.Files.Get"files/file2"|b64enc}}#错误示例apiVersion:v1kind:ConfigMapmetadata:name:temp......
  • Udhcpc.user script documentation and how to hotplug for DHCP events
    Udhcpc.userscriptdocumentationandhowtohotplugforDHCPeventshttps://forum.openwrt.org/t/udhcpc-user-script-documentation-and-how-to-hotplug-for-dhcp-events/47952/10 Hi,guys!I'vebeenlookingforwaystoexecuteprogrammes/scriptsonDHCP......
  • Python 使用Matplotlib绘制可拖动的折线
    Python使用Matplotlib绘制可拖动的折线效果图: 可以拖曲线上的点调整,也可以拖旁边的sliderbar调整.  代码如下:importmatplotlib.animationasanimationfrommatplotlib.widgetsimportSlider,Buttonimportpandasaspdimportmatplotlibasmplfrommatpl......
  • 使用okhttp-4.10.0.jar报,但是发现没有HttpLoggingInterceptor的解决方法
    HttpLoggingInterceptor是OkHttp库中的一个拦截器,可以用于记录HTTP请求和响应的信息,如请求和响应的头部、HTTP方法和请求体等。在OkHttp3.x版本中,HttpLoggingInterceptor是内置的,可以直接使用。但是在OkHttp4.x版本中,HttpLoggingInterceptor被移动到了另外一个库ok......
  • 67、K8S-部署管理-Helm部署Prometheus、TSDB数据持久化
    Kubernetes学习目录1、准备仓库1.1、配置prometheus仓库1.1.1、增加prometheus仓库helmrepoaddprometheus-communityhttps://prometheus-community.github.io/helm-charts1.1.2、查询增加的结果]#helmrepolistNAMEURL......
  • 66、K8S-部署管理-Helm-自定义helm项目
    1、自定义helm项目管理-实践1.1、自定义helm项目1.1.1、创建存放的目录mkdir-p/opt/custom_helm&&cd/opt/custom_helm1.1.2、创建helm项目helmcreatenginx1.2.3、目录的解析custom_helm]#treenginx/nginx/-自动生成的空ch......
  • 65、K8S-部署管理-Helm基础知识、安装、入门示例
    Kubernetes学习目录1、基础知识1.1、需求在kubernetes平台上,我们在部署各种各样的应用服务的时候,可以基于手工或者自动的方式对各种资源对象实现伸缩操作,尤其是对于有状态的应用,我们可以结合持久性存储机制实现更大场景的伸缩动作。但是,无论我们怎么操作各种资源对象,问......