{"id":40756,"date":"2023-10-03T19:25:29","date_gmt":"2023-10-03T19:25:29","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=40756"},"modified":"2023-10-03T19:25:30","modified_gmt":"2023-10-03T19:25:30","slug":"helm-tutorials-templatefiles-section-of-the-value-file","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/helm-tutorials-templatefiles-section-of-the-value-file\/","title":{"rendered":"Helm Tutorials: templateFiles section of the value file"},"content":{"rendered":"\n<p>The <code>templateFiles<\/code> section of the Helm chart custom values file is used to define template files that are to be generated in addition to the template files that are included in the Helm chart. This can be useful for customizing the Helm chart or for generating additional Kubernetes resources that are not included in the chart by default.<\/p>\n\n\n\n<p>Each template file in the <code>templateFiles<\/code> section is defined as an object with the following properties:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code><strong>name<\/strong><\/code>: The name of the template file.<\/li>\n\n\n\n<li><code><strong>envName<\/strong><\/code>: The name of the environment variable that will contain the path to the generated template file.<\/li>\n\n\n\n<li><code><strong>content<\/strong><\/code>: The contents of the template file.<\/li>\n<\/ul>\n\n\n\n<p>The <code>content<\/code> field can be a string or a YAML object. If the <code>content<\/code> field is a string, it will be rendered as a literal string in the generated template file. If the <code>content<\/code> field is a YAML object, it will be rendered as a YAML object in the generated template file.<\/p>\n\n\n\n<p>Here is an example of a <code>templateFiles<\/code> section in a custom values file:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/10\/image.png\" alt=\"\" class=\"wp-image-40757\" style=\"width:840px;height:527px\" width=\"840\" height=\"527\"\/><\/figure>\n\n\n\n<p>This <code>templateFiles<\/code> section defines a single template file called <code>my-custom-template.yaml<\/code>. The template file will be generated as a Deployment with the name <code>my-custom-deployment<\/code>.<\/p>\n\n\n\n<p>When the Helm chart is installed, Helm will render the <code>my-custom-template.yaml<\/code> template file and generate a Deployment with the name <code>my-custom-deployment<\/code>.<\/p>\n\n\n\n<p>The <code>templateFiles<\/code> section of the custom values file can be used to generate any type of Kubernetes resource, including Deployments, Services, ConfigMaps, Secrets, and PersistentVolumeClaims. It can also be used to generate custom resources that are created by Custom Resource Definitions (CRDs).<\/p>\n\n\n\n<p><strong>Usage<\/strong><\/p>\n\n\n\n<p>To use the <code>templateFiles<\/code> section of the custom values file, you would pass it to the Helm install command using the <code>--values<\/code> flag. For example:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">helm install my-chart .\/my-chart --values custom-values.yaml\n<\/code><\/span><\/pre>\n\n\n<p>This would install the Helm chart with the name <code>my-chart<\/code> and the custom values defined in the <code>custom-values.yaml<\/code> file.<\/p>\n\n\n\n<p><strong>Benefits<\/strong><\/p>\n\n\n\n<p>Using the <code>templateFiles<\/code> section of the custom values file has a number of benefits, including:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It allows you to customize the Helm chart for your specific needs.<\/li>\n\n\n\n<li>It allows you to generate additional Kubernetes resources that are not included in the chart by default.<\/li>\n\n\n\n<li>It allows you to keep your custom templates in a separate file, which makes it easier to manage and update them.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The templateFiles section of the Helm chart custom values file is used to define template files that are to be generated in addition to the template files that are included in the Helm chart. This can be useful for customizing the Helm chart or for generating additional Kubernetes resources that are not included in the&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[2],"tags":[],"class_list":["post-40756","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/40756","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=40756"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/40756\/revisions"}],"predecessor-version":[{"id":40758,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/40756\/revisions\/40758"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=40756"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=40756"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=40756"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}