{"id":36201,"date":"2026-11-27T22:05:30","date_gmt":"2026-11-27T22:05:30","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=36201"},"modified":"2026-11-27T22:05:30","modified_gmt":"2026-11-27T22:05:30","slug":"helm-tutorials-how-to-create-basic-custom-charts","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/helm-tutorials-how-to-create-basic-custom-charts\/","title":{"rendered":"Helm Tutorials: How to create Basic Custom Charts"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This tutorial shows how to build a minimal custom Helm chart: scaffold it with <code>helm create<\/code>, remove the default templates, add your own Pod template, set chart metadata in <code>Chart.yaml<\/code>, and install it on a Kubernetes cluster. The commands above are the short version. The sections below add the file contents, explain what each step does, show how to check that it worked, and fix a few problems in the original commands.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">$ sudo -s\r\n$ apt-<span class=\"hljs-keyword\">get<\/span> install tree -y\r\n$ helm create devopsx\r\n$ cd devopsx\/templates\/\r\n$ rm -rf deployment.yaml hpa.yaml ingress.yaml service.yaml serviceaccount.yaml\r\n$ vi pod.yaml # https:\/\/www.devopsschool.com\/blog\/kubernetes-pod-example-programs\/\r\n$ cd ..\r\n$ vi Chart.yaml\r\n$ cd ..\r\n$ helm install -h\r\n$ helm install devopsx .\/devopsx\/\r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A running Kubernetes cluster (minikube, kind, k3s or a managed cluster) and a working <code>kubectl<\/code>. Check with <code>kubectl get nodes<\/code>.<\/li>\n\n\n<li>Helm 3 or later installed. Check with <code>helm version<\/code>. Helm 3 needs no Tiller and uses the same kubeconfig as <code>kubectl<\/code>.<\/li>\n\n\n<li>Optional: the <code>tree<\/code> utility for viewing the chart layout (<code>sudo apt-get install -y tree<\/code> on Debian or Ubuntu).<\/li>\n\n\n<li>Basic knowledge of Kubernetes Pod manifests. If Helm is new to you, read <a href=\"https:\/\/www.devopsschool.com\/blog\/a-quick-tutorial-of-helm\/\">What is Helm &amp; How it works?<\/a> first.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Only the <code>apt-get<\/code> step needs root. Run <code>helm<\/code> and <code>kubectl<\/code> as your normal user. The <code>sudo -s<\/code> in the example above switches you to root, and root usually has no <code>~\/.kube\/config<\/code>, which causes the error <code>Kubernetes cluster unreachable<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What helm create generates<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>helm create devopsx<\/code> creates a working sample chart that deploys nginx with a Deployment, Service, optional Ingress, HPA and ServiceAccount. Run <code>tree devopsx<\/code> to see the layout. The exact file list depends on your Helm version, and newer releases add extra templates, so check it rather than assuming.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">devopsx\/\n\u251c\u2500\u2500 Chart.yaml          <span class=\"hljs-comment\"># chart name, version and metadata<\/span>\n\u251c\u2500\u2500 charts\/             <span class=\"hljs-comment\"># dependent (sub)charts<\/span>\n\u251c\u2500\u2500 templates\/\n\u2502   \u251c\u2500\u2500 NOTES.txt       <span class=\"hljs-comment\"># text printed after install<\/span>\n\u2502   \u251c\u2500\u2500 _helpers.tpl    <span class=\"hljs-comment\"># reusable named templates (names, labels)<\/span>\n\u2502   \u251c\u2500\u2500 deployment.yaml\n\u2502   \u251c\u2500\u2500 hpa.yaml\n\u2502   \u251c\u2500\u2500 ingress.yaml\n\u2502   \u251c\u2500\u2500 service.yaml\n\u2502   \u251c\u2500\u2500 serviceaccount.yaml\n\u2502   \u2514\u2500\u2500 tests\/\n\u2502       \u2514\u2500\u2500 test-connection.yaml\n\u251c\u2500\u2500 values.yaml         <span class=\"hljs-comment\"># default configuration values<\/span>\n\u2514\u2500\u2500 .helmignore         <span class=\"hljs-comment\"># files excluded when packaging<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">The <code>rm<\/code> command above removes the five resource templates but leaves <code>NOTES.txt<\/code>, <code>_helpers.tpl<\/code> and <code>tests\/test-connection.yaml<\/code>. Keep <code>_helpers.tpl<\/code> because it gives you consistent names and labels. The test Pod expects a Service that no longer exists, so delete it. Replace <code>NOTES.txt<\/code> with something simple, because the default one refers to Service and Ingress values.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Build the chart step by step<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Scaffold the chart: <code>helm create devopsx<\/code>.<\/li>\n\n\n<li>Remove the default resource templates and the test: <code>cd devopsx\/templates &amp;&amp; rm -f deployment.yaml hpa.yaml ingress.yaml service.yaml serviceaccount.yaml &amp;&amp; rm -rf tests<\/code>. Run <code>ls<\/code> afterwards. If your Helm version generated other resource templates, such as an HTTPRoute, delete those too.<\/li>\n\n\n<li>Create <code>templates\/pod.yaml<\/code> with the template shown in the next section.<\/li>\n\n\n<li>Replace <code>templates\/NOTES.txt<\/code> with a short message (example below).<\/li>\n\n\n<li>Edit <code>Chart.yaml<\/code> to set the description, chart <code>version<\/code> and <code>appVersion<\/code>.<\/li>\n\n\n<li>Go back to the parent directory and validate: <code>helm lint .\/devopsx<\/code> and <code>helm template devopsx .\/devopsx<\/code>.<\/li>\n\n\n<li>Install: <code>helm install devopsx .\/devopsx<\/code>.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">The chart files<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A hard-coded Pod manifest copied into <code>templates\/<\/code> will install, but it isn&#039;t really a chart yet: you can&#039;t change the image or install the chart twice without editing the file. The template below takes its name and labels from <code>_helpers.tpl<\/code> and the image from <code>values.yaml<\/code>, so each release gets a unique name and can be configured at install time.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># devopsx\/templates\/pod.yaml<\/span>\napiVersion: v1\nkind: Pod\nmetadata:\n  name: {{ <span class=\"hljs-keyword\">include<\/span> <span class=\"hljs-string\">\"devopsx.fullname\"<\/span> . }}\n  labels:\n    {{- <span class=\"hljs-keyword\">include<\/span> <span class=\"hljs-string\">\"devopsx.labels\"<\/span> . | nindent <span class=\"hljs-number\">4<\/span> }}\nspec:\n  containers:\n    - name: {{ .Chart.Name }}\n      image: <span class=\"hljs-string\">\"{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}\"<\/span>\n      imagePullPolicy: {{ .Values.image.pullPolicy }}\n      ports:\n        - name: http\n          containerPort: <span class=\"hljs-number\">80<\/span>\n          protocol: TCP<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ul class=\"wp-block-list\">\n<li><code>include &quot;devopsx.fullname&quot; .<\/code> produces the release-based name defined in <code>_helpers.tpl<\/code>. A release named <code>devopsx<\/code> gives a Pod named <code>devopsx<\/code>. A release named <code>web<\/code> gives <code>web-devopsx<\/code>.<\/li>\n\n\n<li><code>nindent 4<\/code> adds a newline and indents the label block correctly. Wrong indentation is the most common cause of template errors.<\/li>\n\n\n<li><code>.Values.image.tag | default .Chart.AppVersion<\/code> uses the tag from values and falls back to <code>appVersion<\/code> in <code>Chart.yaml<\/code> when the tag is empty, which it is by default.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">A minimal <code>Chart.yaml<\/code>. <code>version<\/code> is the version of the chart itself and must follow SemVer. <code>appVersion<\/code> is the version of the application inside it.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># devopsx\/Chart.yaml<\/span>\napiVersion: v2\nname: devopsx\ndescription: A basic custom chart that runs a single nginx Pod\ntype: application\nversion: <span class=\"hljs-number\">0.1<\/span><span class=\"hljs-number\">.0<\/span>\nappVersion: <span class=\"hljs-string\">\"1.27\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">The generated <code>values.yaml<\/code> already contains the <code>image<\/code> block used above (<code>repository: nginx<\/code>, <code>pullPolicy: IfNotPresent<\/code>, <code>tag: &quot;&quot;<\/code>). You can trim <code>values.yaml<\/code> down to just that block, but only after replacing <code>NOTES.txt<\/code>. Otherwise rendering fails because the old notes reference removed keys. A simple replacement:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\"># devopsx\/templates\/NOTES.txt\nPod {{ include \"devopsx.fullname\" . }} was created in namespace {{ .Release.Namespace }}.\nCheck it with:\n  kubectl get pod {{ include \"devopsx.fullname\" . }} -n {{ .Release.Namespace }}<\/code><\/span><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Validate, install and verify<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Always render and lint before installing. <code>helm template<\/code> prints the final YAML without contacting the cluster. <code>--dry-run<\/code> sends the rendered YAML to the API server for validation but creates nothing.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">helm lint .\/devopsx\nhelm template devopsx .\/devopsx\nhelm install devopsx .\/devopsx --dry-run\n\nhelm install devopsx .\/devopsx\nhelm list\nkubectl <span class=\"hljs-keyword\">get<\/span> pods -l app.kubernetes.io\/instance=devopsx\nhelm <span class=\"hljs-keyword\">get<\/span> manifest devopsx<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">A successful install prints output similar to this, followed by your notes:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\">NAME: devopsx\nLAST DEPLOYED: <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">timestamp<\/span>&gt;<\/span>\nNAMESPACE: default\nSTATUS: deployed\nREVISION: 1\nTEST SUITE: None\nNOTES:\nPod devopsx was created in namespace default.<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">To override values at install time, use <code>--set<\/code> or a values file. For example, <code>helm install web .\/devopsx --set image.tag=1.26<\/code> installs a second release with a different image and a Pod named <code>web-devopsx<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Upgrade, package and clean up<\/h2>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Apply chart or value changes to an existing release<\/span>\nhelm upgrade devopsx .\/devopsx --set image.tag=<span class=\"hljs-number\">1.26<\/span>\nhelm history devopsx\nhelm rollback devopsx <span class=\"hljs-number\">1<\/span>\n\n<span class=\"hljs-comment\"># Package the chart into devopsx-0.1.0.tgz for sharing<\/span>\nhelm package .\/devopsx\n\n<span class=\"hljs-comment\"># Remove the release and its Pod<\/span>\nhelm uninstall devopsx<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Most fields of a running Pod spec are immutable. An upgrade that only changes the container image works, but changing ports, environment variables or resources fails with <code>Forbidden: pod updates may not change fields...<\/code>. This is one reason real charts use a Deployment instead of a bare Pod. A bare Pod is fine for learning but isn&#039;t recreated if its node fails.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common errors and fixes<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Error<\/th><th>Cause<\/th><th>Fix<\/th><\/tr><\/thead><tbody><tr><td><code>Kubernetes cluster unreachable<\/code><\/td><td>Helm can&#039;t find a kubeconfig, often because it is running as root after <code>sudo -s<\/code><\/td><td>Run Helm as the user who owns <code>~\/.kube\/config<\/code>, or set <code>KUBECONFIG<\/code><\/td><\/tr><tr><td><code>cannot re-use a name that is still in use<\/code><\/td><td>A release with that name already exists<\/td><td>Use <code>helm upgrade<\/code>, choose another name, or <code>helm uninstall<\/code> first<\/td><\/tr><tr><td><code>nil pointer evaluating interface {}.enabled<\/code><\/td><td>A template (usually the old <code>NOTES.txt<\/code>) references a key that was removed from <code>values.yaml<\/code><\/td><td>Remove the reference or restore the key<\/td><\/tr><tr><td><code>YAML parse error<\/code> \/ <code>error converting YAML to JSON<\/code><\/td><td>Wrong indentation in a template<\/td><td>Run <code>helm template<\/code> and check the indentation around <code>nindent<\/code><\/td><\/tr><tr><td>Pod stuck in <code>ImagePullBackOff<\/code><\/td><td>The image tag doesn&#039;t exist<\/td><td>Check <code>appVersion<\/code> or <code>image.tag<\/code>, then <code>kubectl describe pod devopsx<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Next steps<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once this works, add a Deployment and Service template, then try lifecycle hooks with <a href=\"https:\/\/www.devopsschool.com\/blog\/helm-tutorials-complete-tutorials-of-helm-hooks\/\">Helm Hooks<\/a>. To manage several releases declaratively, see the <a href=\"https:\/\/www.devopsschool.com\/blog\/helmfile-tutorial-from-beginner-to-advanced\/\">Helmfile tutorial<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">What is the difference between version and appVersion in Chart.yaml?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>version<\/code> is the SemVer version of the chart itself. Increase it whenever the templates or defaults change. <code>appVersion<\/code> is informational and describes the application version, and many templates use it as the default image tag.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Do I need sudo to run helm install?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. Helm uses your kubeconfig and Kubernetes RBAC, not Linux root privileges. Running it as root often fails because root has no kubeconfig.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I see the YAML that Helm will apply?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run <code>helm template &lt;release&gt; &lt;chart-path&gt;<\/code> to render it locally, or <code>helm get manifest &lt;release&gt;<\/code> to see what an installed release applied.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can I install the same chart twice in one namespace?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, as long as each release has a different name and the templates derive resource names from the release, for example with <code>include &quot;devopsx.fullname&quot; .<\/code>. Hard-coded names cause a conflict on the second install.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why should I use a Deployment instead of a Pod in a chart?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A Deployment recreates failed Pods, supports rolling updates and lets you change any field of the Pod template on upgrade. A bare Pod has none of these features and is best kept for learning or one-off tasks.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related tutorials<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/a-quick-tutorial-of-helm\/\">Helm Tutorials: What is Helm &amp; How it works?<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/helm-tutorials-complete-tutorials-of-helm-hooks\/\">Helm Tutorials: Complete tutorials of Helm Hooks<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/helmfile-tutorial-from-beginner-to-advanced\/\">Helmfile Tutorial: From Beginner to Advanced<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/top-50-helm-interview-questions-and-answers\/\">Top 50 Helm interview questions and answers<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/category\/containers-kubernetes\/helm\/\">More Helm tutorials<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to build a minimal custom Helm chart: scaffold it with helm create, remove the default templates, add your own Pod template, set chart&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[26147],"tags":[26185,5664],"class_list":["post-36201","post","type-post","status-publish","format-standard","hentry","category-helm","tag-helm-charts","tag-kubernetes-pods"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/36201","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=36201"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/36201\/revisions"}],"predecessor-version":[{"id":80373,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/36201\/revisions\/80373"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=36201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=36201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=36201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}